Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add anchors to headings inside docs content #16134

Merged
merged 3 commits into from Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/_includes/components/docs-toc.html
@@ -1,6 +1,6 @@
<nav class="docs-toc c-toc" aria-labelledby="js-toc-label">
{%- if all_content | toc | safe | length -%}
<h2 class="c-toc__label" id="js-toc-label">Table of Contents</h2>
<p class="c-toc__label" id="js-toc-label">Table of Contents</p>
harish-sethuraman marked this conversation as resolved.
Show resolved Hide resolved
<div class="c-toc__panel" id="js-toc-panel">
{{ all_content | toc | safe }}
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/src/_includes/layouts/base.html
Expand Up @@ -121,6 +121,7 @@
<script type="module" src="{{ '/assets/js/search.js' | url }}"></script>
<link rel="stylesheet" type="text/css" href="{{ '/assets/css/styles.css' | url }}">
<link rel="stylesheet" href="{{ '/assets/css/print.css' | url }}" media="print">
<script src="https://unpkg.com/anchor-js@4.3.1/anchor.min.js"></script>
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an actual dependency in package.json on the old documentation site so probably it should be here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea? We could do it either way? https://www.npmjs.com/package/anchor-js both are suggested as per their documentation?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer to take advantage of the package management provided by package.json and specify it there, especially given that we haven't begun using unpkg anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to change the imports as module if we want to use imports or add passthrough through eleventy (I haven't tried these yet) anyway the passthrough is just going to import add the files into the assets and we will be importing it from there. I don't think there is going to be much difference using the dep from npm too instead of this approach which seems very straight forward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now. If we end up needing to upgrade this dependency at any point, then I'd say let's move it to an npm dependency.

</head>

<body class="{{ hook }} docs">
Expand Down
4 changes: 4 additions & 0 deletions docs/src/assets/js/main.js
Expand Up @@ -276,3 +276,7 @@ if (index) {
allCollapsed: false
});
}

document.addEventListener("DOMContentLoaded", () => {
anchors.add(".docs-content h2, .docs-content h3, .docs-content h4");
});
1 change: 1 addition & 0 deletions docs/src/assets/scss/components/toc.scss
Expand Up @@ -55,6 +55,7 @@

.c-toc__label.c-toc__label {
font-size: var(--step-0);
font-weight: 500;
color: var(--body-text-color);
font-family: var(--text-font);
margin-bottom: .5rem;
Expand Down