Skip to content

Commit 3864628

Browse files
Add custom header, social, and copyright partials
Introduces custom Jinja2 partials for header, social links, copyright, and generator to the MkDocs theme. Updates mkdocs.yml to adjust social icons, add a generator position option, and remove the cookie settings link. These changes enable more flexible layout and branding in the documentation site.
1 parent 34ed86b commit 3864628

File tree

5 files changed

+266
-3
lines changed

5 files changed

+266
-3
lines changed

mkdocs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ extra:
207207
# Configures the hyperlink for the logo in the header
208208
homepage: https://www.sparkfun.com/
209209

210+
generator: right
211+
210212
# Configures social icons in the footer
211213
social:
212214
- icon: sfe
@@ -221,9 +223,6 @@ extra:
221223
link: https://www.facebook.com/SparkFun
222224
- icon: fontawesome/brands/x-twitter
223225
link: https://twitter.com/sparkfun
224-
- icon: fontawesome/solid/cookie-bite
225-
link: ./#__consent
226-
name: Change cookie settings
227226

228227
# Configures Google Analytics
229228
analytics:

overrides/partials/copyright.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Copyright and theme information -->
24+
<div class="md-copyright">
25+
{% if config.copyright %}
26+
<div class="md-copyright__highlight">
27+
{{ config.copyright }}
28+
</div>
29+
{% endif %}
30+
{% if not config.extra.generator == false %}
31+
{% if not config.extra.generator == "right" %}
32+
{% include "partials/generator.html" %}
33+
{% endif %}
34+
{% endif %}
35+
</div>

overrides/partials/generator.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Made with
2+
<a
3+
href="https://squidfunk.github.io/mkdocs-material/"
4+
target="_blank" rel="noopener"
5+
>
6+
Material for MkDocs
7+
</a>

overrides/partials/header.html

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<!--
2+
Copyright (c) 2016-2024 Martin Donath <martin.donath@squidfunk.com>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Determine classes -->
24+
{% set class = "md-header" %}
25+
{% if "navigation.tabs.sticky" in features %}
26+
{% set class = class ~ " md-header--shadow md-header--lifted" %}
27+
{% elif "navigation.tabs" not in features %}
28+
{% set class = class ~ " md-header--shadow" %}
29+
{% endif %}
30+
31+
<!-- Header -->
32+
<header class="{{ class }}" data-md-component="header">
33+
<nav
34+
class="md-header__inner md-grid"
35+
aria-label="{{ lang.t('header') }}"
36+
>
37+
38+
<!-- Link to home -->
39+
<!-- <a
40+
href="{{ config.extra.homepage | d(nav.homepage.url, true) | url }}"
41+
title="{{ config.site_name | e }}"
42+
class="md-header__button md-logo"
43+
aria-label="{{ config.site_name }}"
44+
data-md-component="logo"
45+
>
46+
{% include "partials/logo.html" %}
47+
</a> -->
48+
<a
49+
href="{{ config.extra.homepage | d(nav.homepage.url, true) | url }}"
50+
title="www.sparkfun.com/pnt"
51+
class="md-header__button md-logo"
52+
aria-label="{{ config.site_name }}"
53+
data-md-component="logo"
54+
>
55+
{% include "partials/logo.html" %}
56+
</a>
57+
58+
<!-- Button to open drawer -->
59+
<label class="md-header__button md-icon" for="__drawer">
60+
{% set icon = config.theme.icon.menu or "material/menu" %}
61+
{% include ".icons/" ~ icon ~ ".svg" %}
62+
</label>
63+
64+
<!-- Header title -->
65+
<div class="md-header__title" data-md-component="header-title">
66+
<div class="md-header__ellipsis">
67+
<div class="md-header__topic">
68+
<span class="md-ellipsis">
69+
{{ config.site_name }}
70+
</span>
71+
</div>
72+
<div class="md-header__topic" data-md-component="header-topic">
73+
<span class="md-ellipsis">
74+
{% if page.meta and page.meta.title %}
75+
{{ page.meta.title }}
76+
{% else %}
77+
{{ page.title }}
78+
{% endif %}
79+
</span>
80+
</div>
81+
</div>
82+
</div>
83+
84+
85+
<!-- Color palette -->
86+
{% if not config.theme.palette is mapping %}
87+
<form class="md-header__option" data-md-component="palette">
88+
{% for option in config.theme.palette %}
89+
{% set scheme = option.scheme | d("default", true) %}
90+
<input
91+
class="md-option"
92+
data-md-color-media="{{ option.media }}"
93+
data-md-color-scheme="{{ scheme | replace(' ', '-') }}"
94+
data-md-color-primary="{{ option.primary | replace(' ', '-') }}"
95+
data-md-color-accent="{{ option.accent | replace(' ', '-') }}"
96+
{% if option.toggle %}
97+
aria-label="{{ option.toggle.name }}"
98+
{% else %}
99+
aria-hidden="true"
100+
{% endif %}
101+
type="radio"
102+
name="__palette"
103+
id="__palette_{{ loop.index }}"
104+
/>
105+
{% if option.toggle %}
106+
<label
107+
class="md-header__button md-icon"
108+
title="{{ option.toggle.name }}"
109+
for="__palette_{{ loop.index0 or loop.length }}"
110+
hidden
111+
>
112+
{% include ".icons/" ~ option.toggle.icon ~ ".svg" %}
113+
</label>
114+
{% endif %}
115+
{% endfor %}
116+
</form>
117+
{% endif %}
118+
119+
<!-- Button for Cookie Consent -->
120+
<label class="md-header__button md-icon">
121+
<a href="#__consent" title="Manage Cookies">
122+
{% include ".icons/material/cookie-edit.svg" %}
123+
</a>
124+
</label>
125+
126+
127+
<!-- Site language selector -->
128+
{% if config.extra.alternate %}
129+
{% include "partials/alternate.html" %}
130+
{% endif %}
131+
132+
<!-- Button to open search modal -->
133+
{% if "material/search" in config.plugins %}
134+
<label class="md-header__button md-icon" for="__search">
135+
{% set icon = config.theme.icon.search or "material/magnify" %}
136+
{% include ".icons/" ~ icon ~ ".svg" %}
137+
</label>
138+
139+
<!-- Search interface -->
140+
{% include "partials/search.html" %}
141+
{% endif %}
142+
143+
<!-- Repository information -->
144+
{% if config.repo_url %}
145+
<div class="md-header__source">
146+
{% include "partials/source.html" %}
147+
</div>
148+
{% endif %}
149+
</nav>
150+
151+
<!-- Navigation tabs (sticky) -->
152+
{% if "navigation.tabs.sticky" in features %}
153+
{% if "navigation.tabs" in features %}
154+
{% include "partials/tabs.html" %}
155+
{% endif %}
156+
{% endif %}
157+
</header>

overrides/partials/social.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!--
2+
Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Social links -->
24+
<div>
25+
{% if config.extra.generator == "right" %}
26+
<article class="md-social generator-right">
27+
{% endif %}
28+
{% if not config.extra.generator == "right" %}
29+
<article class="md-social">
30+
{% endif %}
31+
32+
{% for social in config.extra.social %}
33+
34+
<!-- Automatically set rel=me for Mastodon -->
35+
{% set rel = "noopener" %}
36+
{% if "mastodon" in social.icon %}
37+
{% set rel = rel ~ " me" %}
38+
{% endif %}
39+
40+
<!-- Compute title and render link -->
41+
{% set title = social.name %}
42+
{% if not title and "//" in social.link %}
43+
{% set _, url = social.link.split("//") %}
44+
{% set title = url.split("/")[0] %}
45+
{% endif %}
46+
<a
47+
href="{{ social.link }}"
48+
target="_blank" rel="{{ rel }}"
49+
title="{{ title | e }}"
50+
class="md-social__link"
51+
>
52+
{% include ".icons/" ~ social.icon ~ ".svg" %}
53+
</a>
54+
{% endfor %}
55+
</article>
56+
57+
58+
{% if config.extra.generator == "right" %}
59+
<article class="md-copyright generator-right">
60+
{% include "partials/generator.html" %}
61+
</article>
62+
{% endif %}
63+
64+
65+
</div>

0 commit comments

Comments
 (0)