mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-07 01:54:23 +00:00
Support optional title case
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
footerBelowFold = false
|
||||
loading = "lazy"
|
||||
breakpoint = "md"
|
||||
titleCase = false
|
||||
[main.internalLinks]
|
||||
validate = true
|
||||
pretty = false
|
||||
|
2
exampleSite/config/_default/params.fr.toml
Normal file
2
exampleSite/config/_default/params.fr.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[main]
|
||||
titleCase = false
|
2
exampleSite/config/_default/params.nl.toml
Normal file
2
exampleSite/config/_default/params.nl.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[main]
|
||||
titleCase = false
|
@@ -8,6 +8,7 @@
|
||||
footerBelowFold = false
|
||||
loading = "lazy"
|
||||
breakpoint = "md"
|
||||
titleCase = true
|
||||
[main.internalLinks]
|
||||
validate = true
|
||||
pretty = true
|
||||
|
4
go.mod
4
go.mod
@@ -6,13 +6,13 @@ require (
|
||||
github.com/airbnb/lottie-web v5.12.2+incompatible // indirect
|
||||
github.com/gethinode/mod-bootstrap v1.3.2 // indirect
|
||||
github.com/gethinode/mod-csp v1.0.7 // indirect
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.0.3 // indirect
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.1.0 // indirect
|
||||
github.com/gethinode/mod-fontawesome v1.10.1 // indirect
|
||||
github.com/gethinode/mod-google-analytics v1.3.1 // indirect
|
||||
github.com/gethinode/mod-katex v1.1.3 // indirect
|
||||
github.com/gethinode/mod-leaflet v1.2.1 // indirect
|
||||
github.com/gethinode/mod-lottie v1.5.13 // indirect
|
||||
github.com/gethinode/mod-simple-datatables v1.1.6 // indirect
|
||||
github.com/gethinode/mod-simple-datatables v1.1.7 // indirect
|
||||
github.com/gethinode/mod-utils/v2 v2.9.0 // indirect
|
||||
github.com/nextapps-de/flexsearch v0.0.0-20240501124520-961c3ae84a87 // indirect
|
||||
github.com/twbs/bootstrap v5.3.3+incompatible // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -96,6 +96,8 @@ github.com/gethinode/mod-flexsearch/v2 v2.0.2 h1:5FkLbjORwKvK544H/yaAltyIB7eptRP
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.0.2/go.mod h1:d7MMkVlz0l6cEk76e0mkveEsDxGfu5Sv+HUIhoGguhE=
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.0.3 h1:lC4UN9DPYyj3lsRm86Rt+kKx2DmAS10dOxbM/1H8fVw=
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.0.3/go.mod h1:d7MMkVlz0l6cEk76e0mkveEsDxGfu5Sv+HUIhoGguhE=
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.1.0 h1:NzCruYAKQBMM1DwFFoH7/tzqmItR6sKByMHZWRaRiRk=
|
||||
github.com/gethinode/mod-flexsearch/v2 v2.1.0/go.mod h1:d7MMkVlz0l6cEk76e0mkveEsDxGfu5Sv+HUIhoGguhE=
|
||||
github.com/gethinode/mod-fontawesome v1.0.2 h1:ZSK6D20/w4y5GnfYfTBB58uHD0ChIfkpKfRGwioS9rg=
|
||||
github.com/gethinode/mod-fontawesome v1.0.2/go.mod h1:Ki1qkWEOiF0hQpCgWeZRw+HkpL6nd1DxKFptU0O2feI=
|
||||
github.com/gethinode/mod-fontawesome v1.1.0 h1:rsDzUI+3ZlS/do2ff3ne8/z3KwHeysmuA+WsXlumXXk=
|
||||
@@ -308,6 +310,8 @@ github.com/gethinode/mod-simple-datatables v1.1.5 h1:DKJ+aR94mekzcDwOnm6MJ/+MjAz
|
||||
github.com/gethinode/mod-simple-datatables v1.1.5/go.mod h1:bvMdmQFk4Hvyltf/QhMqUaApvPbIGTnbI3JLjOEh8go=
|
||||
github.com/gethinode/mod-simple-datatables v1.1.6 h1:7nPeRwHlYbmlNEg7fBV6FyXqpxWW6ZAemaZyYxpIF8U=
|
||||
github.com/gethinode/mod-simple-datatables v1.1.6/go.mod h1:bvMdmQFk4Hvyltf/QhMqUaApvPbIGTnbI3JLjOEh8go=
|
||||
github.com/gethinode/mod-simple-datatables v1.1.7 h1:wCY2bWFUxRHWbWzb/zefCACooCSbDPYKrZthfn+qAgM=
|
||||
github.com/gethinode/mod-simple-datatables v1.1.7/go.mod h1:FjkIEuxqeLLEqqDcz/nHAGHsRfV7EJP5Uhk4kYD8okY=
|
||||
github.com/gethinode/mod-utils v1.0.0 h1:cqHm2xS5uDiJzRm1KfHaNbq6uMVDKLhQa8/BuTZ1nhY=
|
||||
github.com/gethinode/mod-utils v1.0.0/go.mod h1:ONJm3pHCq7nvaPNjusLZNCeCbhOhSBH4HVKHwK1FdYE=
|
||||
github.com/gethinode/mod-utils v1.0.1 h1:jhZGlGFHHL1f5HXbBMXfiZ2gCz4TVafAzjnRPTIBSEE=
|
||||
|
17
layouts/_default/_markup/render-heading-new.html
Normal file
17
layouts/_default/_markup/render-heading-new.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{{ $text := chomp .Text }}
|
||||
{{ if site.Params.main.titleCase }}{{ $text = title $text }}{{ end }}
|
||||
|
||||
{{ if eq page.RelPermalink "/en/privacy/" }}
|
||||
{{ warnf "title: %s" (.Text | safeHTML) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if and site.Params.navigation.anchor $text }}
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading">
|
||||
{{- $text | safeHTML -}}
|
||||
<a href="#{{ .Anchor | safeURL }}" aria-labelledby="{{ .Anchor | safeURL }}">
|
||||
{{- partial "assets/icon.html" (dict "icon" "fas link anchor") }}
|
||||
</a>
|
||||
</h{{ .Level }}>
|
||||
{{ else }}
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ $text | safeHTML }}</h{{ .Level }}>
|
||||
{{ end }}
|
@@ -1,12 +1,13 @@
|
||||
{{ $text := trim .Text " \n\r" }}
|
||||
{{ $text := chomp .Text }}
|
||||
{{ if site.Params.main.titleCase }}{{ $text = (title ($text | htmlUnescape)) | htmlEscape }}{{ end }}
|
||||
|
||||
{{ if and site.Params.navigation.anchor $text }}
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading">
|
||||
{{- .Text | safeHTML -}}
|
||||
{{- $text | safeHTML -}}
|
||||
<a href="#{{ .Anchor | safeURL }}" aria-labelledby="{{ .Anchor | safeURL }}">
|
||||
{{- partial "assets/icon.html" (dict "icon" "fas link anchor") }}
|
||||
</a>
|
||||
</h{{ .Level }}>
|
||||
{{ else }}
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}</h{{ .Level }}>
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ $text | safeHTML }}</h{{ .Level }}>
|
||||
{{ end }}
|
@@ -2,11 +2,13 @@
|
||||
{{- $fullCover := $.Scratch.Get "fullCover" -}}
|
||||
{{- $breakpoint := $.Scratch.Get "breakpoint" -}}
|
||||
{{- $layout := .Params.layout -}}
|
||||
{{- $title := .Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
<div class="row row-cols-1 row-cols-{{ $breakpoint.current }}-2">
|
||||
<div class="col-12 col-{{ $breakpoint.current }}-9">
|
||||
{{ if not .IsHome }}
|
||||
{{ with .Title }}<p id="{{ anchorize . }}" class="display-4 mt-5{{ if and $.IsHome site.Params.home.centerHeadline }} text-center{{ end }}">{{ . }}</p>{{ end }}
|
||||
{{ with $title }}<p id="{{ anchorize . }}" class="display-4 mt-5{{ if and $.IsHome site.Params.home.centerHeadline }} text-center{{ end }}">{{ . }}</p>{{ end }}
|
||||
{{ end }}
|
||||
{{ if (.Params.menu) }}
|
||||
{{- partial "assets/section-menu.html" (dict "page" .) -}}
|
||||
|
@@ -12,7 +12,10 @@
|
||||
{{- errorf "layout [_default/single/header.html] - Invalid value for param 'metadata': %s" $metadata -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ with .Title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ $title := .Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
{{ with $title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ if ne $metadata "none" }}
|
||||
<small class="text-body-secondary text-uppercase">
|
||||
{{ if .Date }}
|
||||
|
@@ -1,3 +1,6 @@
|
||||
{{ with .Title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ $title := .Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
{{ with $title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ partial "assets/sharing.html" (dict "page" .) }}
|
||||
<p class="lead mb-5">{{ .Description }}</p>
|
||||
|
@@ -1,3 +1,6 @@
|
||||
{{ with .Title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ $title := .Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
{{ with $title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
|
||||
{{ partial "assets/sharing.html" (dict "page" .) }}
|
||||
<p class="lead mb-5">{{ .Description }}</p>
|
||||
|
@@ -30,7 +30,8 @@
|
||||
{{ $items := slice }}
|
||||
{{- range $index, $item := $page.Ancestors.Reverse -}}
|
||||
{{- $title := .LinkTitle -}}
|
||||
{{- if .IsHome }}{{ $title = T "home" }}{{ end -}}
|
||||
{{- if .IsHome }}{{ $title = T "home" }}{{ end -}}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
{{- $address := or .RelPermalink .Params.Redirect -}}
|
||||
{{ if and $title $address}}
|
||||
{{ $items = $items | append (dict "title" $title "address" $address) }}
|
||||
@@ -57,9 +58,15 @@
|
||||
<ol class="breadcrumb">
|
||||
{{- $length := len $items }}
|
||||
{{- range $index, $item := $items -}}
|
||||
<li class="breadcrumb-item"><a href="{{ $item.address }}">{{ $item.title }}</a></li>
|
||||
{{ $title := $item.title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
<li class="breadcrumb-item"><a href="{{ $item.address }}">{{ $title }}</a></li>
|
||||
{{- end -}}
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $page.LinkTitle }}</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">
|
||||
{{ $title := $page.LinkTitle }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
{{ $title }}
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{{ end }}
|
@@ -86,6 +86,8 @@
|
||||
{{- if eq $body "title" }}{{ $description = "" }}{{ end -}}
|
||||
{{- if eq $body "none" }}{{ $title = "" }}{{ $description = "" }}{{ end -}}
|
||||
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
<!-- Inline partial to render the card's body -->
|
||||
{{- define "partials/card-body.html" -}}
|
||||
{{- $title := .title -}}
|
||||
|
@@ -33,6 +33,9 @@
|
||||
{{- $url := .url -}}
|
||||
{{- $mode := .mode -}}
|
||||
{{- $modes := site.Params.main.modes | default (slice "light" "dark") -}}
|
||||
{{ if and site.Params.main.titleCase (eq $caption (plainify $caption)) }}
|
||||
{{ $caption = title $caption }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Main code -->
|
||||
{{ $params := dict }}
|
||||
|
@@ -106,7 +106,12 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{- if not $case }}{{ $text = lower $text }}{{ end -}}
|
||||
{{- if not $case }}
|
||||
{{ $text = lower $text }}
|
||||
{{ else if site.Params.main.titleCase }}
|
||||
{{ $text = title $text }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if and $pretty (not (hasSuffix $destination "/" )) (not (strings.Contains $destination "#")) }}
|
||||
{{ $destination = printf "%s/" $destination }}
|
||||
{{ end }}
|
||||
|
@@ -77,16 +77,19 @@
|
||||
|
||||
<!-- Main code -->
|
||||
{{ if not $error }}
|
||||
{{ $title := $menu.Name }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
{{ if $menu.Params.button }}
|
||||
{{ partial "assets/button.html" (dict
|
||||
"title" $menu.Name
|
||||
"title" $title
|
||||
"icon" $menu.Pre
|
||||
"href" $menuURL
|
||||
"size" "sm"
|
||||
)}}
|
||||
{{ else }}
|
||||
{{ cond (ne $menuURL "") "<a" "<div" | safeHTML }} class="{{ $anchorClass }}{{ if $isActive }} active{{ end }}{{ with $class }} {{ . }}{{ end }}"
|
||||
{{ if $isIcon }}aria-label="{{ $menu.Name }}"{{ end }}
|
||||
{{ if $isIcon }}aria-label="{{ $title }}"{{ end }}
|
||||
data-nav="main" data-nav-main="{{ $mainNav }}"{{ with $childNav }} data-nav-child="{{ . }}"{{ end }}
|
||||
{{ if $menuURL }} href="{{ $menuURL }}{{ $params | safeHTML }}"{{ with $externalHref }} {{ . | safeHTML }}{{ end }}{{ end }} {{ $button | safeHTML }}>
|
||||
|
||||
@@ -97,7 +100,7 @@
|
||||
{{ partial "assets/icon.html" (dict "icon" (string .) )}}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
<span {{ if $isActive }} class="active"{{ end }}>{{ if or (not $isIcon) $plain }}{{ $menu.Name }}{{ end }}</span>
|
||||
<span {{ if $isActive }} class="active"{{ end }}>{{ if or (not $isIcon) $plain }}{{ $title }}{{ end }}</span>
|
||||
{{- with $menu.Post }}{{ . }}{{ end -}}
|
||||
{{- if not $isIcon }} {{ $suffix }}{{ end -}}
|
||||
{{ cond (ne $menuURL "") "</a>" "</div>" | safeHTML }}
|
||||
|
@@ -13,7 +13,9 @@
|
||||
<div class="col col-6">
|
||||
<div class="row justify-content-end p-0">
|
||||
<div class="col-12 col-md-8 p-0">
|
||||
<div class="fs-3 fw-bold">{{ or .Site.Params.footer.socialTitle .Site.Params.social.title }}</div>
|
||||
{{- $title := or .Site.Params.footer.socialTitle .Site.Params.social.title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
<div class="fs-3 fw-bold">{{ $title }}</div>
|
||||
<p>{{ or .Site.Params.footer.socialCaption .Site.Params.social.caption }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -2,13 +2,13 @@
|
||||
|
||||
<!-- Adapted from doks -->
|
||||
{{ with .Params.meta.title }}
|
||||
{{ $.Scratch.Set "title" . -}}
|
||||
{{ $title := . }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
{{ $.Scratch.Set "title" $title -}}
|
||||
{{ else }}
|
||||
{{ with .Title -}}
|
||||
{{ $.Scratch.Set "title" . -}}
|
||||
{{ else -}}
|
||||
{{ $.Scratch.Set "title" .Site.Title -}}
|
||||
{{ end -}}
|
||||
{{ $title := .Title | default .Site.Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
{{ $.Scratch.Set "title" $title -}}
|
||||
{{ end }}
|
||||
|
||||
{{ $description := or (partial "utilities/GetDescription.html" (dict "page" . "meta" true)) .Site.Params.main.description }}
|
||||
|
@@ -22,7 +22,10 @@
|
||||
{{ $force := false }}
|
||||
{{ $cue := site.Params.main.externalLinks.cue }}
|
||||
{{ $tab := site.Params.main.externalLinks.tab }}
|
||||
{{ $text := trim .Inner " \r\n" | .Page.RenderString | safeHTML }}
|
||||
{{ $text := chomp .Inner }}
|
||||
{{ if site.Params.main.titleCase }}{{ $text = title $text }}{{ end }}
|
||||
{{ $text := $text | .Page.RenderString | safeHTML }}
|
||||
|
||||
{{- $anchor := "" -}}
|
||||
|
||||
{{ if .IsNamedParams }}
|
||||
|
@@ -3,6 +3,8 @@
|
||||
{{- $layout := $page.Params.layout -}}
|
||||
{{- $breakpoint := $.Scratch.Get "breakpoint" -}}
|
||||
{{- $hasSidebar := site.Params.navigation.sidebar | default true -}}
|
||||
{{- $pageTitle := .Page.Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $pageTitle = title $pageTitle }}{{ end }}
|
||||
|
||||
<div class="container-xxl flex-fill p-4 px-xxl-0">
|
||||
<div class="row row-cols-1 row-cols-{{ $breakpoint.prev }}-{{ if $hasSidebar }}3{{ else }}2{{ end }}">
|
||||
@@ -14,17 +16,20 @@
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
<p class="display-4 mt-5">{{ .Page.Title }}</p>
|
||||
<p class="display-4 mt-5">{{ $pageTitle }}</p>
|
||||
|
||||
{{ if eq .Kind "taxonomy" }}
|
||||
<div class="row mt-5"></div>
|
||||
{{ range $.Site.Taxonomies.tags.ByCount }}
|
||||
{{- $title := .Page.Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-3 mt-auto text-right">
|
||||
{{ .Count }} {{ if gt .Count 1 }} {{ T "articles" }} {{ else }} {{ T "article" }} {{ end }}
|
||||
</div>
|
||||
<div class="col-9">
|
||||
<a href="{{ .Page.RelPermalink }}">{{ .Page.Title | .Page.RenderString }}</a>
|
||||
<a href="{{ .Page.RelPermalink }}">{{ $title | .Page.RenderString }}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
@@ -37,6 +42,8 @@
|
||||
{{ range .Pages }}
|
||||
{{ $year := .Date.Year }}
|
||||
{{ $lastYear := $.Scratch.Get "lastYear"}}
|
||||
{{- $title := .Title }}
|
||||
{{ if site.Params.main.titleCase }}{{ $title = title $title }}{{ end }}
|
||||
<div class="row mt-2">
|
||||
<div class="d-none d-{{ $breakpoint.prev }}-block col-{{ $breakpoint.prev }}-3 mt-auto text-right">
|
||||
{{ with .Date }}
|
||||
@@ -52,7 +59,7 @@
|
||||
<p class="text-body-secondary mt-5">{{ $year }}</p>
|
||||
{{ $.Scratch.Set "lastYear" $year }}
|
||||
{{ end }}
|
||||
<a href="{{ .Page.RelPermalink }}">{{ if .Draft }}{{ T "draft" | upper }}: {{ end }}{{ .Title | .Page.RenderString }}</a>
|
||||
<a href="{{ .Page.RelPermalink }}">{{ if .Draft }}{{ T "draft" | upper }}: {{ end }}{{ $title | .Page.RenderString }}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@gethinode/hinode",
|
||||
"version": "0.28.2",
|
||||
"version": "0.29.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@gethinode/hinode",
|
||||
"version": "0.28.2",
|
||||
"version": "0.29.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fullhuman/postcss-purgecss": "^7.0.2",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gethinode/hinode",
|
||||
"version": "0.28.2",
|
||||
"version": "0.29.0",
|
||||
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
|
||||
"keywords": [
|
||||
"hugo",
|
||||
|
Reference in New Issue
Block a user