diff --git a/assets/search/data.json b/assets/search/data.json index 38d358a..26f2463 100644 --- a/assets/search/data.json +++ b/assets/search/data.json @@ -4,8 +4,8 @@ { "id": {{ $index }}, "href": "{{ $page.RelPermalink }}", - "title": {{ (partial "title" $page) | jsonify }}, - "parent": {{ with $page.Parent }}{{ (partial "title" .) | jsonify }}{{ else }}""{{ end }}, + "title": {{ (partial "utils/title" $page) | jsonify }}, + "parent": {{ with $page.Parent }}{{ (partial "utils/title" .) | jsonify }}{{ else }}""{{ end }}, "content": {{ $page.Plain | jsonify }} } {{ end }} diff --git a/exampleSite/config/_default/params.yaml b/exampleSite/config/_default/params.yaml index bd0c2e4..8917d7c 100644 --- a/exampleSite/config/_default/params.yaml +++ b/exampleSite/config/_default/params.yaml @@ -1,4 +1,9 @@ --- +description: > + Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme + and may not fit the requirements of complex projects. If a more feature-complete theme is required + there are a lot of good alternatives out there. + geekdocToC: 3 geekdocTagsToMenu: true diff --git a/exampleSite/content/en/_index.md b/exampleSite/content/en/_index.md index 37c88dd..f07ec42 100644 --- a/exampleSite/content/en/_index.md +++ b/exampleSite/content/en/_index.md @@ -1,6 +1,5 @@ --- title: Welcome to the documentation -description: Geekdoc is a simple Hugo theme for documentations. It is intentionally designed as a fast and lean theme and may not fit the requirements of complex projects. If a more feature-complete theme is required there are a lot of good alternatives out there. geekdocNav: false geekdocAlign: center geekdocAnchor: false diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 8133c86..071e30f 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -3,16 +3,17 @@ {{ partial "head/meta" . }} - {{ if not (eq .Kind "home") }} - {{ partial "title" . }}{{ printf " | " }} - {{ end }}{{ .Site.Title }} + {{- if eq .Kind "home" -}} + {{ .Site.Title }} + {{- else -}} + {{ printf "%s | %s" (partial "utils/title" .) .Site.Title }} + {{- end -}} {{ partial "head/favicons" . }} {{ partial "head/rel-me" . }} {{ partial "head/microformats" . }} {{ partial "head/others" . }} - {{ partial "head/schema" . }} {{ partial "head/custom" . }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index de93c0b..9e7a5b8 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -5,7 +5,7 @@
-

{{ partial "title" . }}

- {{ partial "content" . }} +

{{ partial "utils/title" . }}

+ {{ partial "utils/content" . }}
{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index de93c0b..9e7a5b8 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -5,7 +5,7 @@
-

{{ partial "title" . }}

- {{ partial "content" . }} +

{{ partial "utils/title" . }}

+ {{ partial "utils/content" . }}
{{ end }} diff --git a/layouts/partials/content.html b/layouts/partials/content.html deleted file mode 100644 index 0aff871..0000000 --- a/layouts/partials/content.html +++ /dev/null @@ -1,4 +0,0 @@ -{{- $content := .Content -}} -{{- $content = $content | replaceRE `` `` | safeHTML -}} -{{- $content = $content | replaceRE `((?:.|\n)+?
)` `
${1}
` | safeHTML -}} -{{- $content -}} diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 6adb84e..761fe1c 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,13 +1,14 @@ + +{{ hugo.Generator }} -{{ $description := default (default .Site.Title .Site.Params.description) (default .Summary .Description) }} {{ $keywords := default .Site.Params.Keywords .Keywords }} -{{ with $description }} - -{{ end }} -{{ with $keywords }} +{{- with partial "utils/description" . }} + +{{- end }} +{{- with $keywords }} -{{ end }} +{{- end }} diff --git a/layouts/partials/head/microformats.html b/layouts/partials/head/microformats.html index 47183f7..8b6038a 100644 --- a/layouts/partials/head/microformats.html +++ b/layouts/partials/head/microformats.html @@ -1,2 +1,3 @@ -{{ template "_internal/opengraph.html" . }} -{{ template "_internal/twitter_cards.html" . }} +{{ partial "microformats/opengraph.html" . }} +{{ partial "microformats/twitter_cards.html" . }} +{{ partial "microformats/schema" . }} diff --git a/layouts/partials/head/schema.html b/layouts/partials/head/schema.html deleted file mode 100644 index f1a4d8c..0000000 --- a/layouts/partials/head/schema.html +++ /dev/null @@ -1,66 +0,0 @@ -{{ if .IsHome -}} - {{ $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }} -{{ else if .IsPage }} -{{ $description := default .Site.Params.description (default .Description .Summary) }} - -{{ end }} diff --git a/layouts/partials/menu-bundle.html b/layouts/partials/menu-bundle.html index 26895c8..a52383d 100644 --- a/layouts/partials/menu-bundle.html +++ b/layouts/partials/menu-bundle.html @@ -52,9 +52,9 @@ {{ else }} {{ relref $current .ref }} {{ end }}" - class="gdoc-nav__entry {{ if not .external }} - {{ if $isCurrent }}is-active{{ end }} - {{ end }}" + class="gdoc-nav__entry{{- if not .external }} + {{- if $isCurrent }}{{ printf " is-active" }}{{ end }} + {{- end }}" > {{ $name }} diff --git a/layouts/partials/menu-filetree.html b/layouts/partials/menu-filetree.html index 7d39071..d8616a5 100644 --- a/layouts/partials/menu-filetree.html +++ b/layouts/partials/menu-filetree.html @@ -68,13 +68,15 @@ - {{ partial "title" . }} + {{ partial "utils/title" . }} {{ else }} - {{ partial "title" . }} + {{ partial "utils/title" . }} {{ end }} {{ if $doCollapse }} diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 272916d..8de0565 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -20,10 +20,12 @@ {{ with $.Site.GetPage (printf "/tags/%s" $name) }}
  • - {{ .Title }} + {{ partial "utils/title" . }}
  • {{ end }} diff --git a/layouts/partials/microformats/opengraph.html b/layouts/partials/microformats/opengraph.html new file mode 100644 index 0000000..1065cb9 --- /dev/null +++ b/layouts/partials/microformats/opengraph.html @@ -0,0 +1,74 @@ +{{- if not (eq .Kind "home") }} + +{{- end }} +{{- with .Site.Title }} + +{{- end }} +{{- with partial "utils/description" . }} + +{{- end }} + + + +{{- with $.Params.images }} + {{- range first 6 . }}{{ end -}} +{{- else }} + {{- $featured := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" -}} + {{- with $featured }} + + {{- else }} + {{- with $.Site.Params.images }} + + {{- end }} + {{- end }} +{{- end }} + +{{- with .Params.audio }} + +{{- end }} +{{- with .Params.locale }} + +{{- end }} +{{- with .Params.videos }} + {{- range . }} + + {{- end }} +{{- end }} + +{{- /* If it is part of a series, link to related articles */}} +{{- if .Site.Taxonomies.series }} + {{- $permalink := .Permalink -}} + {{- $siteSeries := .Site.Taxonomies.series -}} + {{- with .Params.series }} + {{- range $name := . }} + {{- $series := index $siteSeries ($name | urlize) }} + {{- range $page := first 6 $series.Pages }} + {{- if ne $page.Permalink $permalink }} + + {{- end }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} + +{{ if .IsPage -}} + {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} + + {{- with .PublishDate }} + + {{- end }} + {{- with .Lastmod }} + + {{- end }} +{{- end }} + +{{- /* Facebook Page Admin ID for Domain Insights */}} +{{- with .Site.Social.facebook_admin }} + +{{- end }} diff --git a/layouts/partials/microformats/schema.html b/layouts/partials/microformats/schema.html new file mode 100644 index 0000000..c610c70 --- /dev/null +++ b/layouts/partials/microformats/schema.html @@ -0,0 +1,67 @@ +{{- if .IsHome -}} + {{- $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }} + + +{{- else if .IsPage }} + +{{- end }} diff --git a/layouts/partials/microformats/twitter_cards.html b/layouts/partials/microformats/twitter_cards.html new file mode 100644 index 0000000..55097be --- /dev/null +++ b/layouts/partials/microformats/twitter_cards.html @@ -0,0 +1,28 @@ +{{- with $.Params.images -}} + + +{{- else }} + {{- $images := $.Resources.ByType "image" -}} + {{- $featured := $images.GetMatch "*feature*" -}} + {{- if not $featured }} + {{- $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}} + {{- end }} + {{- with $featured }} + + + {{- else }} + {{- with $.Site.Params.images }} + + + {{- else }} + + {{- end }} + {{- end }} +{{- end }} + +{{- with partial "utils/description" . }} + +{{- end }} +{{- with .Site.Social.twitter -}} + +{{- end }} diff --git a/layouts/partials/page-header.html b/layouts/partials/page-header.html index bef099e..9d94525 100644 --- a/layouts/partials/page-header.html +++ b/layouts/partials/page-header.html @@ -9,7 +9,7 @@ {{ define "breadcrumb" }} {{ $parent := .page.Parent }} {{ if $parent }} - {{ $name := (partial "title" $parent) }} + {{ $name := (partial "utils/title" $parent) }} {{ $position := (sub .position 1) }} {{ $value := (printf "
  • %s
  • /
  • %s" $parent.RelPermalink $parent.RelPermalink $name $position .value) }} {{ template "breadcrumb" dict "page" $parent "value" $value "position" $position }} @@ -36,7 +36,7 @@ diff --git a/layouts/partials/utils/content.html b/layouts/partials/utils/content.html new file mode 100644 index 0000000..a888b66 --- /dev/null +++ b/layouts/partials/utils/content.html @@ -0,0 +1,6 @@ +{{ $content := .Content }} + +{{ $content = $content | replaceRE `` `` | safeHTML }} +{{ $content = $content | replaceRE `((?:.|\n)+?
    )` `
    ${1}
    ` | safeHTML }} + +{{ return $content }} diff --git a/layouts/partials/utils/description.html b/layouts/partials/utils/description.html new file mode 100644 index 0000000..a639681 --- /dev/null +++ b/layouts/partials/utils/description.html @@ -0,0 +1,13 @@ +{{ $description := "" }} + +{{ if .Description }} + {{ $description = .Description }} +{{ else }} + {{ if .IsPage }} + {{ $description = .Summary }} + {{ else if .Site.Params.description }} + {{ $description = .Site.Params.description }} + {{ end }} +{{ end }} + +{{ return $description }} diff --git a/layouts/partials/title.html b/layouts/partials/utils/title.html similarity index 100% rename from layouts/partials/title.html rename to layouts/partials/utils/title.html diff --git a/layouts/posts/list.html b/layouts/posts/list.html index 9fa37bf..757b496 100644 --- a/layouts/posts/list.html +++ b/layouts/posts/list.html @@ -2,7 +2,9 @@ {{ range .Paginator.Pages }}
    -

    {{ .Title }}

    +

    + {{ partial "utils/title" . }} +

    {{ .Summary }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 1227e62..dea2a8c 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -1,13 +1,13 @@ {{ define "main" }}
    -

    {{ .Title }}

    +

    {{ partial "utils/title" . }}

    - {{ partial "content" . }} + {{ partial "utils/content" . }}
    {{ end }} diff --git a/layouts/shortcodes/toc-tree.html b/layouts/shortcodes/toc-tree.html index cb017bb..15319b8 100644 --- a/layouts/shortcodes/toc-tree.html +++ b/layouts/shortcodes/toc-tree.html @@ -17,13 +17,15 @@ {{ if or .Content .Params.GeekdocFlatSection }} - {{ partial "title" . }}{{ with .Params.GeekdocDescription }}:{{ end }} + {{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }}:{{ end }} {{ with .Params.GeekdocDescription }}{{ . }}{{ end }} {{ else }} - {{ partial "title" . }}{{ with .Params.GeekdocDescription }}: {{ . }}{{ end }} + {{ partial "utils/title" . }}{{ with .Params.GeekdocDescription }} + : {{ . }} + {{ end }} {{ end }} diff --git a/layouts/taxonomy/list.html b/layouts/taxonomy/list.html index 9fa37bf..757b496 100644 --- a/layouts/taxonomy/list.html +++ b/layouts/taxonomy/list.html @@ -2,7 +2,9 @@ {{ range .Paginator.Pages }}