1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-12 01:50:52 +01:00

Added support for skip-to-content link

This commit is contained in:
squidfunk 2018-01-18 21:19:10 +01:00 committed by Martin Donath
parent c3cdb945a6
commit 0e1850280a
10 changed files with 57 additions and 12 deletions

View File

@ -115,7 +115,7 @@ If you're using Windows command prompt (`cmd.exe`), substitute `${PWD}` with
## Usage
In order to enable the theme just add one of the following lines to your
project's `mkdocs.yml`. If you installed Material using pip:
project's `mkdocs.yml`. If you installed Material using a package manager:
``` yaml
theme:
@ -335,9 +335,9 @@ Material supports both, left-to-right (`ltr`) and right-to-left (`rtl`) text
direction. This enables more languages like Arabic, Hebrew, Syriac and others
to be used with the theme:
```
``` yaml
theme:
direction: rtl
direction: 'rtl'
```
#### Site search

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -46,7 +46,7 @@
{% endif %}
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application.2a88008a.css">
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application.f450e885.css">
{% if palette.primary or palette.accent %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-palette.792431c1.css">
{% endif %}
@ -92,6 +92,11 @@
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
{% if page.toc | first is defined %}
<a href="{{ (page.toc | first).url }}" tabindex="1" class="md-skip">
{{ lang.t('skip.link.title') }}
</a>
{% endif %}
{% block header %}
{% include "partials/header.html" %}
{% endblock %}
@ -162,7 +167,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application.d5140e78.js"></script>
<script src="{{ base_url }}/assets/javascripts/application.fa71e325.js"></script>
{% if lang.t("search.language") != "en" %}
{% set languages = lang.t("search.language").split(",") %}
{% if languages | length and languages[0] != "" %}

View File

@ -13,6 +13,7 @@
"search.result.one": "1 matching document",
"search.result.other": "# matching documents",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Skip to content",
"source.link.title": "Go to repository",
"toc.title": "Table of contents"
}[key] }}{% endmacro %}

View File

@ -55,13 +55,9 @@
}
}
// Hide anchor for top-level heading, as it makes no sense
h1[id] .headerlink {
display: none;
}
// Correct anchor offset for link blurring
@each $level, $delta in (
h1: 10rem,
h2: 0.8rem,
h3: 0.9rem,
h4: 0.9rem,

View File

@ -201,6 +201,40 @@ hr {
}
}
// ----------------------------------------------------------------------------
// Rules: skip link
// ----------------------------------------------------------------------------
// Skip link
.md-skip {
position: fixed;
width: 0.1rem;
height: 0.1rem;
margin: 1rem;
padding: 0.6rem 1rem;
clip: rect(0.1rem);
transform: translateY(0.8rem);
border-radius: 0.2rem;
background-color: $md-color-black;
color: $md-color-white;
font-size: ms(-1);
opacity: 0;
overflow: hidden;
// Show skip link on focus
&:focus {
width: auto;
height: auto;
clip: auto;
transform: translateX(0);
transition:
transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
opacity 0.175s 0.075s;
opacity: 1;
z-index: 10;
}
}
// ----------------------------------------------------------------------------
// Rules: print styles
// ----------------------------------------------------------------------------

View File

@ -185,6 +185,14 @@
<!-- Overlay for expanded drawer -->
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
<!-- Render "skip to content" link -->
{% if page.toc | first is defined %}
<a href="{{ (page.toc | first).url }}" tabindex="1"
class="md-skip">
{{ lang.t('skip.link.title') }}
</a>
{% endif %}
<!-- Application header -->
{% block header %}
{% include "partials/header.html" %}

View File

@ -36,6 +36,7 @@
"search.result.one": "1 matching document",
"search.result.other": "# matching documents",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Skip to content",
"source.link.title": "Go to repository",
"toc.title": "Table of contents"
}[key] }}{% endmacro %}