diff --git a/packages/astro/test/astro-markdown-frontmatter-injection.test.js b/packages/astro/test/astro-markdown-frontmatter-injection.test.js index 581c72733..436366355 100644 --- a/packages/astro/test/astro-markdown-frontmatter-injection.test.js +++ b/packages/astro/test/astro-markdown-frontmatter-injection.test.js @@ -22,7 +22,9 @@ describe('Astro Markdown - frontmatter injection', () => { it('rehype supports custom vfile data - reading time', async () => { const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); - const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime); + const readingTimes = frontmatterByPage.map( + (frontmatter = {}) => frontmatter.injectedReadingTime + ); expect(readingTimes.length).to.be.greaterThan(0); for (let readingTime of readingTimes) { expect(readingTime).to.not.be.null; @@ -32,7 +34,9 @@ describe('Astro Markdown - frontmatter injection', () => { it('overrides injected frontmatter with user frontmatter', async () => { const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); - const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime?.text); + const readingTimes = frontmatterByPage.map( + (frontmatter = {}) => frontmatter.injectedReadingTime?.text + ); const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title); expect(titles).to.contain('Overridden title'); expect(readingTimes).to.contain('1000 min read'); diff --git a/packages/integrations/mdx/src/astro-data-utils.ts b/packages/integrations/mdx/src/astro-data-utils.ts index bfbc74461..3300c7b55 100644 --- a/packages/integrations/mdx/src/astro-data-utils.ts +++ b/packages/integrations/mdx/src/astro-data-utils.ts @@ -1,8 +1,7 @@ -import { name as isValidIdentifierName } from 'estree-util-is-identifier-name'; -import type { VFile } from 'vfile'; -import type { MdxjsEsm } from 'mdast-util-mdx'; import type { MarkdownAstroData } from 'astro'; -import type { Data } from 'vfile'; +import { name as isValidIdentifierName } from 'estree-util-is-identifier-name'; +import type { MdxjsEsm } from 'mdast-util-mdx'; +import type { Data, VFile } from 'vfile'; import { jsToTreeNode } from './utils.js'; export function remarkInitializeAstroData() { diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 3b1ceaa4c..85eec630e 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -1,7 +1,6 @@ import { compile as mdxCompile, nodeTypes } from '@mdx-js/mdx'; import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; -import type { AstroIntegration, AstroConfig } from 'astro'; -import { remarkInitializeAstroData, rehypeApplyFrontmatterExport } from './astro-data-utils.js'; +import type { AstroConfig, AstroIntegration } from 'astro'; import { parse as parseESM } from 'es-module-lexer'; import rehypeRaw from 'rehype-raw'; import remarkGfm from 'remark-gfm'; @@ -10,6 +9,7 @@ import remarkShikiTwoslash from 'remark-shiki-twoslash'; import remarkSmartypants from 'remark-smartypants'; import { VFile } from 'vfile'; import type { Plugin as VitePlugin } from 'vite'; +import { rehypeApplyFrontmatterExport, remarkInitializeAstroData } from './astro-data-utils.js'; import rehypeCollectHeadings from './rehype-collect-headings.js'; import remarkPrism from './remark-prism.js'; import { getFileInfo, parseFrontmatter } from './utils.js'; diff --git a/packages/integrations/mdx/test/mdx-frontmatter-injection.test.js b/packages/integrations/mdx/test/mdx-frontmatter-injection.test.js index ae1d485bb..420e4716e 100644 --- a/packages/integrations/mdx/test/mdx-frontmatter-injection.test.js +++ b/packages/integrations/mdx/test/mdx-frontmatter-injection.test.js @@ -22,7 +22,9 @@ describe('MDX frontmatter injection', () => { it('rehype supports custom vfile data - reading time', async () => { const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); - const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime); + const readingTimes = frontmatterByPage.map( + (frontmatter = {}) => frontmatter.injectedReadingTime + ); expect(readingTimes.length).to.be.greaterThan(0); for (let readingTime of readingTimes) { expect(readingTime).to.not.be.null; @@ -32,7 +34,9 @@ describe('MDX frontmatter injection', () => { it('overrides injected frontmatter with user frontmatter', async () => { const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); - const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime?.text); + const readingTimes = frontmatterByPage.map( + (frontmatter = {}) => frontmatter.injectedReadingTime?.text + ); const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title); expect(titles).to.contain('Overridden title'); expect(readingTimes).to.contain('1000 min read'); diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 0bb827c30..a50b3ad19 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -7,13 +7,13 @@ import rehypeExpressions from './rehype-expressions.js'; import rehypeIslands from './rehype-islands.js'; import rehypeJsx from './rehype-jsx.js'; import remarkEscape from './remark-escape.js'; +import { remarkInitializeAstroData } from './remark-initialize-astro-data.js'; import remarkMarkAndUnravel from './remark-mark-and-unravel.js'; import remarkMdxish from './remark-mdxish.js'; import remarkPrism from './remark-prism.js'; import scopedStyles from './remark-scoped-styles.js'; import remarkShiki from './remark-shiki.js'; import remarkUnwrap from './remark-unwrap.js'; -import { remarkInitializeAstroData } from './remark-initialize-astro-data.js'; import rehypeRaw from 'rehype-raw'; import rehypeStringify from 'rehype-stringify';