Skip to content

Commit c32d53a

Browse files
committed
MF: Use css for data-mf instead of js
1 parent cf868d4 commit c32d53a

File tree

7 files changed

+58
-78
lines changed

7 files changed

+58
-78
lines changed

assets/css/docs-nginx-com/style.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
/*copy from nginx-theme.css */
22

3+
[data-mf="false"] {
4+
display: block !important;
5+
}
6+
7+
[data-mf="true"] {
8+
display: none !important;
9+
}
10+
311
big,
412
html,
513
small {
@@ -2248,4 +2256,3 @@ text-decoration: none;
22482256
}
22492257

22502258
/*======END GDPR2==================*/
2251-

assets/css/v2/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
[data-mf="true"] {
2+
display: block !important;
3+
}
4+
5+
[data-mf="false"] {
6+
display: none !important;
7+
}
8+
19
/* Regular */
210
@font-face {
311
font-family: "JetBrainsMono";

layouts/_default/baseof.html

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="{{ .Site.LanguageCode }}">
33

4-
<head>
4+
<head>
55
<style>
66
body {
77
/* Hide entire body for first paint. This suppresses flicker when theme is loading. */
@@ -11,7 +11,7 @@
1111
flex-direction: column;
1212
}
1313
</style>
14-
14+
1515
<noscript>
1616
<style>
1717
/* Styles when JavaScript is disabled. Fallsback to old theme. */
@@ -20,7 +20,7 @@
2020
}
2121
</style>
2222
</noscript>
23-
23+
2424

2525

2626
<script>
@@ -56,44 +56,11 @@
5656
}
5757
});
5858

59-
// swap out v1 and v2 elements
60-
const v1ElementIds = ["sidebar", "footer", "toc", "api", "search-v1", "breadcrumb-v1", "list-v1"]
61-
62-
v1ElementIds.forEach((elementId) => {
63-
const element = document.getElementById(elementId);
64-
if (element !== null) {
65-
element.style.display = isNewTheme ? "none" : "";
66-
}
67-
68-
const trustarc = document.getElementById("teconsent-v1");
69-
if (trustarc) {
70-
trustarc.id = isNewTheme ? "teconsent-v1" : "teconsent";
71-
}
72-
});
7359

7460
document.querySelectorAll(".table-v1").forEach((table) => {
7561
table.style.display = isNewTheme ? "none" : "";
7662
});
7763

78-
const notMfElements = ['[data-mf="false"]'];
79-
notMfElements.forEach((elementId) => {
80-
document.querySelectorAll(elementId).forEach((element) => {
81-
element.style.display = isNewTheme ? "none" : "";
82-
});
83-
})
84-
85-
const mfElements = ['[data-mf="true"]'];
86-
mfElements.forEach((elementId) => {
87-
document.querySelectorAll(elementId).forEach((element) => {
88-
element.style.display = isNewTheme ? "" : "none";
89-
90-
const trustarc = document.getElementById("teconsent-v2");
91-
if (trustarc) {
92-
trustarc.id = isNewTheme ? "teconsent" : "teconsent-v2";
93-
}
94-
});
95-
});
96-
9764
document.getElementById("body").style.visibility = "visible";
9865
};
9966

@@ -131,61 +98,61 @@
13198
{{ block "head" . }}
13299

133100
{{ partial "meta.html" . }}
134-
101+
135102
{{ partial "favicon.html" . }}
136-
103+
137104
{{ partial "styles.html" . }}
138-
105+
139106
{{ if in .Params.doctypes "devportal" }}
140107
{{ partial "devportal/style.html" . }}
141108
{{ end }}
142-
109+
143110
{{ if fileExists "/layouts/partials/head_custom.html" }}
144111
{{ partial "head_custom.html" . }}
145112
{{ end }}
146-
113+
147114
{{ if or ( not hugo.IsServer ) ( not ( in .Site.Params.buildtype "package" ) ) }}
148-
115+
149116
{{ partial "trustarc.html" . }}
150-
117+
151118
{{ partial "tealium-profile.html" . }}
152-
119+
153120
{{ end }}
154-
121+
155122
{{ end }}
156-
123+
157124
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
158125
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
159126
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
160127
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
161128
})(window,document,'script','dataLayer','GTM-K5HG9JT');</script>
162-
129+
163130
</head>
164-
131+
165132
<body id="body">
166133
{{ if or ( not hugo.IsServer ) ( not ( in .Site.Params.buildtype "package" ) ) }}
167134
{{ partial "universal-tag.html" . }}
168135
{{ end }}
169-
136+
170137
<header>
171138
{{ block "header" . }}{{end}}
172139
</header>
173-
140+
174141
<section class="base-layout" data-testid="base-layout">
175-
<section id="breadcrumb-v1">
142+
<section id="breadcrumb-v1" data-mf="false">
176143
{{ if not .IsHome }}
177144
{{ if not (in .Params.display_breadcrumb "false" ) }}
178-
{{ partial "breadcrumb" .}}
145+
{{ partial "breadcrumb" .}}
179146
{{ end }}
180147
{{ end }}
181148
</section>
182-
149+
183150
<div class="main container-fluid min-page-height" data-menu-id="{{.RelPermalink}}">
184151
{{ block "main" . }}{{ end }}
185152
</div>
186153
</section>
187154

188-
<footer id="footer">
155+
<footer id="footer" data-mf="false">
189156
{{ block "footer" . }}
190157
{{ partial "footer.html" . }}
191158
{{ end }}
@@ -196,7 +163,7 @@
196163
{{ partial "footer-v2.html" . }}
197164
{{ end }}
198165
</footer>
199-
{{ partial "scripts.html" . }}
166+
{{ partial "scripts.html" . }}
200167
<div id="consent_blackbar"></div>
201168
</body>
202169
</html>

layouts/_default/docs.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ define "main" }}
22
<div class="docs-container row override-sidebar-collapse">
33
<div class="docs-container row override-sidebar-collapse">
4-
<nav id="sidebar" class="sidenav overflow-auto col-md-3 d-none d-xl-block d-print-none align-top">
4+
<nav id="sidebar" data-mf="false" class="sidenav overflow-auto col-md-3 d-none d-xl-block d-print-none align-top">
55
{{ partial "sidebar.html" . }}
66
</nav>
77

@@ -19,12 +19,12 @@
1919
{{$iconName = index (index $submatches 0) 1}}
2020
{{$styleAttr = index (index $submatches 0) 2}}
2121

22-
{{- $iconMappings := dict
23-
"bug-slash" "bug-off"
24-
"circle-info" "info"
22+
{{- $iconMappings := dict
23+
"bug-slash" "bug-off"
24+
"circle-info" "info"
2525
"info-circle" "info"
2626
"file-circle-plus" "file-plus"
27-
"check-circle" "circle-check"
27+
"check-circle" "circle-check"
2828
"heartbeat" "heart-pulse"
2929
"code-branch" "git-branch"
3030
"desktop" "monitor"
@@ -46,8 +46,8 @@
4646
{{$iconName = .}}
4747
{{ end }}
4848

49-
{{$iconHTML := partial "lucide" (dict
50-
"context" $
49+
{{$iconHTML := partial "lucide" (dict
50+
"context" $
5151
"icon" $iconName
5252
"style" $styleAttr
5353
)}}
@@ -58,15 +58,15 @@
5858

5959
{{end}}
6060
{{end}}
61-
61+
6262
{{if (.Params.catalog) }}
6363
<main class="content content-has-toc" role="main">
6464
{{ else if and (gt .WordCount 200 ) (.Params.toc) }}
6565
<main class="content col d-block align-top content-has-toc" role="main">
6666
{{ else }}
6767
<main class="content col d-block align-top content-no-toc" role="main">
6868
{{ end }}
69-
69+
7070
<section class="main-layout">
7171
<div class="sidebar-layout" id="sidebar-layout">
7272
<nav data-mf="true" id="sidebar-v2" class="sidebar" style="display:none;">
@@ -79,7 +79,7 @@
7979
<section class="breadcrumb-layout" data-mf="true" style="display: none;">
8080
{{ if not .IsHome }}
8181
{{ if not (in .Params.display_breadcrumb "false" ) }}
82-
{{ partial "breadcrumb" .}}
82+
{{ partial "breadcrumb" .}}
8383
{{ end }}
8484
{{ end }}
8585
</section>
@@ -89,7 +89,7 @@ <h1>{{ .Title }}</h1>
8989
{{ if in .Params.doctypes "beta" }}{{ partial "beta-badge" . }}{{ end }}
9090

9191
<hr>
92-
92+
9393
{{ if .Page.Lastmod }}
9494
<div class="last-modified">
9595
{{ partial "page-meta-links" . }}
@@ -103,12 +103,12 @@ <h1>{{ .Title }}</h1>
103103
</main>
104104
{{ if and (gt .WordCount 200 ) (.Params.toc) }}
105105
{{ if (add (len (findRE "<h3" .Content)) (len (findRE "<h2" .Content))) }}
106-
<div id="toc" class="col-md-3 d-none d-xl-block d-print-none nginx-toc align-top">
106+
<div id="toc" data-mf="false" class="col-md-3 d-none d-xl-block d-print-none nginx-toc align-top">
107107
{{ partial "toc.html" . }}
108108
</div>
109109
{{ end }}
110110
{{ end }}
111-
111+
112112
</div>
113113
</section>
114114
</section>

layouts/_default/list.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{{ define "main" }}
2-
<div class="row flex-xl-nowrap" id="list-v1">
2+
<div class="row flex-xl-nowrap" id="list-v1" data-mf="false">
33
<nav class="sidenav overflow-auto col-md-3 d-none d-xl-block d-print-none">
44
{{ partial "sidebar.html" . }}
55
</nav>
66
<main class="content col-xl-9 d-block" role="main">
7-
{{ partial "list-main" . }}
7+
{{ partial "list-main" . }}
88
</main>
99
</div>
1010

@@ -56,4 +56,3 @@ <h2>
5656
</section>
5757
</main>
5858
{{ end }}
59-

layouts/partials/api.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!--Use wide page layout for the API reference pages-->
2-
<div class="nginx-docs-api-container">
3-
<div id="api-component" class="content">
2+
<div class="nginx-docs-api-container">
3+
<div id="api-component" data-mf="false" class="content">
44
{{ .Content}}
55
</div>
66
</div>
7-

layouts/search/single.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{ define "main" }}
22

3-
<div class="row flex-xl-nowrap" id="search-v1">
3+
<div class="row flex-xl-nowrap" id="search-v1" data-mf="false">
44
<main class="col-md-10 content" role="main">
55
<div class="container"><h1>{{ .Title}}</h1></div>
66

@@ -145,7 +145,7 @@
145145
<atomic-result-section-title-metadata>
146146
<atomic-result-printable-uri></atomic-result-printable-uri>
147147
</atomic-result-section-title-metadata>
148-
148+
149149
<!-- Excerpt -->
150150
<atomic-result-section-excerpt>
151151
<atomic-result-text field="excerpt"></atomic-result-text>
@@ -157,7 +157,7 @@
157157
</atomic-result-section-bottom-metadata>
158158
</template>
159159
</atomic-result-template>
160-
</atomic-result-list>
160+
</atomic-result-list>
161161
</atomic-layout-section>
162162

163163
<!-- Pagination -->

0 commit comments

Comments
 (0)