summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/mdx/src')
-rw-r--r--packages/integrations/mdx/src/index.ts6
-rw-r--r--packages/integrations/mdx/src/plugins.ts2
-rw-r--r--packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts6
-rw-r--r--packages/integrations/mdx/src/rehype-collect-headings.ts2
-rw-r--r--packages/integrations/mdx/src/rehype-images-to-component.ts2
-rw-r--r--packages/integrations/mdx/src/rehype-optimize-static.ts4
-rw-r--r--packages/integrations/mdx/src/utils.ts6
-rw-r--r--packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts8
-rw-r--r--packages/integrations/mdx/src/vite-plugin-mdx.ts4
9 files changed, 20 insertions, 20 deletions
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts
index 30f827dc8..de29003ff 100644
--- a/packages/integrations/mdx/src/index.ts
+++ b/packages/integrations/mdx/src/index.ts
@@ -68,7 +68,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
},
contentModuleTypes: await fs.readFile(
new URL('../template/content-module-types.d.ts', import.meta.url),
- 'utf-8'
+ 'utf-8',
),
// MDX can import scripts and styles,
// so wrap all MDX files with script / style propagation checks
@@ -91,7 +91,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
options: partialMdxOptions,
defaults: markdownConfigToMdxOptions(
extendMarkdownConfig ? config.markdown : markdownConfigDefaults,
- logger
+ logger,
),
});
@@ -113,7 +113,7 @@ const defaultMdxOptions = {
function markdownConfigToMdxOptions(
markdownConfig: typeof markdownConfigDefaults,
- logger: AstroIntegrationLogger
+ logger: AstroIntegrationLogger,
): MdxOptions {
return {
...defaultMdxOptions,
diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts
index 3978e5325..082e8f6fd 100644
--- a/packages/integrations/mdx/src/plugins.ts
+++ b/packages/integrations/mdx/src/plugins.ts
@@ -86,7 +86,7 @@ function getRehypePlugins(mdxOptions: MdxOptions): PluggableList {
// Render info from `vfile.data.astro.data.frontmatter` as JS
rehypeApplyFrontmatterExport,
// Analyze MDX nodes and attach to `vfile.data.__astroMetadata`
- rehypeAnalyzeAstroMetadata
+ rehypeAnalyzeAstroMetadata,
);
if (mdxOptions.optimize) {
diff --git a/packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts b/packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts
index 3a1098800..7fa7f69ef 100644
--- a/packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts
+++ b/packages/integrations/mdx/src/rehype-apply-frontmatter-export.ts
@@ -10,7 +10,7 @@ export function rehypeApplyFrontmatterExport() {
throw new Error(
// Copied from Astro core `errors-data`
// TODO: find way to import error data from core
- '[MDX] A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.'
+ '[MDX] A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
);
const { frontmatter } = astroData;
const exportNodes = [
@@ -40,8 +40,8 @@ export function rehypeApplyFrontmatterExport() {
'server:root': true,
children,
});
- };`
- )
+ };`,
+ ),
);
}
tree.children = exportNodes.concat(tree.children);
diff --git a/packages/integrations/mdx/src/rehype-collect-headings.ts b/packages/integrations/mdx/src/rehype-collect-headings.ts
index 69e3f9b1b..fafc59721 100644
--- a/packages/integrations/mdx/src/rehype-collect-headings.ts
+++ b/packages/integrations/mdx/src/rehype-collect-headings.ts
@@ -5,7 +5,7 @@ export function rehypeInjectHeadingsExport() {
return function (tree: any, file: MarkdownVFile) {
const headings: MarkdownHeading[] = file.data.__astroHeadings || [];
tree.children.unshift(
- jsToTreeNode(`export function getHeadings() { return ${JSON.stringify(headings)} }`)
+ jsToTreeNode(`export function getHeadings() { return ${JSON.stringify(headings)} }`),
);
};
}
diff --git a/packages/integrations/mdx/src/rehype-images-to-component.ts b/packages/integrations/mdx/src/rehype-images-to-component.ts
index 6c797fda2..95b500784 100644
--- a/packages/integrations/mdx/src/rehype-images-to-component.ts
+++ b/packages/integrations/mdx/src/rehype-images-to-component.ts
@@ -157,7 +157,7 @@ export function rehypeImageToComponent() {
tree.children.unshift(...importsStatements);
tree.children.unshift(
- jsToTreeNode(`import { Image as ${ASTRO_IMAGE_IMPORT} } from "astro:assets";`)
+ jsToTreeNode(`import { Image as ${ASTRO_IMAGE_IMPORT} } from "astro:assets";`),
);
// Export `__usesAstroImage` to pick up `astro:assets` usage in the module graph.
// @see the '@astrojs/mdx-postprocess' plugin
diff --git a/packages/integrations/mdx/src/rehype-optimize-static.ts b/packages/integrations/mdx/src/rehype-optimize-static.ts
index ebedb753e..80c28ab9c 100644
--- a/packages/integrations/mdx/src/rehype-optimize-static.ts
+++ b/packages/integrations/mdx/src/rehype-optimize-static.ts
@@ -183,7 +183,7 @@ interface ElementGroup {
function findElementGroups(
allPossibleElements: Set<OptimizableNode>,
elementMetadatas: WeakMap<OptimizableNode, ElementMetadata>,
- isNodeNonStatic: (node: Node) => boolean
+ isNodeNonStatic: (node: Node) => boolean,
): ElementGroup[] {
const elementGroups: ElementGroup[] = [];
@@ -195,7 +195,7 @@ function findElementGroups(
const metadata = elementMetadatas.get(el);
if (!metadata) {
throw new Error(
- 'Internal MDX error: rehype-optimize-static should have metadata for element node'
+ 'Internal MDX error: rehype-optimize-static should have metadata for element node',
);
}
diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts
index 4705316cc..ad98abb9e 100644
--- a/packages/integrations/mdx/src/utils.ts
+++ b/packages/integrations/mdx/src/utils.ts
@@ -18,7 +18,7 @@ export interface FileInfo {
/** @see 'vite-plugin-utils' for source */
export function getFileInfo(id: string, config: AstroConfig): FileInfo {
const sitePathname = appendForwardSlash(
- config.site ? new URL(config.base, config.site).pathname : config.base
+ config.site ? new URL(config.base, config.site).pathname : config.base,
);
// Try to grab the file's actual URL
@@ -69,7 +69,7 @@ export function jsToTreeNode(
acornOpts: AcornOpts = {
ecmaVersion: 'latest',
sourceType: 'module',
- }
+ },
): MdxjsEsm {
return {
type: 'mdxjsEsm',
@@ -101,7 +101,7 @@ export function ignoreStringPlugins(plugins: any[], logger: AstroIntegrationLogg
}
if (hasInvalidPlugin) {
logger.warn(
- `To inherit Markdown plugins in MDX, please use explicit imports in your config instead of "strings." See Markdown docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins`
+ `To inherit Markdown plugins in MDX, please use explicit imports in your config instead of "strings." See Markdown docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins`,
);
}
return validPlugins;
diff --git a/packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts b/packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts
index 7661c0ecf..e00173fbe 100644
--- a/packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts
+++ b/packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts
@@ -50,7 +50,7 @@ function injectUnderscoreFragmentImport(code: string, imports: readonly ImportSp
function injectMetadataExports(
code: string,
exports: readonly ExportSpecifier[],
- fileInfo: FileInfo
+ fileInfo: FileInfo,
) {
if (!exports.some(({ n }) => n === 'url')) {
code += `\nexport const url = ${JSON.stringify(fileInfo.fileUrl)};`;
@@ -101,7 +101,7 @@ function annotateContentExport(
code: string,
id: string,
ssr: boolean,
- imports: readonly ImportSpecifier[]
+ imports: readonly ImportSpecifier[],
) {
// Mark `Content` as MDX component
code += `\nContent[Symbol.for('mdx-component')] = true`;
@@ -117,7 +117,7 @@ function annotateContentExport(
code,
imports,
astroTagComponentImportRegex,
- 'astro/runtime/server/index.js'
+ 'astro/runtime/server/index.js',
)
) {
code += `\nimport { __astro_tag_component__ } from 'astro/runtime/server/index.js';`;
@@ -135,7 +135,7 @@ function isSpecifierImported(
code: string,
imports: readonly ImportSpecifier[],
specifierRegex: RegExp,
- source: string
+ source: string,
) {
for (const imp of imports) {
if (imp.n !== source) continue;
diff --git a/packages/integrations/mdx/src/vite-plugin-mdx.ts b/packages/integrations/mdx/src/vite-plugin-mdx.ts
index 1b966ecd2..b232d1c83 100644
--- a/packages/integrations/mdx/src/vite-plugin-mdx.ts
+++ b/packages/integrations/mdx/src/vite-plugin-mdx.ts
@@ -54,7 +54,7 @@ export function vitePluginMdx(mdxOptions: MdxOptions): Plugin {
// should be called in between those two lifecycle, so this error should never happen
if (!processor) {
return this.error(
- 'MDX processor is not initialized. This is an internal error. Please file an issue.'
+ 'MDX processor is not initialized. This is an internal error. Please file an issue.',
);
}
@@ -86,7 +86,7 @@ function getMdxMeta(vfile: VFile): Record<string, any> {
const astroMetadata = getAstroMetadata(vfile);
if (!astroMetadata) {
throw new Error(
- 'Internal MDX error: Astro metadata is not set by rehype-analyze-astro-metadata'
+ 'Internal MDX error: Astro metadata is not set by rehype-analyze-astro-metadata',
);
}
return {