Skip to content

Commit

Permalink
optimize templating (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmau111 authored Aug 18, 2021
1 parent 8b319dc commit b864715
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 48 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ If you don't set anything then the theme display the default image "https://raw.
A lot of stuff, including:

* i18n
* shortcodes
* more shortcodes
* author box

But still, it's not a multi-purpose theme.

Expand Down
2 changes: 1 addition & 1 deletion layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<!DOCTYPE html>
<!-- copied from https://dev.to/404 -->
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
Expand Down
24 changes: 21 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,44 @@
<link rel="stylesheet" href="{{ ($style | minify | fingerprint).RelPermalink }}">
{{- end }}

<!-- block additional styles in templates -->
{{ block "stylesheets" . }}{{ end }}
<!-- /block additional styles in templates -->
</head>

<body class='{{ block "body_classes" . }}{{ end }}'>

{{ partial "header.html" . }}

<main class="site-main">
{{ block "main" . }}{{ end }}
<!-- let's keep a way to override the whole structure by
redefining the whole block main -->
{{ block "main" . }}
<article>
{{- block "subheader" . }}
{{ partial "subheader.html" (dict "context" . "site" $.Site) }}
{{ end }}
<div class="content slide-invert">
{{- block "content" . }}{{ end }}
</div>
</article>
{{ end }}
</main>
{{ partial "footer.html" . }}

{{ partialCached "footer.html" . }}

{{ $prefixFree := resources.Get "js/prefixfree.js" }}

<!-- block additional scripts in templates -->
{{ block "scripts" . }}{{ end }}
<!-- block additional scripts in templates -->

{{- if .Site.IsServer }}
<script src="{{ $prefixFree.RelPermalink }}" defer="defer"></script>
{{- else }}
<script src="{{ ($prefixFree | minify | fingerprint).RelPermalink }}"></script>
{{- end }}

{{ partial "google-analytics.html" . }}
{{ partialCached "google-analytics.html" . .Site.Params.ga_id }}
</body>
</html>
21 changes: 8 additions & 13 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{{ define "body_classes" }}list{{ end }}

{{- define "main" }}
<article>
{{ partial "subheader.html" (dict "context" . "site" $.Site) }}
<div class="content slide-invert">
<ul class="listing-posts">
{{ $paginator := .Paginate (.Pages) }}
{{ range $paginator.Pages }}
{{ partial "summary" . }}
{{ end }}
</ul>
{{ template "_internal/pagination.html" . }}
</div>
</article>
{{ define "content" }}
<ul class="listing-posts">
{{ $paginator := .Paginate (.Pages) }}
{{ range $paginator.Pages }}
{{ partial "summary" . }}
{{ end }}
</ul>
{{ template "_internal/pagination.html" . }}
{{- end }}
9 changes: 2 additions & 7 deletions layouts/_default/page.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{{ define "body_classes" }}page{{ end }}

{{- define "main" }}
<article>
{{ partial "subheader.html" (dict "context" . "site" $.Site) }}
<div class="content slide-invert">
{{ .Content }}
</div>
</article>
{{- define "content" }}
{{ .Content }}
{{- end }}
9 changes: 2 additions & 7 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{{ define "body_classes" }}page{{ end }}

{{- define "main" }}
<article>
{{ partial "subheader.html" (dict "context" . "site" $.Site) }}
<div class="content slide-invert">
{{ .Content }}
</div>
</article>
{{- define "content" }}
{{ .Content }}
{{- end }}
15 changes: 7 additions & 8 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{{ define "body_classes" }}home{{ end }}

{{- define "main" }}
<article>
{{ partial "subheader.html" (dict "context" . "site" $.Site "isHome" true) }}
<div class="content slide-invert">
{{ .Content }}
{{ partial "welcome.html" . }}
</div>
</article>
{{- define "subheader" }}
{{ partial "subheader.html" (dict "context" . "site" $.Site "isHome" true) }}
{{- end }}

{{- define "content" }}
{{ .Content }}
{{ partial "welcome.html" . }}
{{- end }}
15 changes: 7 additions & 8 deletions layouts/post/single.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{{ define "body_classes" }}single{{ end }}

{{- define "main" }}
<article>
{{ $date := partial "date.html" . }}
{{ partial "subheader.html" (dict "context" . "date" $date "site" $.Site) }}
<div class="content slide-invert">
{{ .Content }}
</div>
</article>
{{- define "subheader" }}
{{ $date := partial "date.html" . }}
{{ partial "subheader.html" (dict "context" . "date" $date "site" $.Site) }}
{{- end }}

{{- define "content" }}
{{ .Content }}
{{- end }}
Empty file added layouts/section/.gitkeep
Empty file.

0 comments on commit b864715

Please sign in to comment.