Skip to content

Commit 2842227

Browse files
authored
docs: fix heading level a11y issue (sveltejs#5679)
1 parent 854a7de commit 2842227

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

site/content/docs/01-component-format.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All three sections — script, styles and markup — are optional.
2424

2525
A `<script>` block contains JavaScript that runs when a component instance is created. Variables declared (or imported) at the top level are 'visible' from the component's markup. There are four additional rules:
2626

27-
##### 1. `export` creates a component prop
27+
#### 1. `export` creates a component prop
2828

2929
---
3030

@@ -87,7 +87,7 @@ You can use reserved words as prop names.
8787
</script>
8888
```
8989

90-
##### 2. Assignments are 'reactive'
90+
#### 2. Assignments are 'reactive'
9191

9292
---
9393

@@ -109,7 +109,7 @@ Because Svelte's reactivity is based on assignments, using array methods like `.
109109
</script>
110110
```
111111

112-
##### 3. `$:` marks a statement as reactive
112+
#### 3. `$:` marks a statement as reactive
113113

114114
---
115115

@@ -171,7 +171,7 @@ If a statement consists entirely of an assignment to an undeclared variable, Sve
171171
</script>
172172
```
173173

174-
##### 4. Prefix stores with `$` to access their values
174+
#### 4. Prefix stores with `$` to access their values
175175

176176
---
177177

site/src/routes/docs/index.svelte

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
<script context="module">
2+
const title_replacements = {
3+
'1_export_creates_a_component_prop': 'props',
4+
'2_Assignments_are_reactive': 'reactive assignments',
5+
'3_$_marks_a_statement_as_reactive': 'reactive statements ($:)',
6+
'4_Prefix_stores_with_$_to_access_their_values': 'accessing stores ($)'
7+
};
8+
29
export async function preload() {
310
const sections = await this.fetch(`docs.json`).then(r => r.json());
11+
for (const section of sections) {
12+
for (const subsection of section.subsections) {
13+
const { slug } = subsection;
14+
// show abbreviated title in the table of contents
15+
if (slug in title_replacements) {
16+
subsection.title = title_replacements[slug];
17+
}
18+
}
19+
}
20+
421
return { sections };
522
}
623
</script>

0 commit comments

Comments
 (0)