Skip to content

Commit

Permalink
chore: add mdx filter test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Jan 12, 2024
1 parent eb86e64 commit a5430a4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/__snapshots__/mdx.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ snapshot[`Build a mdx site 1`] = `
"/_includes",
"/_includes/Image.tsx",
"/index.mdx",
"/mdx-filter.page.ts",
],
}
`;
Expand Down Expand Up @@ -198,5 +199,51 @@ This is a markdown file with the title **{ title }**.
remote: undefined,
},
},
{
content: '<!DOCTYPE html>
<hr/>
<h2>title: Hello world
description: This is a description</h2>
<header><h1>Hello world</h1><p>This is a description</p></header>
<h2>Hello world</h2>
<p>This is a markdown file with the title <strong>Hello world</strong>.</p>
<img src="https://via.placeholder.com/350x150" alt="foo"/>',
data: {
basename: "mdx-filter",
children: '<hr/>
<h2>title: Hello world
description: This is a description</h2>
<header><h1>Hello world</h1><p>This is a description</p></header>
<h2>Hello world</h2>
<p>This is a markdown file with the title <strong>Hello world</strong>.</p>
<img src="https://via.placeholder.com/350x150" alt="foo"/>',
comp: [
"_components",
"_proxies",
],
content: "default",
date: [],
mergedKeys: [
"tags",
],
page: [
"src",
"data",
],
paginate: "paginate",
search: [],
tags: "Array(0)",
title: "mdx filter example",
url: "/mdx-filter/",
},
src: {
asset: false,
ext: ".page.ts",
path: "/mdx-filter",
remote: undefined,
},
},
]
`;
26 changes: 26 additions & 0 deletions tests/assets/mdx/mdx-filter.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import "../../../types.ts";

export const title = "mdx filter example";
export default async (data: Lume.Data, { mdx }: Lume.Helpers) =>
await mdx(
`
---
title: Hello world
description: This is a description
---
import Image from "./_includes/Image.tsx";
<comp.Header title={title} description={description}/>
## Hello world
This is a markdown file with the title **{ title }**.
<Image alt="foo" />
`,
{
...data,
title: "Hello world",
description: "This is a description",
},
);

0 comments on commit a5430a4

Please sign in to comment.