Skip to content

Commit 4e9b047

Browse files
committed
Move noscript elements to head
- Should fix search engines picking up elements inside noscript
1 parent 8021be2 commit 4e9b047

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

layouts/partials/head.html

+42-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,48 @@
113113
{{ end -}}
114114
{{- range .AllTranslations -}}
115115
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" />
116-
{{ end }}
116+
{{ end -}}
117+
118+
<noscript>
119+
<style>
120+
#theme-toggle,
121+
.top-link {
122+
display: none;
123+
}
124+
125+
</style>
126+
{{- if (and (ne .Site.Params.defaultTheme "light") (ne .Site.Params.defaultTheme "dark")) }}
127+
<style>
128+
@media (prefers-color-scheme: dark) {
129+
:root {
130+
--theme: #1d1e20;
131+
--entry: #2e2e33;
132+
--primary: rgba(255, 255, 255, 0.84);
133+
--secondary: rgba(255, 255, 255, 0.56);
134+
--tertiary: rgba(255, 255, 255, 0.16);
135+
--content: rgba(255, 255, 255, 0.74);
136+
--hljs-bg: #2e2e33;
137+
--code-bg: #37383e;
138+
--border: #333;
139+
}
140+
141+
.list {
142+
background: var(--theme);
143+
}
144+
145+
.list:not(.dark)::-webkit-scrollbar-track {
146+
background: 0 0;
147+
}
148+
149+
.list:not(.dark)::-webkit-scrollbar-thumb {
150+
border-color: var(--theme);
151+
}
152+
}
153+
154+
</style>
155+
{{- end }}
156+
</noscript>
157+
117158
{{- partial "extend_head.html" . -}}
118159

119160
{{- /* Misc */}}

layouts/partials/header.html

-39
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,6 @@
3838

3939
</script>
4040
{{- end }}
41-
<noscript>
42-
<style type="text/css">
43-
#theme-toggle,
44-
.top-link {
45-
display: none;
46-
}
47-
48-
</style>
49-
{{- if (and (ne .Site.Params.defaultTheme "light") (ne .Site.Params.defaultTheme "dark")) }}
50-
<style>
51-
@media (prefers-color-scheme: dark) {
52-
:root {
53-
--theme: #1d1e20;
54-
--entry: #2e2e33;
55-
--primary: rgba(255, 255, 255, 0.84);
56-
--secondary: rgba(255, 255, 255, 0.56);
57-
--tertiary: rgba(255, 255, 255, 0.16);
58-
--content: rgba(255, 255, 255, 0.74);
59-
--hljs-bg: #2e2e33;
60-
--code-bg: #37383e;
61-
--border: #333;
62-
}
63-
64-
.list {
65-
background: var(--theme);
66-
}
67-
68-
.list:not(.dark)::-webkit-scrollbar-track {
69-
background: 0 0;
70-
}
71-
72-
.list:not(.dark)::-webkit-scrollbar-thumb {
73-
border-color: var(--theme);
74-
}
75-
}
76-
77-
</style>
78-
{{- end }}
79-
</noscript>
8041

8142
<header class="header">
8243
<nav class="nav">

0 commit comments

Comments
 (0)