Skip to content

Commit 258ccf2

Browse files
bleucitronRomain Cresteybenmccann
authored
docs: add category heading in docs pages (#8918)
Co-authored-by: Romain Crestey <[email protected]> Co-authored-by: Ben McCann <[email protected]>
1 parent 85d4940 commit 258ccf2

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

sites/svelte.dev/src/lib/server/docs/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export async function get_docs_data(base = CONTENT_BASE_PATHS.DOCS) {
7575
title: page_title,
7676
slug: page_slug,
7777
content: page_content,
78+
category: category_title,
7879
sections: get_sections(page_content),
7980
path: `${app_base}/docs/${page_slug}`,
8081
file: `${category_dir}/${filename}`

sites/svelte.dev/src/lib/server/docs/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Category = {
1717

1818
export type Page = {
1919
title: string;
20+
category: string;
2021
slug: string;
2122
file: string;
2223
path: string;

sites/svelte.dev/src/routes/docs/+layout.svelte

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
55
export let data;
66
7-
$: title = $page.data.page?.title;
7+
$: pageData = $page.data.page;
8+
9+
$: title = pageData?.title;
10+
$: category = pageData?.category;
811
</script>
912
1013
<div class="container">
@@ -13,6 +16,9 @@
1316
</div>
1417
1518
<div class="page content">
19+
{#if category}
20+
<p class="category">{category}</p>
21+
{/if}
1622
{#if title}
1723
<h1>{title}</h1>
1824
{/if}
@@ -41,6 +47,14 @@
4147
all: unset;
4248
}
4349
50+
.category {
51+
font: 700 var(--sk-text-s) var(--sk-font);
52+
text-transform: uppercase;
53+
letter-spacing: 0.12em;
54+
margin: 0 0 0.5em;
55+
color: var(--sk-text-3);
56+
}
57+
4458
@media (min-width: 832px) {
4559
.content {
4660
padding-left: calc(var(--sidebar-width) + var(--sk-page-padding-side));

0 commit comments

Comments
 (0)