Skip to content

Commit b6d6abe

Browse files
authored
feat: add skip-to-content link to improve accessability (#985)
1 parent 3d695d8 commit b6d6abe

File tree

9 files changed

+35
-1
lines changed

9 files changed

+35
-1
lines changed

layouts/_default/baseof.html

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
</head>
2323

2424
<body itemscope itemtype="https://schema.org/WebPage">
25+
<div class="w-full flex justify-center">
26+
<a href="#main-content" id="gdoc-to-main" class="gdoc-markdown__link">Skip to main content</a>
27+
</div>
28+
2529
{{ partial "svg-icon-symbols" . }}
2630

2731

layouts/_default/list.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<article
66
class="gdoc-markdown gdoc-markdown__align--{{ default "left" (.Page.Params.geekdocAlign | lower) }}"
7+
id="main-content" tabindex="-1"
78
>
89
<h1>{{ partial "utils/title" . }}</h1>
910
{{ partial "utils/content" . }}

layouts/_default/single.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<article
66
class="gdoc-markdown gdoc-markdown__align--{{ default "left" (.Page.Params.geekdocAlign | lower) }}"
7+
id="main-content" tabindex="-1"
78
>
89
<h1>{{ partial "utils/title" . }}</h1>
910
{{ partial "page-metadata" . }}

layouts/_default/taxonomy.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{ define "main" }}
2+
<div id="main-content" tabindex="-1">
23
{{ range .Paginator.Pages }}
34
<article class="gdoc-post">
45
<header class="gdoc-post__header">
@@ -31,6 +32,7 @@ <h1 class="gdoc-post__title">
3132
</footer>
3233
</article>
3334
{{ end }}
35+
</div>
3436
{{ partial "pagination.html" . }}
3537
{{ end }}
3638

layouts/_default/terms.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{ define "main" }}
2+
<div id="main-content" tabindex="-1">
23
{{ range .Paginator.Pages.ByTitle }}
34
<article class="gdoc-post">
45
<header class="gdoc-post__header">
@@ -28,5 +29,6 @@ <h1 class="gdoc-post__title">
2829
</footer>
2930
</article>
3031
{{ end }}
32+
</div>
3133
{{ partial "pagination.html" . }}
3234
{{ end }}

layouts/posts/list.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{ define "main" }}
2+
<div id="main-content" tabindex="-1">
23
{{ range .Paginator.Pages }}
34
<article class="gdoc-markdown gdoc-post">
45
<header class="gdoc-post__header">
@@ -29,6 +30,7 @@ <h1 class="gdoc-post__title">
2930
</footer>
3031
</article>
3132
{{ end }}
33+
</div>
3234
{{ partial "pagination.html" . }}
3335
{{ end }}
3436

layouts/posts/single.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<article class="gdoc-post">
2+
<article class="gdoc-post" id="main-content" tabindex="-1">
33
<header class="gdoc-post__header">
44
<h1 class="gdoc-post__title">{{ partial "utils/title" . }}</h1>
55
<div class="flex flex-wrap align-center gdoc-post__meta gdoc-post__meta--head">

src/sass/_base.scss

+18
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ body {
105105
* {
106106
box-sizing: inherit;
107107
}
108+
109+
#gdoc-to-main {
110+
position: absolute;
111+
margin: defaults.$padding-8 0;
112+
padding: defaults.$padding-8;
113+
114+
display: inline-block;
115+
background-color: var(--accent-color-lite);
116+
border-radius: defaults.$border-radius;
117+
border: defaults.$border-1 solid var(--accent-color);
118+
119+
transform: translateY(0);
120+
transition: transform 250ms ease-in;
121+
122+
&:not(:focus) {
123+
transform: translateY(-#{defaults.$padding-64});
124+
}
125+
}
108126
}
109127

110128
h1,

src/sass/_utils.scss

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@
101101
display: inline-block;
102102
min-width: 4rem;
103103
}
104+
105+
.w-full {
106+
width: 100%;
107+
}

0 commit comments

Comments
 (0)