mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
🛠️ Initial content-collections config + /docs/* route
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
import type { PageProps } from "./$types";
|
||||
|
||||
import PageCard from "@/components/pageCard.svelte";
|
||||
import PageHeader from "@/components/pageHeader.svelte";
|
||||
|
||||
import Container from "@/components/container.svelte";
|
||||
import FileText from "@lucide/svelte/icons/file-text";
|
||||
|
||||
let { data }: PageProps = $props();
|
||||
const document = $derived(data.document);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.document.title} - Svgl</title>
|
||||
<meta name="description" content={data.document.description} />
|
||||
</svelte:head>
|
||||
|
||||
<PageCard>
|
||||
<PageHeader>
|
||||
<div
|
||||
class="flex items-center space-x-2 font-medium text-neutral-950 dark:text-neutral-50"
|
||||
>
|
||||
<FileText size={18} strokeWidth={1.5} />
|
||||
<p>
|
||||
{document.title}
|
||||
</p>
|
||||
</div>
|
||||
</PageHeader>
|
||||
<Container className="my-6">
|
||||
<article>{@html document.html}</article>
|
||||
</Container>
|
||||
</PageCard>
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { allDocs } from "content-collections";
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const document = allDocs.find((doc) => doc._meta.path == params.slug);
|
||||
if (!document) {
|
||||
error(404, `Could not find ${params.slug}`);
|
||||
}
|
||||
return {
|
||||
document,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user