* feat: refactor condition for checking `site.Params.bundled`

- Add default condition for checking if `site.Params.bundled` is true or false

* refactor: update info page content

* chore: update site description

* refactor: refactor variable assignments and return statement in menu template

- Change the variable assignment from `.DirName` to `.Identifier` in the file `layouts/_default/single.json`
- Change the variable assignments in the file `layouts/partials/function/currentMenuItem.html`:
  - From `$dirName := ""` to `$identifier := ""`
  - From `$id := -1` to `$title := ""` and `$weight := -1`
  - From `$dirName = .Identifier` to `$identifier = .Identifier`, `$title = .Title`, and `$weight = .Weight`
- Change the return statement in the file `layouts/partials/function/currentMenuItem.html` from `(dict "DirName" $dirName "ID" $id)` to `(dict "Identifier" $identifier "Title" $title "Weight" $weight)`

* feat: update nav links structure for current link styling

- Remove javascript code related to setting current link style and title
- Update nav links to use updated HTML structure for current link styling

* feat: update page titles and meta tags in layout files

- Update the `baseof.html` layout to include the current page title in the `<title>` tag
- Add OpenGraph meta tags for the page title and description in `meta.html` layout
This commit is contained in:
Spedon
2024-01-07 23:16:55 +08:00
committed by GitHub
parent 0f537630e8
commit 8ba41fc32c
12 changed files with 62 additions and 63 deletions

View File

@@ -1,9 +1,4 @@
{{- define "main" -}}
{{- $params := .Scratch.Get "params" -}}
{{- $currentPage := . -}}
{{- with partial "function/currentMenuItem.html" . -}}
<script>document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")</script>
{{- end -}}
<div class="container">
{{- partial "nav.html" . -}}
</div>

View File

@@ -3,11 +3,10 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ site.Title }}</title>
{{- partial "head/link.html" -}}
{{- partial "head/meta.html" -}}
{{- partial "head/seo.html" -}}
{{- partial "head/favicon.html" -}}
{{- partial "head/link.html" . -}}
{{- partial "head/meta.html" . -}}
{{- partial "head/seo.html" . -}}
{{- partial "head/favicon.html" . -}}
</head>
<body lang="{{- site.LanguageCode -}}">
<div id="main">

View File

@@ -1,14 +1,9 @@
{{- define "main" -}}
{{- $params := .Scratch.Get "params" -}}
{{- $currentPage := . -}}
{{- with partial "function/currentMenuItem.html" . -}}
<script>
document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")
document.getElementById("main").setAttribute("nextText", "{{- i18n "next" -}}")
document.getElementById("main").setAttribute("prevText", "{{- i18n "prev" -}}")
document.getElementById("main").setAttribute("closeText", "{{- i18n "close" -}}")
</script>
{{- end -}}
<script>
document.getElementById("main").setAttribute("nextText", "{{- i18n "next" -}}")
document.getElementById("main").setAttribute("prevText", "{{- i18n "prev" -}}")
document.getElementById("main").setAttribute("closeText", "{{- i18n "close" -}}")
</script>
<div class="container">
{{- partial "nav.html" . -}}
</div>

View File

@@ -3,7 +3,7 @@
{{- $params := .Page.Params | merge .Site.Params.Page -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{- $Path = .DirName -}}
{{- $Path = .Identifier -}}
{{- end -}}
{{- $gallery := site.GetPage $Path -}}

View File

@@ -1,15 +1,17 @@
{{- $currentPage := . -}}
{{- $dirName := "" -}}
{{- $id := -1 -}}
{{- $identifier := "" -}}
{{- $title := "" -}}
{{- $weight := -1 -}}
{{- range site.Menus.main -}}
{{ $menu_item_url := .URL | relLangURL }}
{{ $page_url:= $currentPage.RelPermalink | relLangURL }}
{{ if eq $menu_item_url $page_url }}
{{- $dirName = .Identifier -}}
{{- $id = .Weight -}}
{{- $identifier = .Identifier -}}
{{- $title = .Title -}}
{{- $weight = .Weight -}}
{{- end -}}
{{- end -}}
{{- return (dict "DirName" $dirName "ID" $id) -}}
{{- return (dict "Identifier" $identifier "Title" $title "Weight" $weight) -}}

View File

@@ -8,7 +8,7 @@
{{- partial "plugin/style.html" $style -}}
{{/* main style */}}
{{- if site.Params.bundled -}}
{{- if (site.Params.bundled | default true) -}}
{{- $style := dict "Link" "/bundled/css/style.min.css" "Defer" true -}}
{{- partial "plugin/style.html" $style -}}
{{- else -}}

View File

@@ -1,9 +1,22 @@
<meta name="Description" content="{{- site.Params.description -}}" />
<meta
name="application-name"
content="{{- .Site.Params.app.title | default site.Title -}}"
/>
<meta
name="apple-mobile-web-app-title"
content="{{- .Site.Params.app.title | default site.Title -}}"
/>
{{/* Title */}}
{{- $page_title := "" -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{ $page_title = printf "%s" site.Title | printf "%s%s" " | " | printf "%s%s" .Title | printf "%s" }}
{{- end -}}
<title>{{ $page_title }}</title>
{{/* Basic */}}
<meta name="Description" content="{{ site.Params.description }}" />
<meta name="application-name" content="{{ $page_title }}" />
<meta name="apple-mobile-web-app-title" content="{{ $page_title }}" />
{{/* Opengraph */}}
<meta property="og:title" content="{{ $page_title }}" />
<meta name="twitter:title" content="{{ $page_title }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:description" content="{{ site.Params.description }}" />
<meta name="twitter:description" content="{{ site.Params.description }}" />
{{/* Generator */}}
{{ hugo.Generator }}

View File

@@ -4,14 +4,30 @@
</div>
<div class="links">
{{- $index := 0 -}}
{{- $currentIndex := -1 -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{- $currentIndex = sub .Weight 1 -}}
{{- end -}}
{{- $menus := .Site.Menus.main -}}
{{- $len := len $menus }}
{{- range $menus -}}
{{- $url := .URL | relURL -}}
{{- if eq (add $index 1) $len -}}
<a href="{{- .URL | relURL -}}" class="link">{{- .Title -}}</a>
<a
href="{{- .URL | relURL -}}"
class="link{{- if eq $index $currentIndex -}}
{{- printf " current" -}}
{{- end -}}"
>{{- .Title -}}</a
>
{{- else -}}
<a href="{{- .URL | relURL -}}" class="link">{{- .Title -}}</a>,&nbsp
<a
href="{{- .URL | relURL -}}"
class="link{{- if eq $index $currentIndex -}}
{{- printf " current" -}}
{{- end -}}"
>{{- .Title -}}</a
>,&nbsp
{{- end -}}
{{- $index = add $index 1 -}}
{{- end -}}