Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/svelte.dev/src/lib/server/content.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { read } from '$app/server';
import type { Document } from '@sveltejs/site-kit';
import type { Document, DocumentSummary } from '@sveltejs/site-kit';
import { create_index } from '@sveltejs/site-kit/server/content';

const documents = import.meta.glob<string>('../../../content/**/*.md', {
Expand Down Expand Up @@ -123,6 +123,14 @@ function create_docs() {
return docs;
}

export function create_summary(document: Document): DocumentSummary {
return {
slug: document.slug,
metadata: document.metadata,
children: document.children.map(create_summary)
};
}

export const docs = create_docs();

export const examples = index.examples.children;
4 changes: 2 additions & 2 deletions apps/svelte.dev/src/routes/docs/[...path]/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { docs } from '$lib/server/content';
import { create_summary, docs } from '$lib/server/content';
import { redirect } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';

Expand All @@ -20,6 +20,6 @@ export async function load({ params }) {
}

return {
sections: document.children
sections: document.children.map(create_summary)
};
}
4 changes: 2 additions & 2 deletions packages/site-kit/src/lib/docs/DocsContents.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import type { Document } from '../types';
import type { Document, DocumentSummary } from '../types';

interface Props {
contents: Document[];
contents: DocumentSummary[];
show_ts_toggle?: boolean;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/site-kit/src/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export interface Document {
prev: null | { slug: string; title: string };
}

export interface DocumentSummary {
slug: string;
metadata: {
title: string;
[key: string]: any;
};
children: DocumentSummary[];
}

export interface Section {
slug: string;
title: string;
Expand Down