summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-frontmatter.test.js
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2022-08-12 17:17:26 -0500
committerGravatar GitHub <noreply@github.com> 2022-08-12 18:17:26 -0400
commitf7afdb889fe4e97177958c8ec92f80c5f6e5cb51 (patch)
treebcc42e78a52a91a9a5efe14e93e3c517acb2b441 /packages/integrations/mdx/test/mdx-frontmatter.test.js
parent437bf73f264b2811b7ee8f11c2b54d3414144a0f (diff)
downloadastro-f7afdb889fe4e97177958c8ec92f80c5f6e5cb51.tar.gz
astro-f7afdb889fe4e97177958c8ec92f80c5f6e5cb51.tar.zst
astro-f7afdb889fe4e97177958c8ec92f80c5f6e5cb51.zip
[MDX] Fix remaining inconsistencies with Markdown (#4268)
* feat: add "file" and "url" to layout props * feat: add rawContent and compiledContent errs * fix: add "file" and "url" to frontmatter * fix: add separate MDX instance type * types: add MarkdownLayoutProps and MDXLayoutProps * refactor: simplify MDXLayoutProps * test: pass file and url to layout * test: glob components with .default and Content * feat: add <Content /> to MDX * feat: declare MDX type module * fix: [MD] move file and url to layout props only * chore: changeset * chore: bump MDX to "minor" with more details * refactor: remove "file" + "url" top-level props (save for minor) * revert: MDInstance type def updates (save for minor) * fix: MDXInstance "default" + "content" types * fix: bad test layout * chore: remove getHeaders fro *.mdx
Diffstat (limited to 'packages/integrations/mdx/test/mdx-frontmatter.test.js')
-rw-r--r--packages/integrations/mdx/test/mdx-frontmatter.test.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-frontmatter.test.js b/packages/integrations/mdx/test/mdx-frontmatter.test.js
index e69919bd5..9f0e9d8e6 100644
--- a/packages/integrations/mdx/test/mdx-frontmatter.test.js
+++ b/packages/integrations/mdx/test/mdx-frontmatter.test.js
@@ -56,4 +56,15 @@ describe('MDX frontmatter', () => {
expect(headingSlugs).to.contain('section-1');
expect(headingSlugs).to.contain('section-2');
});
+
+ it('passes "file" and "url" to layout via frontmatter', async () => {
+ const html = await fixture.readFile('/with-headings/index.html');
+ const { document } = parseHTML(html);
+
+ const frontmatterFile = document.querySelector('[data-frontmatter-file]')?.textContent;
+ const frontmatterUrl = document.querySelector('[data-frontmatter-url]')?.textContent;
+
+ expect(frontmatterFile?.endsWith('with-headings.mdx')).to.equal(true, '"file" prop does not end with correct path or is undefined');
+ expect(frontmatterUrl).to.equal('/with-headings');
+ });
});