Skip to content

Commit

Permalink
Add a 'skip to main content' for VoiceOver users
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwlchan committed Oct 12, 2022
1 parent 6eebe33 commit 342018f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
6 changes: 5 additions & 1 deletion src/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

{% include head.html %}

<a class="skip-main" href="#main">Skip to main content</a>

<body>
{% include header.html %}

{{ content }}
<main id="main" tabIndex="-1">
{{ content }}
</main>

{% include footer.html %}
</body>
Expand Down
38 changes: 18 additions & 20 deletions src/_layouts/page.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
---
layout: default
---
<main>
{% if page.title != "" %}
<h1 class="title">
<a href="{{ page.url | relative_url }}">{{ page.title | smartify | escape }}</a>
</h1>
{% endif %}
{% if page.title != "" %}
<h1 class="title">
<a href="{{ page.url | relative_url }}">{{ page.title | smartify | escape }}</a>
</h1>
{% endif %}

{% if page.date_updated or page.meta %}
<div class="page__meta">
<ul class="dot_list">
{% if page.date_updated %}
<li class="page__date">Last updated {{ page.date_updated | date: site.date_format }}</li>
{% endif %}
{% for m in page.meta %}
<li>{{ m }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if page.date_updated or page.meta %}
<div class="page__meta">
<ul class="dot_list">
{% if page.date_updated %}
<li class="page__date">Last updated {{ page.date_updated | date: site.date_format }}</li>
{% endif %}
{% for m in page.meta %}
<li>{{ m }}</li>
{% endfor %}
</ul>
</div>
{% endif %}

{{ content | cleanup_text | smartify }}
</main>
{{ content | cleanup_text | smartify }}
10 changes: 10 additions & 0 deletions src/_scss/_links.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* from https://accessibility.oit.ncsu.edu/it-accessibility-at-nc-state/developers/accessibility-handbook/mouse-and-keyboard-events/skip-to-main-content/ */
a.skip-main {
position: absolute;
left: -999px;
top: auto;
width: 1px;
height: 1px;
overflow :hidden;
z-index: -999;
}
1 change: 1 addition & 0 deletions src/_scss/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@import "_layout.scss";
@import "_text.scss";
@import "_links.scss";

// Major page components
@import "_aside.scss";
Expand Down

0 comments on commit 342018f

Please sign in to comment.