Skip to content

Commit 9d0ba10

Browse files
Document the headings anchor script in the design system
1 parent 8b7ad76 commit 9d0ba10

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

design-system-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'Styles' => '/styles/',
1818
'Layouts' => '/layouts/',
1919
'Components' => '/components/',
20-
'Third party plugins' => '/third-party-plugins/',
20+
'Scripts' => '/scripts/',
2121
'Templates' => '/templates/',
2222
],
2323
'templates_path' => 'design-system-templates',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<p>Copyright © 2023 W3C - generated {{ date|date("d M Y, H:i:s e") }}</p>
1+
<p>Copyright © {{ date|date("Y") }} W3C - generated {{ date|date("d M Y, H:i:s e") }}</p>
22
<p>Feedback is welcome and can be submitted as a <a href="https://github.com/w3c/w3c-website/issues">GitHub issue</a>.</p>

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ More generic and wide-reaching styles sit within the lower numbered levels, with
2525
- **40-layouts:**<br> heavily influenced by [Every Layout](https://every-layout.dev/), these are the styles for the basic layout types, which can be combined and customised to make a variety of components and templates - [more about layouts](layouts/README.md)
2626
- **50-core-components:**<br> the basic components available for use, un-enhanced by JavaScript - [more about components](components/README.md)
2727
- **60-advanced-components:**<br> components that are enhanced in some way with JavaScript - [more about components](components/README.md)
28-
- **70-third-party-plugins:**<br> any functionality that comes from external sources - [more about third-party plugins](third-party-plugins/README.md)
28+
- **70-third-party-plugins:**<br> styles for components/functionality from sources external to the design system, typically via scripts. They may include some customisations specifically required to fit in with the design system.
2929
- **80-templates:**<br> styles required for specific page templates and/or content types - [more about templates](templates/README.md)
3030
- **90-utilities:**<br> overrides or helper classes - [more about utilities](styles/utilities.md)
3131

docs/scripts/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Scripts
2+
3+
Documenting functionality that is added via scripts.
4+
5+
For sources that are external to the design system, there may be some customisations specifically required.

docs/scripts/heading-anchors.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Heading anchors
2+
3+
This script is part of `main.js`/`main.min.js`. To help linking to specific parts of pages, this script automatically creates and appends a visible anchor link to any H2-H6 heading within the `<main>` element, with the following exclusions:
4+
5+
- where the heading is a child of a `<nav>` element
6+
- where the heading carries the attribute `data-anchor="no"`
7+
- where a heading has an ancestor carrying the attribute `data-anchor="no"`
8+
9+
If a heading already has an `id` attribute, this is used when creating the `href` for the `<a>`. Otherwise, the script parses the text content of the heading to create both the heading `id` and the anchor `href`.
10+
11+
To override the default behaviour of the script and prevent the addition of anchor links to headings, modify the HTML markup to apply the `data-anchor="no"` attribute to an individual heading (or to a parent container, if targeting a group of headings).

docs/third-party-plugins/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)