Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually configure MDX integration #7972

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions astro.config.ts
Expand Up @@ -6,9 +6,9 @@ import { makeSidebar } from './config/sidebar';
import rehypeSlug from 'rehype-slug';
import remarkSmartypants from 'remark-smartypants';

import { mdx } from './integrations/mdx';
import { sitemap } from './integrations/sitemap';
import { rehypeAutolink } from './plugins/rehype-autolink';
import { rehypeOptimizeStatic } from './plugins/rehype-optimize-static';
import { rehypeTasklistEnhancer } from './plugins/rehype-tasklist-enhancer';
import { remarkFallbackLang } from './plugins/remark-fallback-lang';

Expand Down Expand Up @@ -65,6 +65,7 @@ export default defineConfig({
],
}),
sitemap(),
mdx(),
],
trailingSlash: 'always',
scopedStyleStrategy: 'where',
Expand All @@ -83,8 +84,6 @@ export default defineConfig({
...rehypeAutolink(),
// Tweak GFM task list syntax
rehypeTasklistEnhancer(),
// Collapse static parts of the hast to html
rehypeOptimizeStatic,
],
},
image: {
Expand Down
16 changes: 16 additions & 0 deletions integrations/mdx.ts
@@ -0,0 +1,16 @@
import AstroMdx from '@astrojs/mdx';
import type { AstroIntegration } from 'astro';

/** Add `@astrojs/mdx` integration after Starlight's injected `astro-expressive-code` integration */
export function mdx(): AstroIntegration {
return {
name: 'add-mdx-integration',
hooks: {
'astro:config:setup': ({ config }) => {
const astroMdxIndex = config.integrations.findIndex((i) => i.name === '@astrojs/mdx');
// Replace Starlight injected `@astrojs/mdx` integration with our own
config.integrations.splice(astroMdxIndex, 1, AstroMdx({ optimize: true }));
},
},
};
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -82,6 +82,7 @@
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/mdx": "^2.3.1",
"@astrojs/sitemap": "^3.1.3",
"@astrojs/starlight": "0.21.1",
"@docsearch/js": "^3.5.2",
Expand Down
79 changes: 0 additions & 79 deletions plugins/rehype-optimize-static.ts

This file was deleted.

45 changes: 8 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.