[ci] format
This commit is contained in:
parent
1743fe140e
commit
8e20156638
2 changed files with 9 additions and 9 deletions
|
@ -1,4 +1,3 @@
|
||||||
import type { Plugin as VitePlugin } from 'vite';
|
|
||||||
import { nodeTypes } from '@mdx-js/mdx';
|
import { nodeTypes } from '@mdx-js/mdx';
|
||||||
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
|
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
|
||||||
import type { AstroIntegration } from 'astro';
|
import type { AstroIntegration } from 'astro';
|
||||||
|
@ -10,6 +9,7 @@ import type { RemarkMdxFrontmatterOptions } from 'remark-mdx-frontmatter';
|
||||||
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
|
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
|
||||||
import remarkShikiTwoslash from 'remark-shiki-twoslash';
|
import remarkShikiTwoslash from 'remark-shiki-twoslash';
|
||||||
import remarkSmartypants from 'remark-smartypants';
|
import remarkSmartypants from 'remark-smartypants';
|
||||||
|
import type { Plugin as VitePlugin } from 'vite';
|
||||||
import remarkPrism from './remark-prism.js';
|
import remarkPrism from './remark-prism.js';
|
||||||
import { getFileInfo, getFrontmatter } from './utils.js';
|
import { getFileInfo, getFrontmatter } from './utils.js';
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export default function mdx(mdxOptions: MdxOptions = {}): AstroIntegration {
|
||||||
// Note: disable `.md` support
|
// Note: disable `.md` support
|
||||||
format: 'mdx',
|
format: 'mdx',
|
||||||
mdExtensions: [],
|
mdExtensions: [],
|
||||||
})
|
});
|
||||||
|
|
||||||
updateConfig({
|
updateConfig({
|
||||||
vite: {
|
vite: {
|
||||||
|
@ -98,14 +98,14 @@ export default function mdx(mdxOptions: MdxOptions = {}): AstroIntegration {
|
||||||
const frontmatter = getFrontmatter(code, id);
|
const frontmatter = getFrontmatter(code, id);
|
||||||
if (frontmatter.layout) {
|
if (frontmatter.layout) {
|
||||||
const { layout, ...content } = frontmatter;
|
const { layout, ...content } = frontmatter;
|
||||||
code += `\nexport default async function({ children }) {\nconst Layout = (await import(${
|
code += `\nexport default async function({ children }) {\nconst Layout = (await import(${JSON.stringify(
|
||||||
JSON.stringify(frontmatter.layout)
|
frontmatter.layout
|
||||||
})).default;\nreturn <Layout content={${
|
)})).default;\nreturn <Layout content={${JSON.stringify(
|
||||||
JSON.stringify(content)
|
content
|
||||||
}}>{children}</Layout> }`
|
)}}>{children}</Layout> }`;
|
||||||
}
|
}
|
||||||
return mdxPluginTransform?.(code, id);
|
return mdxPluginTransform?.(code, id);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '@astrojs/mdx',
|
name: '@astrojs/mdx',
|
||||||
|
|
|
@ -42,7 +42,7 @@ export function getFileInfo(id: string, config: AstroConfig): FileInfo {
|
||||||
/**
|
/**
|
||||||
* Match YAML exception handling from Astro core errors
|
* Match YAML exception handling from Astro core errors
|
||||||
* @see 'astro/src/core/errors.ts'
|
* @see 'astro/src/core/errors.ts'
|
||||||
*/
|
*/
|
||||||
export function getFrontmatter(code: string, id: string) {
|
export function getFrontmatter(code: string, id: string) {
|
||||||
try {
|
try {
|
||||||
return matter(code).data;
|
return matter(code).data;
|
||||||
|
|
Loading…
Reference in a new issue