initial template
This commit is contained in:
77
layouts/_default/baseof.html
Normal file
77
layouts/_default/baseof.html
Normal file
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ .Site.LanguageCode | default "en" }}">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
{{/* Generate consistent title */}}
|
||||
{{ $title := "" }}
|
||||
{{ if if .IsHome }}
|
||||
{{ $title = .Title }}
|
||||
{{ else }}
|
||||
{{ $title = printf "%s - %s" .Title .Site.Title }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Basic SEO -->
|
||||
<title>{{ $title }}</title>
|
||||
|
||||
{{/* Generate description from summary, description, or default site description */}}
|
||||
{{ $description := "" }}
|
||||
{{ with .Description }}
|
||||
{{ $description = . }}
|
||||
{{ else }}
|
||||
{{ $description = .Site.Params.description }}
|
||||
{{ end }}
|
||||
<meta name="description" content="{{ $description }}" />
|
||||
|
||||
{{/* Generate keywords from topics */}}
|
||||
{{ with .Params.topics }}
|
||||
<meta name="keywords" content="{{ delimit . ", " }}" />
|
||||
{{ end }}
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:site_name" content="{{ .Site.Title }}" />
|
||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||
<meta property="og:url" content="{{ .Permalink }}" />
|
||||
<meta property="og:title" content="{{ $title }}" />
|
||||
<meta property="og:description" content="{{ $description }}" />
|
||||
{{ with .Params.ogImage | default .Site.Params.openGraphImage }}
|
||||
<meta property="og:image" content="{{ . | absURL }}" />
|
||||
{{ end }}
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="{{ $title }}" />
|
||||
<meta name="twitter:description" content="{{ $description }}" />
|
||||
{{ with .Params.ogImage | default .Site.Params.openGraphImage }}
|
||||
<meta name="twitter:image" content="{{ . | absURL }}" />
|
||||
{{ end }}
|
||||
|
||||
<!-- Canonical URL -->
|
||||
<link rel="canonical" href="{{ .Permalink }}" />
|
||||
|
||||
<!-- CSS Styles -->
|
||||
{{ $style := resources.Get "css/styles.css" }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $style = $style | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}" integrity="{{ $style.Data.Integrity }}" crossorigin="anonymous">
|
||||
{{ else }}
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
|
||||
{{ end }}
|
||||
</head>
|
||||
<body class="">
|
||||
{{ partial "header.html" . }}
|
||||
|
||||
{{ block "main" . }}{{ end }}
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
|
||||
{{ $js := resources.Match "js/*.js" | resources.Concat "js/bundle.js" }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $js = $js | minify | fingerprint }}
|
||||
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{ else }}
|
||||
<script src="{{ $js.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
</body>
|
||||
</html>
|
12
layouts/_default/section.html
Normal file
12
layouts/_default/section.html
Normal file
@ -0,0 +1,12 @@
|
||||
{{ define "main" }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
<ul>
|
||||
{{ range .Pages }}
|
||||
<li>
|
||||
<a href="{{ .RelPermalink }}">
|
||||
{{ .Title }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
9
layouts/_default/single.html
Normal file
9
layouts/_default/single.html
Normal file
@ -0,0 +1,9 @@
|
||||
{{ define "main" }}
|
||||
<article>
|
||||
|
||||
<h1>{{ .Title }}</h1>
|
||||
|
||||
{{ .Content }}
|
||||
|
||||
</article>
|
||||
{{ end }}
|
26
layouts/_default/taxonomy.html
Normal file
26
layouts/_default/taxonomy.html
Normal file
@ -0,0 +1,26 @@
|
||||
{{ define "main" }}
|
||||
<header class="my-8">
|
||||
<p>{{ .Data.Singular }}</p>
|
||||
<h1>{{ .Title }}</h1>
|
||||
</header>
|
||||
<main>
|
||||
<ul>
|
||||
{{ range .Data.Pages }}
|
||||
<li>
|
||||
<a href="{{ .RelPermalink }}">
|
||||
{{ .Title }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
{{ if gt (len (index .Site.Taxonomies .Data.Singular)) 1 }}
|
||||
<section>
|
||||
<h2>Other {{ .Data.Plural }}</h2>
|
||||
<div class="tag-cloud">
|
||||
{{ partial "taxonomy-cloud" (dict "taxonomy" .Data.Singular "Site" .Site "page" .Page) }}
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
</main>
|
||||
{{ end }}
|
6
layouts/partials/footer.html
Normal file
6
layouts/partials/footer.html
Normal file
@ -0,0 +1,6 @@
|
||||
<footer>
|
||||
<h1 class="text-2xl font-bold">
|
||||
<a href="/">{{ .Site.Title }}</a>
|
||||
</h1>
|
||||
<p class="text-lg">{{ .Site.Params.footer | markdownify }}</p>
|
||||
</footer>
|
25
layouts/partials/header.html
Normal file
25
layouts/partials/header.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!-- basic header partial in hugo with just home and about -->
|
||||
<header class="flex flex-col mb-4">
|
||||
<div class="flex justify-between items-center p-4">
|
||||
<h1 class="text-2xl font-bold">
|
||||
<a href="/">{{ .Site.Title }}</a>
|
||||
</h1>
|
||||
<nav class="font-iosevka">
|
||||
<ul class="flex gap-4">
|
||||
<li>
|
||||
<a href="/">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/about">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="wompum-container wompum-container--wide-gap px-4 h-1">
|
||||
<div class="wompum-grid"
|
||||
data-text="{{ .Site.Title }}"
|
||||
data-columns="7"
|
||||
data-rows="1">
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
19
layouts/partials/image.html
Normal file
19
layouts/partials/image.html
Normal file
@ -0,0 +1,19 @@
|
||||
{{ $width := .width }}
|
||||
{{ $height := default $width .height }}
|
||||
{{ $class := .class }}
|
||||
{{ $resource := .resource }}
|
||||
{{ $alt := .alt }}
|
||||
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fit (printf "%dx%d webp" (int $width) (int $height)) }}
|
||||
{{ $fallback := .Fit (printf "%dx%d" (int $width) (int $height)) }}
|
||||
<picture class="{{ $class }} block">
|
||||
<source srcset="{{ $image.RelPermalink }}" type="image/webp">
|
||||
<img
|
||||
src="{{ $fallback.RelPermalink }}"
|
||||
alt="{{ $alt }}"
|
||||
width="{{ $width }}"
|
||||
height="{{ $height }}"
|
||||
loading="lazy">
|
||||
</picture>
|
||||
{{ end }}
|
40
layouts/partials/related-articles.html
Normal file
40
layouts/partials/related-articles.html
Normal file
@ -0,0 +1,40 @@
|
||||
{{- $topics := .topics -}}
|
||||
{{- $limit := default 3 .limit -}}
|
||||
{{- $currentPath := .page.RelPermalink -}}
|
||||
|
||||
{{- $related := where (where site.RegularPages "Type" "articles") "RelPermalink" "!=" $currentPath -}}
|
||||
{{- $matchingArticles := slice -}}
|
||||
|
||||
{{/* First try to find articles with matching topics */}}
|
||||
{{- range $related -}}
|
||||
{{- $matches := 0 -}}
|
||||
{{- range .Params.topics -}}
|
||||
{{- if in $topics . -}}
|
||||
{{- $matches = add $matches 1 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if gt $matches 0 -}}
|
||||
{{- $matchingArticles = $matchingArticles | append (dict "page" . "matches" $matches) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If we found matching articles, sort by number of matching topics */}}
|
||||
{{- $finalArticles := slice -}}
|
||||
{{- if gt (len $matchingArticles) 0 -}}
|
||||
{{- $finalArticles = first $limit (sort $matchingArticles "matches" "desc") -}}
|
||||
{{- else -}}
|
||||
{{/* Fallback to showing other articles sorted by date */}}
|
||||
{{- $finalArticles = first $limit (sort $related "Date" "desc") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if gt (len $finalArticles) 0 -}}
|
||||
<div class="related-articles flex flex-wrap gap-4">
|
||||
<h2 class="title text-3xl font-bold">Related Articles</h2>
|
||||
<div class="wompum-container wompum-container--no-gap">
|
||||
<div class="wompum-grid" data-text="Related Articles" data-columns="8" data-rows="1"></div>
|
||||
</div>
|
||||
<ul class="flex flex-col gap-4 w-full">
|
||||
{{ partial "article-list" (dict "Pages" $finalArticles) }}
|
||||
</ul>
|
||||
</div>
|
||||
{{- end -}}
|
10
layouts/partials/taxonomy-cloud.html
Normal file
10
layouts/partials/taxonomy-cloud.html
Normal file
@ -0,0 +1,10 @@
|
||||
{{ $taxonomy := .taxonomy }}
|
||||
{{ range $term, $pages := index .Site.Taxonomies $taxonomy }}
|
||||
{{ $termPage := $.Site.GetPage (printf "/%s/%s" $taxonomy $term) }}
|
||||
<a href="{{ $termPage.RelPermalink }}"
|
||||
data-size="{{ len $pages }}"
|
||||
class="tag"
|
||||
data-count="{{ len $pages}}">
|
||||
{{ $term }}
|
||||
</a>
|
||||
{{ end }}
|
Reference in New Issue
Block a user