mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-27 09:19:53 +00:00
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { frontmatter } from '@/content/md/frontmatter';
|
|
import { test, expect } from 'vitest';
|
|
|
|
test('parse frontmatter', () => {
|
|
expect(frontmatter('---\ntitle: hello world\ndescription: I love Fumadocs\n---\nwow looks cool.'))
|
|
.toMatchInlineSnapshot(`
|
|
{
|
|
"content": "wow looks cool.",
|
|
"data": {
|
|
"description": "I love Fumadocs",
|
|
"title": "hello world",
|
|
},
|
|
"matter": "---
|
|
title: hello world
|
|
description: I love Fumadocs
|
|
---
|
|
",
|
|
}
|
|
`);
|
|
|
|
expect(
|
|
frontmatter(
|
|
'---\r\ntitle: hello world\r\ndescription: I love Fumadocs\r\n---\r\nwow looks cool.',
|
|
),
|
|
).toMatchInlineSnapshot(`
|
|
{
|
|
"content": "wow looks cool.",
|
|
"data": {
|
|
"description": "I love Fumadocs",
|
|
"title": "hello world",
|
|
},
|
|
"matter": "---
|
|
title: hello world
|
|
description: I love Fumadocs
|
|
---
|
|
",
|
|
}
|
|
`);
|
|
|
|
expect(frontmatter('--- \ntitle: hello world\r\n---\r\nwow looks cool.')).toMatchInlineSnapshot(`
|
|
{
|
|
"content": "---
|
|
title: hello world
|
|
---
|
|
wow looks cool.",
|
|
"data": {},
|
|
"matter": "",
|
|
}
|
|
`);
|
|
});
|