summaryrefslogtreecommitdiffstats
path: root/create/skeletons/theme/layouts
diff options
context:
space:
mode:
authorJoe Mooring <joe.mooring@veriphor.com>2023-08-16 15:07:01 -0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-21 10:38:22 +0200
commitb6538532f45bf833226da7277994c1a96d26a56c (patch)
tree554e35423b4cee3ca6f1d526097bbc8677acb7b2 /create/skeletons/theme/layouts
parent90944aa261acf596af774dcea0db1fc31dccc973 (diff)
commands/new: Embed site and theme skeletons
The skeletons are used when creating new sites and themes with the CLI. Closes #11358
Diffstat (limited to 'create/skeletons/theme/layouts')
-rw-r--r--create/skeletons/theme/layouts/_default/baseof.html17
-rw-r--r--create/skeletons/theme/layouts/_default/home.html7
-rw-r--r--create/skeletons/theme/layouts/_default/list.html8
-rw-r--r--create/skeletons/theme/layouts/_default/single.html10
-rw-r--r--create/skeletons/theme/layouts/partials/footer.html1
-rw-r--r--create/skeletons/theme/layouts/partials/head.html5
-rw-r--r--create/skeletons/theme/layouts/partials/head/css.html9
-rw-r--r--create/skeletons/theme/layouts/partials/head/js.html12
-rw-r--r--create/skeletons/theme/layouts/partials/header.html2
-rw-r--r--create/skeletons/theme/layouts/partials/menu.html45
-rw-r--r--create/skeletons/theme/layouts/partials/terms.html23
11 files changed, 139 insertions, 0 deletions
diff --git a/create/skeletons/theme/layouts/_default/baseof.html b/create/skeletons/theme/layouts/_default/baseof.html
new file mode 100644
index 000000000..ce9613a2b
--- /dev/null
+++ b/create/skeletons/theme/layouts/_default/baseof.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="{{ or site.Language.LanguageCode site.Language.Lang }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
+<head>
+ {{ partial "head.html" . }}
+</head>
+<body>
+ <header>
+ {{ partial "header.html" . }}
+ </header>
+ <main>
+ {{ block "main" . }}{{ end }}
+ </main>
+ <footer>
+ {{ partial "footer.html" . }}
+ </footer>
+</body>
+</html>
diff --git a/create/skeletons/theme/layouts/_default/home.html b/create/skeletons/theme/layouts/_default/home.html
new file mode 100644
index 000000000..0df659742
--- /dev/null
+++ b/create/skeletons/theme/layouts/_default/home.html
@@ -0,0 +1,7 @@
+{{ define "main" }}
+ {{ .Content }}
+ {{ range site.RegularPages }}
+ <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+ {{ .Summary }}
+ {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/_default/list.html b/create/skeletons/theme/layouts/_default/list.html
new file mode 100644
index 000000000..50fc92d40
--- /dev/null
+++ b/create/skeletons/theme/layouts/_default/list.html
@@ -0,0 +1,8 @@
+{{ define "main" }}
+ <h1>{{ .Title }}</h1>
+ {{ .Content }}
+ {{ range .Pages }}
+ <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
+ {{ .Summary }}
+ {{ end }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/_default/single.html b/create/skeletons/theme/layouts/_default/single.html
new file mode 100644
index 000000000..7e286c802
--- /dev/null
+++ b/create/skeletons/theme/layouts/_default/single.html
@@ -0,0 +1,10 @@
+{{ define "main" }}
+ <h1>{{ .Title }}</h1>
+
+ {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
+ {{ $dateHuman := .Date | time.Format ":date_long" }}
+ <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
+
+ {{ .Content }}
+ {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+{{ end }}
diff --git a/create/skeletons/theme/layouts/partials/footer.html b/create/skeletons/theme/layouts/partials/footer.html
new file mode 100644
index 000000000..a7cd916d0
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/footer.html
@@ -0,0 +1 @@
+<p>Copyright {{ now.Year }}. All rights reserved.</p>
diff --git a/create/skeletons/theme/layouts/partials/head.html b/create/skeletons/theme/layouts/partials/head.html
new file mode 100644
index 000000000..c15b7b499
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/head.html
@@ -0,0 +1,5 @@
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0">
+<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
+{{ partialCached "head/css.html" . }}
+{{ partialCached "head/js.html" . }}
diff --git a/create/skeletons/theme/layouts/partials/head/css.html b/create/skeletons/theme/layouts/partials/head/css.html
new file mode 100644
index 000000000..91b928ded
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/head/css.html
@@ -0,0 +1,9 @@
+{{- with resources.Get "css/main.css" }}
+ {{- if eq hugo.Environment "development" }}
+ <link rel="stylesheet" href="{{ .RelPermalink }}">
+ {{- else }}
+ {{- with . | minify | fingerprint }}
+ <link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/head/js.html b/create/skeletons/theme/layouts/partials/head/js.html
new file mode 100644
index 000000000..18fe84291
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/head/js.html
@@ -0,0 +1,12 @@
+{{- with resources.Get "js/main.js" }}
+ {{- if eq hugo.Environment "development" }}
+ {{- with . | js.Build }}
+ <script src="{{ .RelPermalink }}"></script>
+ {{- end }}
+ {{- else }}
+ {{- $opts := dict "minify" true }}
+ {{- with . | js.Build $opts | fingerprint }}
+ <script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/header.html b/create/skeletons/theme/layouts/partials/header.html
new file mode 100644
index 000000000..7980a00e1
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/header.html
@@ -0,0 +1,2 @@
+<h1>{{ site.Title }}</h1>
+{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
diff --git a/create/skeletons/theme/layouts/partials/menu.html b/create/skeletons/theme/layouts/partials/menu.html
new file mode 100644
index 000000000..8f72130d0
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/menu.html
@@ -0,0 +1,45 @@
+{{- /*
+Renders a menu for the given menu ID.
+
+@context {page} page The current page.
+@context {string} menuID The menu ID.
+
+@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
+*/}}
+
+{{- $page := .page }}
+{{- $menuID := .menuID }}
+
+{{- with index site.Menus $menuID }}
+ <nav>
+ <ul>
+ {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+ </ul>
+ </nav>
+{{- end }}
+
+{{- define "partials/inline/menu/walk.html" }}
+ {{- $page := .page }}
+ {{- range .menuEntries }}
+ {{- $attrs := dict "href" .URL }}
+ {{- if $page.IsMenuCurrent .Menu . }}
+ {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
+ {{- else if $page.HasMenuCurrent .Menu .}}
+ {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
+ {{- end }}
+ <li>
+ <a
+ {{- range $k, $v := $attrs }}
+ {{- with $v }}
+ {{- printf " %s=%q" $k $v | safeHTMLAttr }}
+ {{- end }}
+ {{- end -}}
+ >{{ or (T .Identifier) .Name | safeHTML }}</a>
+ {{- with .Children }}
+ <ul>
+ {{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
+ </ul>
+ {{- end }}
+ </li>
+ {{- end }}
+{{- end }}
diff --git a/create/skeletons/theme/layouts/partials/terms.html b/create/skeletons/theme/layouts/partials/terms.html
new file mode 100644
index 000000000..47cf6e41c
--- /dev/null
+++ b/create/skeletons/theme/layouts/partials/terms.html
@@ -0,0 +1,23 @@
+{{- /*
+For a given taxonomy, renders a list of terms assigned to the page.
+
+@context {page} page The current page.
+@context {string} taxonomy The taxonony.
+
+@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
+*/}}
+
+{{- $page := .page }}
+{{- $taxonomy := .taxonomy }}
+
+{{- with $page.GetTerms $taxonomy }}
+ {{- $label := (index . 0).Parent.LinkTitle }}
+ <div>
+ <div>{{ $label }}:</div>
+ <ul>
+ {{- range . }}
+ <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
+ {{- end }}
+ </ul>
+ </div>
+{{- end }}