Skip to content

Commit 4a8dfe8

Browse files
committed
refactor: Remove some blocks in default layout
Remove blocks: "head", "styles", "container" and "scripts" as they are better implemented by partials and keep the layouts consistent across theme components default, CV and slides. Move scripts block into "scripts/base.html" partial.
1 parent e846b3b commit 4a8dfe8

File tree

4 files changed

+58
-68
lines changed

4 files changed

+58
-68
lines changed

layouts/_default/baseof.html

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,55 @@
11
<!DOCTYPE html>
22
<html lang="{{- site.Language -}}">
33
<head>
4-
{{- block "head" . -}}
5-
{{- partial "head/base.html" . -}}
6-
{{- block "styles" . -}}
7-
{{- partial "head/style.html" . -}}
8-
{{- end -}}
9-
{{- end -}}
10-
4+
{{- partial "head/base.html" . -}}
5+
{{- partial "head/style.html" . -}}
116
{{- if templates.Exists "partials/extend_head.html" -}}
127
{{- partial "extend_head.html" . -}}
138
{{- end -}}
149
</head>
1510

1611
<body>
17-
{{- block "container" . -}}
18-
{{- $container := "container" -}}
19-
{{- if site.Params.fullWidthTheme -}}
20-
{{- $container = print $container " full" -}}
21-
{{- else if site.Params.centerTheme -}}
22-
{{- $container = print $container " center" -}}
23-
{{- end -}}
24-
25-
26-
<div class="theme-container">
27-
{{- /* container */}}
28-
<div class="{{- $container -}}">
29-
{{- /* site header */}}
30-
<header class="site-header">
31-
{{- block "header" . -}}
32-
{{- partial "header.html" . -}}
33-
{{- end -}}
34-
</header>
35-
36-
{{- /* site main */}}
37-
<main class="site-main">
38-
{{- block "main" . -}}
39-
{{ if .Title -}}
40-
<h1 class="post-title">{{ .Title | plainify }}</h1>
41-
{{- end -}}
12+
{{- $container := "container" -}}
13+
{{- if site.Params.fullWidthTheme -}}
14+
{{- $container = print $container " full" -}}
15+
{{- else if site.Params.centerTheme -}}
16+
{{- $container = print $container " center" -}}
17+
{{- end -}}
4218

43-
{{- /* site main content */}}
44-
{{ .Content }}
19+
{{- /* theme container */}}
20+
<div class="theme-container">
21+
{{- /* container */}}
22+
<div class="{{- $container -}}">
23+
{{- /* site header */}}
24+
<header class="site-header">
25+
{{- block "header" . -}}
26+
{{- partial "header.html" . -}}
27+
{{- end -}}
28+
</header>
29+
30+
{{- /* site main */}}
31+
<main class="site-main">
32+
{{- block "main" . -}}
33+
{{ if .Title -}}
34+
<h1 class="post-title">{{ .Title | plainify }}</h1>
4535
{{- end -}}
46-
{{- /* end main content */}}
47-
</main>
4836

49-
{{- /* site footer */}}
50-
<footer class="site-footer">
51-
{{- block "footer" . -}}
52-
{{- partial "footer.html" . -}}
53-
{{- end -}}
54-
</footer>
55-
</div>
37+
{{- /* site main content */}}
38+
{{ .Content }}
39+
{{- end -}}
40+
{{- /* end main content */}}
41+
</main>
42+
43+
{{- /* site footer */}}
44+
<footer class="site-footer">
45+
{{- block "footer" . -}}
46+
{{- partial "footer.html" . -}}
47+
{{- end -}}
48+
</footer>
5649
</div>
57-
{{- end -}}
58-
59-
{{- block "scripts" . -}}
60-
{{- $copy := resources.Get "scripts/copy.js" | js.Build -}}
61-
{{- $menu := resources.Get "scripts/menu.js" | js.Build -}}
62-
{{- $print := resources.Get "scripts/print.js" | js.Build -}}
63-
{{- $theme := resources.Get "scripts/theme.js" | js.Build -}}
64-
{{- $bundle := slice $menu $theme $copy $print | resources.Concat "bundle.js" -}}
65-
{{- if hugo.IsProduction -}}
66-
{{- $bundle = $bundle | resources.Minify -}}
67-
{{- end -}}
68-
<script type="text/javascript" src="{{ $bundle.RelPermalink }}"></script>
69-
{{- end -}}
50+
</div>
7051

52+
{{- partial "scripts/base.html" . -}}
7153
{{- if templates.Exists "partials/extend_footer.html" -}}
7254
{{- partial "extend_footer.html" . -}}
7355
{{- end -}}

layouts/partials/head/style.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
{{- if and (not .IsSection) (eq .Type "slides") -}}
2+
{{- partial "slides/style.html" . -}}
3+
{{- end }}
4+
15
{{- /* styles */}}
26
{{- if hugo.IsProduction -}}
37
{{- $options := (dict "targetPath" "styles.css" "outputStyle" "compressed") -}}

layouts/partials/scripts/base.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- $copy := resources.Get "scripts/copy.js" | js.Build -}}
2+
{{- $menu := resources.Get "scripts/menu.js" | js.Build -}}
3+
{{- $print := resources.Get "scripts/print.js" | js.Build -}}
4+
{{- $theme := resources.Get "scripts/theme.js" | js.Build -}}
5+
{{- $bundle := slice $menu $theme $copy $print | resources.Concat "bundle.js" -}}
6+
7+
{{- if hugo.IsProduction -}}
8+
{{- $bundle = $bundle | resources.Minify -}}
9+
{{- end -}}
10+
<script type="text/javascript" src="{{ $bundle.RelPermalink }}"></script>
11+
12+
{{- if and (not .IsSection) (eq .Type "slides") -}}
13+
{{- partial "slides/scripts.html" . -}}
14+
{{- end }}

layouts/slides/single.html

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{{ define "styles" }}
2-
{{- partial "slides/style.html" . -}}
3-
{{ end }}
4-
5-
{{ define "container" }}
1+
{{- define "main" -}}
62
<!-- Hide header & footer until slides are ready -->
73
<div style="display: none;">
84
<div id="slide-header-footer">
@@ -41,9 +37,7 @@ <h1>{{- .Title -}}</h1>
4137

4238
<!-- Content slides -->
4339
<section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$">
44-
{{ block "main" . }}
4540
{{- .RawContent -}}
46-
{{ end }}
4741
</section>
4842

4943
<!-- End slide -->
@@ -52,8 +46,4 @@ <h2>Thank you</h2>
5246
</section>
5347
</div>
5448
</div>
55-
{{ end }}
56-
57-
{{ define "scripts" }}
58-
{{ partial "slides/scripts.html" . }}
59-
{{ end }}
49+
{{- end -}}

0 commit comments

Comments
 (0)