Skip to content

Commit 9be5474

Browse files
committed
fix(docs): update page component to use server-side data and fix base path links
- Remove client-side markdown fetching in favor of server-side data loading - Fix hardcoded links in breadcrumbs to use correct base path (/rhema/) - Update component to expect data.markdown and data.title from server - Remove loading/error states since content is now prerendered - Resolve base path errors during prerendering
1 parent dd4340a commit 9be5474

1 file changed

Lines changed: 16 additions & 55 deletions

File tree

docs/src/routes/docs/[...slug]/+page.svelte

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,39 @@
11
<script>
22
import { marked } from 'marked';
3-
import { onMount } from 'svelte';
43
54
export let data;
65
76
let content = '';
8-
let title = '';
9-
let loading = true;
10-
let error = false;
11-
12-
onMount(async () => {
13-
try {
14-
const slug = data.slug;
15-
if (!slug) {
16-
error = true;
17-
return;
18-
}
19-
20-
// Try to load the markdown file
21-
const response = await fetch(`/docs/${slug}.md`);
22-
if (!response.ok) {
23-
error = true;
24-
return;
25-
}
26-
27-
const markdown = await response.text();
28-
29-
// Extract title from first heading
30-
const titleMatch = markdown.match(/^#\s+(.+)$/m);
31-
title = titleMatch ? titleMatch[1] : slug.split('/').pop() || 'Documentation';
32-
33-
// Process markdown
34-
content = marked(markdown);
35-
loading = false;
36-
} catch (err) {
37-
console.error('Error loading document:', err);
38-
error = true;
39-
}
40-
});
7+
8+
// Process markdown when data changes
9+
$: {
10+
if (data.markdown) {
11+
content = marked(data.markdown);
12+
}
13+
}
4114
</script>
4215

4316
<svelte:head>
44-
<title>{title || 'Documentation'} - Rhema Documentation</title>
45-
<meta name="description" content="Rhema documentation for {title || 'Documentation'}" />
17+
<title>{data.title} - Rhema Documentation</title>
18+
<meta name="description" content="Rhema documentation for {data.title}" />
4619
</svelte:head>
4720

4821
<div class="docs-page">
4922
<div class="docs-content">
5023
<header class="docs-header">
51-
<h1>{title || 'Loading...'}</h1>
24+
<h1>{data.title}</h1>
5225
<div class="breadcrumb">
53-
<a href="/">Home</a>
26+
<a href="/rhema/">Home</a>
5427
<span class="separator">/</span>
55-
<a href="/docs">Documentation</a>
28+
<a href="/rhema/docs">Documentation</a>
5629
<span class="separator">/</span>
57-
<span class="current">{title || 'Loading...'}</span>
30+
<span class="current">{data.title}</span>
5831
</div>
5932
</header>
6033

61-
{#if loading}
62-
<div class="loading">
63-
<p>Loading documentation...</p>
64-
</div>
65-
{:else if error}
66-
<div class="error">
67-
<h2>Document Not Found</h2>
68-
<p>The requested documentation page could not be found.</p>
69-
<a href="/docs">Return to Documentation</a>
70-
</div>
71-
{:else}
72-
<article class="markdown-content">
73-
{@html content}
74-
</article>
75-
{/if}
34+
<article class="markdown-content">
35+
{@html content}
36+
</article>
7637
</div>
7738
</div>
7839

0 commit comments

Comments
 (0)