From 4bd69b5ede0527d7e6facfa678743fd790921ded Mon Sep 17 00:00:00 2001
From: pheralb
Date: Thu, 18 Sep 2025 12:08:46 +0100
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Create=20=20c?=
=?UTF-8?q?omponent=20and=20integrate=20it=20into=20the=20docs=20page=20la?=
=?UTF-8?q?yout?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/documentSettings.svelte | 116 +++++++++++++++++++++++
src/routes/api/docs/[...slug]/+server.ts | 15 +++
src/routes/docs/[...slug]/+page.svelte | 12 ++-
3 files changed, 140 insertions(+), 3 deletions(-)
create mode 100644 src/components/documentSettings.svelte
create mode 100644 src/routes/api/docs/[...slug]/+server.ts
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}
+
+
+
+ {/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}
+