chore: format

This commit is contained in:
2025-10-10 16:43:21 +02:00
parent f0aabd63b6
commit 75c29e0ba4
551 changed files with 433948 additions and 94145 deletions

View File

@@ -1,27 +1,40 @@
import { withLeadingSlash } from 'ufo'
import { stringify } from 'minimark/stringify'
import { queryCollection } from '@nuxt/content/nitro'
import type { Collections } from '@nuxt/content'
import { withLeadingSlash } from "ufo";
import { stringify } from "minimark/stringify";
import { queryCollection } from "@nuxt/content/nitro";
import type { Collections } from "@nuxt/content";
export default eventHandler(async (event) => {
const slug = getRouterParams(event)['slug.md']
if (!slug?.endsWith('.md')) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}
const slug = getRouterParams(event)["slug.md"];
if (!slug?.endsWith(".md")) {
throw createError({
statusCode: 404,
statusMessage: "Page not found",
fatal: true,
});
}
const path = withLeadingSlash(slug.replace('.md', ''))
const path = withLeadingSlash(slug.replace(".md", ""));
const page = await queryCollection(event, 'docs' as keyof Collections).path(path).first()
if (!page) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}
const page = await queryCollection(event, "docs" as keyof Collections)
.path(path)
.first();
if (!page) {
throw createError({
statusCode: 404,
statusMessage: "Page not found",
fatal: true,
});
}
// Add title and description to the top of the page if missing
if (page.body.value[0]?.[0] !== 'h1') {
page.body.value.unshift(['blockquote', {}, page.description])
page.body.value.unshift(['h1', {}, page.title])
}
// Add title and description to the top of the page if missing
if (page.body.value[0]?.[0] !== "h1") {
page.body.value.unshift(["blockquote", {}, page.description]);
page.body.value.unshift(["h1", {}, page.title]);
}
setHeader(event, 'Content-Type', 'text/markdown; charset=utf-8')
return stringify({ ...page.body, type: 'minimark' }, { format: 'markdown/html' })
})
setHeader(event, "Content-Type", "text/markdown; charset=utf-8");
return stringify(
{ ...page.body, type: "minimark" },
{ format: "markdown/html" },
);
});