diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
commit | 59c7d4567380d1a9c80e96eb958fdbdd512ce006 (patch) | |
tree | 65410cfc10dbc7d060ec23be110662d9b7f6b0e9 /themes/hugo-theme-stack/layouts/_default |
новая жизнь блога
Diffstat (limited to 'themes/hugo-theme-stack/layouts/_default')
8 files changed, 292 insertions, 0 deletions
diff --git a/themes/hugo-theme-stack/layouts/_default/_markup/render-heading.html b/themes/hugo-theme-stack/layouts/_default/_markup/render-heading.html new file mode 100644 index 0000000..f79308a --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/_markup/render-heading.html @@ -0,0 +1,6 @@ +<h{{ .Level }} id="{{ .Anchor }}"> + {{- if site.Params.Article.HeadingAnchor -}} + <a href="#{{ .Anchor }}" class="header-anchor"></a> + {{- end -}} + {{ .Text | safeHTML }} +</h{{ .Level }}>
\ No newline at end of file diff --git a/themes/hugo-theme-stack/layouts/_default/_markup/render-image.html b/themes/hugo-theme-stack/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..0ed5584 --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/_markup/render-image.html @@ -0,0 +1,41 @@ +{{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}} +{{- $Permalink := .Destination | relURL | safeURL -}} +{{- $alt := .PlainText | safeHTML -}} +{{- $Width := 0 -}} +{{- $Height := 0 -}} +{{- $Srcset := "" -}} + +{{/* SVG and external images won't work with gallery layout, because their width and height attributes are unknown */}} +{{- $galleryImage := false -}} + +{{- if $image -}} + {{- $notSVG := ne (path.Ext .Destination) ".svg" -}} + {{- $Permalink = $image.RelPermalink -}} + + {{- if $notSVG -}} + {{- $Width = $image.Width -}} + {{- $Height = $image.Height -}} + {{- $galleryImage = true -}} + + {{- if (default true .Page.Site.Params.imageProcessing.content.enabled) -}} + {{- $small := $image.Resize `480x` -}} + {{- $big := $image.Resize `1024x` -}} + {{- $Srcset = printf `%s 480w, %s 1024w` $small.RelPermalink $big.RelPermalink -}} + {{- end -}} + {{- end -}} +{{- end -}} + +<img src="{{ $Permalink }}" + {{ with $Width }}width="{{ . }}"{{ end }} + {{ with $Height }}height="{{ . }}"{{ end }} + {{ with $Srcset }}srcset="{{ . }}"{{ end }} + loading="lazy" + {{ with $alt }} + alt="{{ . }}" + {{ end }} + {{ if $galleryImage }} + class="gallery-image" + data-flex-grow="{{ div (mul $image.Width 100) $image.Height }}" + data-flex-basis="{{ div (mul $image.Width 240) $image.Height }}px" + {{ end }} +>
\ No newline at end of file diff --git a/themes/hugo-theme-stack/layouts/_default/_markup/render-link.html b/themes/hugo-theme-stack/layouts/_default/_markup/render-link.html new file mode 100644 index 0000000..843854d --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/_markup/render-link.html @@ -0,0 +1,3 @@ +<a class="link" href="{{ .Destination | safeURL }}" {{ with .Title}} title="{{ . }}" + {{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener" + {{ end }}>{{ .Text | safeHTML }}</a>
\ No newline at end of file diff --git a/themes/hugo-theme-stack/layouts/_default/archives.html b/themes/hugo-theme-stack/layouts/_default/archives.html new file mode 100644 index 0000000..5d5243c --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/archives.html @@ -0,0 +1,35 @@ +{{ define "body-class" }}template-archives{{ end }} +{{ define "main" }} + <header> + {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}} + {{- $terms := $taxonomy.Pages -}} + {{ if $terms }} + <h2 class="section-title">{{ $taxonomy.Title }}</h2> + <div class="subsection-list"> + <div class="article-list--tile"> + {{ range $terms }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }} + {{ end }} + </div> + </div> + {{ end }} + </header> + + {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + + {{ range $filtered.GroupByDate "2006" }} + {{ $id := lower (replace .Key " " "-") }} + <div class="archives-group" id="{{ $id }}"> + <h2 class="archives-date section-title"><a href="{{ $.RelPermalink }}#{{ $id }}">{{ .Key }}</a></h2> + <div class="article-list--compact"> + {{ range .Pages }} + {{ partial "article-list/compact" . }} + {{ end }} + </div> + </div> + {{ end }} + + {{ partialCached "footer/footer" . }} +{{ end }} diff --git a/themes/hugo-theme-stack/layouts/_default/baseof.html b/themes/hugo-theme-stack/layouts/_default/baseof.html new file mode 100644 index 0000000..83fdaa3 --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/baseof.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html lang="{{ .Site.LanguageCode }}" dir="{{ default `ltr` .Language.LanguageDirection }}"> + <head> + {{- partial "head/head.html" . -}} + {{- block "head" . -}}{{ end }} + </head> + <body class="{{ block `body-class` . }}{{ end }}"> + {{- partial "head/colorScheme" . -}} + + {{/* The container is wider when there's any activated widget */}} + {{- $hasWidget := false -}} + {{- range .Site.Params.widgets -}} + {{- if gt (len .) 0 -}} + {{- $hasWidget = true -}} + {{- end -}} + {{- end -}} + <div class="container main-container flex on-phone--column {{ if $hasWidget }}extended{{ else }}compact{{ end }}"> + {{- block "left-sidebar" . -}} + {{ partial "sidebar/left.html" . }} + {{- end -}} + {{- block "right-sidebar" . -}}{{ end }} + <main class="main full-width"> + {{- block "main" . }}{{- end }} + </main> + </div> + {{ partial "footer/include.html" . }} + </body> +</html> diff --git a/themes/hugo-theme-stack/layouts/_default/list.html b/themes/hugo-theme-stack/layouts/_default/list.html new file mode 100644 index 0000000..9bc618d --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/list.html @@ -0,0 +1,85 @@ +{{ define "main" }} + <header> + <h3 class="section-title"> + {{ if eq .Parent (.GetPage "/") }} + {{ T "list.section" }} + {{ else }} + {{ .Parent.Title }} + {{ end }} + </h3> + + <div class="section-card"> + <div class="section-details"> + <h3 class="section-count">{{ T "list.page" (len .Pages) }}</h3> + <h1 class="section-term">{{ .Title }}</h1> + {{ with .Params.description }} + <h2 class="section-description">{{ . }}</h2> + {{ end }} + </div> + + {{- $image := partialCached "helper/image" (dict "Context" . "Type" "section") .RelPermalink "section" -}} + {{ if $image.exists }} + <div class="section-image"> + {{ if $image.resource }} + {{- $Permalink := $image.resource.RelPermalink -}} + {{- $Width := $image.resource.Width -}} + {{- $Height := $image.resource.Height -}} + + {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} + {{- $thumbnail := $image.resource.Fill "120x120" -}} + {{- $Permalink = $thumbnail.RelPermalink -}} + {{- $Width = $thumbnail.Width -}} + {{- $Height = $thumbnail.Height -}} + {{- end -}} + + <img src="{{ $Permalink }}" + width="{{ $Width }}" + height="{{ $Height }}" + loading="lazy"> + {{ else }} + <img src="{{ $image.permalink }}" loading="lazy" /> + {{ end }} + </div> + {{ end }} + </div> + </header> + + {{- $subsections := .Sections -}} + {{- $pages := .Pages | complement $subsections -}} + + {{- if eq (len $pages) 0 -}} + {{/* If there are no normal pages, display subsections in list style, with pagination */}} + {{/* This happens with taxonomies like categories or tags */}} + {{- $pages = $subsections -}} + {{- $subsections = slice -}} + {{- end -}} + + {{- with $subsections -}} + <aside> + <h2 class="section-title">{{ T "list.subsection" (len $subsections) }}</h2> + <div class="subsection-list"> + <div class="article-list--tile"> + {{ range . }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "section") }} + {{ end }} + </div> + </div> + </aside> + {{- end -}} + + {{/* List only pages that are not a subsection */}} + {{ $paginator := .Paginate $pages }} + <section class="article-list--compact"> + {{ range $paginator.Pages }} + {{ partial "article-list/compact" . }} + {{ end }} + </section> + + {{- partial "pagination.html" . -}} + + {{ partialCached "footer/footer" . }} +{{ end }} + +{{ define "right-sidebar" }} + {{ partial "sidebar/right.html" (dict "Context" . "Scope" "homepage") }} +{{ end }}
\ No newline at end of file diff --git a/themes/hugo-theme-stack/layouts/_default/rss.xml b/themes/hugo-theme-stack/layouts/_default/rss.xml new file mode 100644 index 0000000..3d2e592 --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/rss.xml @@ -0,0 +1,48 @@ +{{- $pctx := . -}} +{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- $pages := slice -}} +{{- if or $.IsHome $.IsSection -}} +{{- $pages = $pctx.RegularPages -}} +{{- else -}} +{{- $pages = $pctx.Pages -}} +{{- end -}} +{{- $pages := where $pages "Params.hidden" "!=" true -}} +{{- $limit := .Site.Config.Services.RSS.Limit -}} +{{- if ge $limit 1 -}} +{{- $pages = $pages | first $limit -}} +{{- end -}} +{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> + <link>{{ .Permalink }}</link> + <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description> + <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} + <language>{{.}}</language>{{end}}{{ with .Site.Params.Author.email }} + <managingEditor>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Params.Author.email }} + <webMaster>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} + <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} + <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} + {{- with .OutputFormats.Get "RSS" -}} + {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} + {{- end -}} + {{ range $pages }} + {{- $content := safeHTML (.Summary | html) -}} + {{- if .Site.Params.rssFullContent -}} + {{- $content = safeHTML (.Content | html) -}} + {{- end -}} + <item> + <title>{{ .Title }}</title> + <link>{{ .Permalink }}</link> + <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + {{ with .Site.Params.Author.email }}<author>{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}</author>{{end}} + <guid>{{ .Permalink }}</guid> + <description> + {{- $image := partial "helper/image" (dict "Context" . "Type" "rss") -}} + {{- if $image.exists -}} + {{ "<" | html }}img src="{{ $image.permalink | absURL }}" alt="Featured image of post {{ .Title }}" {{ "/>" | html}} + {{- end -}}{{ $content }}</description> + </item> + {{ end }} + </channel> +</rss> diff --git a/themes/hugo-theme-stack/layouts/_default/single.html b/themes/hugo-theme-stack/layouts/_default/single.html new file mode 100644 index 0000000..5f300bf --- /dev/null +++ b/themes/hugo-theme-stack/layouts/_default/single.html @@ -0,0 +1,46 @@ +{{ define "body-class" }} + article-page + {{/* + Enable the right sidebar if + - Widget different from 'TOC' is enabled + - TOC is enabled and not empty + */}} + {{- $HasWidgetNotTOC := false -}} + {{- $TOCWidgetEnabled := false -}} + {{- range .Site.Params.widgets.page -}} + {{- if ne .type "toc" -}} + {{ $HasWidgetNotTOC = true -}} + {{- else -}} + {{ $TOCWidgetEnabled = true -}} + {{- end -}} + {{- end -}} + + {{- $TOCManuallyDisabled := eq .Params.toc false -}} + {{- $TOCEnabled := and (not $TOCManuallyDisabled) $TOCWidgetEnabled -}} + {{- $hasTOC := ge (len .TableOfContents) 100 -}} + {{- .Scratch.Set "TOCEnabled" (and $TOCEnabled $hasTOC) -}} + + {{- .Scratch.Set "hasWidget" (or $HasWidgetNotTOC (and $TOCEnabled $hasTOC)) -}} +{{ end }} + +{{ define "main" }} + {{ partial "article/article.html" . }} + + {{ if .Params.links }} + {{ partial "article/components/links" . }} + {{ end }} + + {{ partial "article/components/related-content" . }} + + {{ if not (eq .Params.comments false) }} + {{ partial "comments/include" . }} + {{ end }} + + {{ partialCached "footer/footer" . }} + + {{ partialCached "article/components/photoswipe" . }} +{{ end }} + +{{ define "right-sidebar" }} + {{ if .Scratch.Get "hasWidget" }}{{ partial "sidebar/right.html" (dict "Context" . "Scope" "page") }}{{ end}} +{{ end }} |