From 59c7d4567380d1a9c80e96eb958fdbdd512ce006 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sun, 3 Nov 2024 20:08:36 +0300 Subject: новая жизнь блога MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layouts/_default/_markup/render-heading.html | 6 ++ .../layouts/_default/_markup/render-image.html | 41 +++++++++++ .../layouts/_default/_markup/render-link.html | 3 + .../layouts/_default/archives.html | 35 +++++++++ .../hugo-theme-stack/layouts/_default/baseof.html | 28 +++++++ themes/hugo-theme-stack/layouts/_default/list.html | 85 ++++++++++++++++++++++ themes/hugo-theme-stack/layouts/_default/rss.xml | 48 ++++++++++++ .../hugo-theme-stack/layouts/_default/single.html | 46 ++++++++++++ 8 files changed, 292 insertions(+) create mode 100644 themes/hugo-theme-stack/layouts/_default/_markup/render-heading.html create mode 100644 themes/hugo-theme-stack/layouts/_default/_markup/render-image.html create mode 100644 themes/hugo-theme-stack/layouts/_default/_markup/render-link.html create mode 100644 themes/hugo-theme-stack/layouts/_default/archives.html create mode 100644 themes/hugo-theme-stack/layouts/_default/baseof.html create mode 100644 themes/hugo-theme-stack/layouts/_default/list.html create mode 100644 themes/hugo-theme-stack/layouts/_default/rss.xml create mode 100644 themes/hugo-theme-stack/layouts/_default/single.html (limited to 'themes/hugo-theme-stack/layouts/_default') 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 @@ + + {{- if site.Params.Article.HeadingAnchor -}} + + {{- end -}} + {{ .Text | safeHTML }} + \ 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 -}} + +{{ . }} \ 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 @@ +{{ .Text | safeHTML }} \ 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" }} +
+ {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}} + {{- $terms := $taxonomy.Pages -}} + {{ if $terms }} +

{{ $taxonomy.Title }}

+
+
+ {{ range $terms }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }} + {{ end }} +
+
+ {{ end }} +
+ + {{ $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 " " "-") }} +
+

{{ .Key }}

+
+ {{ range .Pages }} + {{ partial "article-list/compact" . }} + {{ end }} +
+
+ {{ 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 @@ + + + + {{- partial "head/head.html" . -}} + {{- block "head" . -}}{{ 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 -}} +
+ {{- block "left-sidebar" . -}} + {{ partial "sidebar/left.html" . }} + {{- end -}} + {{- block "right-sidebar" . -}}{{ end }} +
+ {{- block "main" . }}{{- end }} +
+
+ {{ partial "footer/include.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" }} +
+

+ {{ if eq .Parent (.GetPage "/") }} + {{ T "list.section" }} + {{ else }} + {{ .Parent.Title }} + {{ end }} +

+ +
+
+

{{ T "list.page" (len .Pages) }}

+

{{ .Title }}

+ {{ with .Params.description }} +

{{ . }}

+ {{ end }} +
+ + {{- $image := partialCached "helper/image" (dict "Context" . "Type" "section") .RelPermalink "section" -}} + {{ if $image.exists }} +
+ {{ 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 -}} + + + {{ else }} + + {{ end }} +
+ {{ end }} +
+
+ + {{- $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 -}} + + {{- end -}} + + {{/* List only pages that are not a subsection */}} + {{ $paginator := .Paginate $pages }} +
+ {{ range $paginator.Pages }} + {{ partial "article-list/compact" . }} + {{ end }} +
+ + {{- 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 "" | safeHTML }} + + + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo -- gohugo.io{{ with .Site.LanguageCode }} + {{.}}{{end}}{{ with .Site.Params.Author.email }} + {{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Params.Author.email }} + {{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} + {{.}}{{end}}{{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "RSS" -}} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end -}} + {{ range $pages }} + {{- $content := safeHTML (.Summary | html) -}} + {{- if .Site.Params.rssFullContent -}} + {{- $content = safeHTML (.Content | html) -}} + {{- end -}} + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Params.Author.email }}{{.}}{{ with $.Site.Params.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + + {{- $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 }} + + {{ end }} + + 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 }} -- cgit v1.2.3