upgrade to astro v7

This commit is contained in:
2026-08-22 07:59:49 -04:00
parent 8799733474
commit 0ded527b40
5 changed files with 511 additions and 358 deletions
+6 -3
View File
@@ -1,7 +1,8 @@
import { defineConfig } from "astro/config";
import mdx from '@astrojs/mdx';
import vue from '@astrojs/vue';
import { remarkDescription } from './src/plugins.ts';
import { satteri } from '@astrojs/markdown-satteri';
import { description } from './src/plugins.ts';
export default defineConfig({
integrations: [
@@ -10,12 +11,14 @@ export default defineConfig({
],
prefetch: true,
markdown: {
remarkPlugins: [remarkDescription],
processor: satteri({
mdastPlugins: [description],
}),
shikiConfig: {
themes: {
light: 'dracula',
dark: 'dark-plus',
}
},
}
},
});
+482 -316
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -1,15 +1,15 @@
{
"dependencies": {
"@astrojs/check": "^0.9.6",
"@astrojs/mdx": "^4.3.13",
"@astrojs/rss": "^4.0.15",
"@astrojs/sitemap": "^3.7.0",
"@astrojs/vue": "^5.1.4",
"@astrojs/check": "0.9.10",
"@astrojs/mdx": "7.0.7",
"@astrojs/rss": "4.0.19",
"@astrojs/sitemap": "3.7.3",
"@astrojs/vue": "7.0.2",
"@fontsource-variable/baskervville": "^5.2.3",
"@fontsource-variable/baskervville-sc": "^5.2.3",
"@fontsource-variable/figtree": "^5.2.10",
"@fontsource-variable/fira-code": "^5.2.7",
"astro": "^5.18.0",
"astro": "7.2.4",
"sharp": "^0.34.5"
},
"name": "astro",
+1 -1
View File
@@ -19,7 +19,7 @@ const posts = await Promise.all(entries.map(async entry => {
<ul>
{posts.map( (p, idx) =>
<li>
{idx > 0 && <hr></hr>}
{idx > 0 && <hr />}
<h2>
<a href={`/${p.id}`} data-astro-prefetch>
{p.data.title}
+16 -32
View File
@@ -1,33 +1,17 @@
import type { Root, Paragraph, PhrasingContent } from 'mdast';
import type { VFile } from 'vfile';
import { visit } from 'unist-util-visit';
import { toString } from 'mdast-util-to-string';
import { defineMdastPlugin } from 'satteri';
export function remarkDescription() {
return (tree: Root, vfile: VFile) => {
let description: string | null = null;
visit(tree, 'paragraph', (node: Paragraph) => {
if (description !== null) return;
description = summarize(node);
});
// Astro exposes this as `remarkPluginFrontmatter` from render()
const astro = (vfile.data.astro ??= { frontmatter: {} }) as { frontmatter: Record<string, unknown> };
astro.frontmatter.description = description;
};
}
/**
* Convert a paragraph node to a plain-text string, stripping any
* MDX JSX elements (e.g. <Sidenote>) so their content doesn't
* leak into the summary.
*/
function summarize(par: Paragraph): string {
const filtered = par.children.filter(
(child: PhrasingContent) => !(child.type as string).startsWith('mdxJsx')
);
return toString({ type: 'paragraph', children: filtered });
}
export const description = defineMdastPlugin({
name: 'description',
paragraph(node, ctx) {
if (ctx.data.astro !== undefined) {
const astro = ctx.data.astro as { frontmatter: Record<string, unknown> };
if (astro.frontmatter.description === undefined) {
const filteredText = node.children
.filter(c => c.type !== 'mdxJsxTextElement')
.map(c => ctx.textContent(c))
.join('');
astro.frontmatter.description = filteredText;
}
}
},
})