diff --git a/src/components/documentSettings.svelte b/src/components/documentSettings.svelte new file mode 100644 index 0000000..5501fcf --- /dev/null +++ b/src/components/documentSettings.svelte @@ -0,0 +1,116 @@ + + +{#snippet LinkItem({ href, icon, name }: AiOption)} + + {#snippet child({ props })} + {@const Icon = icon} + +
+ + {name} + +
+
+ {/snippet} +
+{/snippet} + +
+ + + + + + + + {@render LinkItem({ + href: rawUrl, + icon: Markdown, + name: "View as Markdown", + })} + {#each aiOptions as option (option.name)} + {@render LinkItem(option)} + {/each} + + + +
diff --git a/src/routes/api/docs/[...slug]/+server.ts b/src/routes/api/docs/[...slug]/+server.ts new file mode 100644 index 0000000..a33237c --- /dev/null +++ b/src/routes/api/docs/[...slug]/+server.ts @@ -0,0 +1,15 @@ +import type { RequestEvent } from "@sveltejs/kit"; +import { error } from "@sveltejs/kit"; +import { allDocs } from "content-collections"; + +export const GET = async ({ params }: RequestEvent) => { + const document = allDocs.find((doc) => doc._meta.path === params.slug); + if (!document) { + throw error(404, `Could not find ${params.slug}`); + } + return new Response(document.content, { + headers: { + "Content-Type": "text/markdown; charset=utf-8", + }, + }); +}; diff --git a/src/routes/docs/[...slug]/+page.svelte b/src/routes/docs/[...slug]/+page.svelte index a966b58..d2b7fff 100644 --- a/src/routes/docs/[...slug]/+page.svelte +++ b/src/routes/docs/[...slug]/+page.svelte @@ -5,15 +5,16 @@ import PageCard from "@/components/pageCard.svelte"; import Container from "@/components/container.svelte"; import PageHeader from "@/components/pageHeader.svelte"; - import TableOfContents from "@/components/tableOfContents/tableOfContents.svelte"; + import { buttonVariants } from "@/components/ui/button"; import * as Collapsible from "@/components/ui/collapsible"; + import DocumentSettings from "@/components/documentSettings.svelte"; + import TableOfContents from "@/components/tableOfContents/tableOfContents.svelte"; import FileText from "@lucide/svelte/icons/file-text"; + import ChevronDown from "@lucide/svelte/icons/chevron-down"; // Markdown: import "@/styles/markdown.css"; - import { buttonVariants } from "@/components/ui/button"; - import ChevronDown from "@lucide/svelte/icons/chevron-down"; let { data }: PageProps = $props(); let tocOpen = $state(false); @@ -38,6 +39,11 @@ {document.title}

+