Skip to content

Commit

Permalink
fix: upgrade hugo to 0.128.2 version and fix issues (#240)
Browse files Browse the repository at this point in the history
- Upgrade Hugo and use 0.128.2 version.
- Fix pagination and breadcrumb issues.
- Fix deprecated issue of `.Site.IsServer` by using `hugo.isServer`.
  • Loading branch information
faiq-naufal authored Jul 8, 2024
1 parent 1468d5f commit 0078705
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.111.3
HUGO_VERSION: 0.128.2
NODE_VERSION: 20
_HUGO_APP_CANONICAL_ORIGIN: https://inlive.app
_HUGO_APP_ENV: production
Expand Down
25 changes: 16 additions & 9 deletions themes/inlive/layouts/partials/docs/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@

<!-- templates -->
{{ define "breadcrumbs" }}
{{ $split := index (split .currentPage.Parent.File.Dir "/") }}
{{ $parentSection := index $split (sub (len $split) 2) }}
{{ if .currentPage.Parent.Slug }}
{{ $split := index (split .currentPage.Parent.File.Dir "/") }}
{{ $parentSection := index $split (sub (len $split) 2) }}

{{ if and (.currentPage.Parent) (and (not .currentPage.Parent.IsHome) (ne $parentSection nil)) }}
{{ template "breadcrumbs" dict "currentPage" .currentPage.Parent }}
{{ end }}
<li class="group flex items-center text-red-600 font-bold text-sm">
<a href="{{ .currentPage.RelPermalink }}" class="block hover:underline">{{ .currentPage.Params.menu.docs_sidebar.name }}</a>
<span class="block mx-1 group-last:hidden">/</span>
</li>
{{ if and (.currentPage.Parent) (and (not .currentPage.Parent.IsHome) (ne $parentSection nil)) }}
{{ template "breadcrumbs" dict "currentPage" .currentPage.Parent }}
{{ end }}
<li class="group flex items-center text-red-600 font-bold text-sm">
<a href="{{ .currentPage.RelPermalink }}" class="block hover:underline">{{ .currentPage.Params.menu.docs_sidebar.name }}</a>
<span class="block mx-1 group-last:hidden">/</span>
</li>
{{ else }}
<li class="group flex items-center text-red-600 font-bold text-sm">
<a href="{{ .currentPage.RelPermalink }}" class="block hover:underline">{{ .currentPage.Params.menu.docs_sidebar.name }}</a>
<span class="block mx-1 group-last:hidden">/</span>
</li>
{{ end }}
{{ end }}
94 changes: 48 additions & 46 deletions themes/inlive/layouts/partials/docs/pagination.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
{{ if .File.Path }}
{{ if .File }}
{{ if .File.Path }}

{{ $context := . }}
{{ $context := . }}

{{ $menus := partial "docs/sequential-order-menu.html" (dict
"context" $context
"menuEntries" .Site.Menus.docs_sidebar
) }}
{{ $menus := partial "docs/sequential-order-menu.html" (dict
"context" $context
"menuEntries" .Site.Menus.docs_sidebar
) }}

{{ $prev := "" }}
{{ $next := "" }}
{{ $prev := "" }}
{{ $next := "" }}

{{ range $index, $menu := $menus }}
{{ if eq $menu.Page $context.Page }}
{{ $prev = index $menus (sub $index 1)}}
{{ $next = index $menus (add $index 1)}}
{{ end }}
{{ end }}

<nav class="py-16">
<ul class="grid grid-cols-1 lg:grid-cols-2 justify-between gap-4">
<li>
{{ if $prev }}
<a href="{{ $prev.URL }}"
class="w-full h-full px-4 py-3 lg:p-4 flex justify-between gap-x-4 border border-gray-300 hover:border-red-400 rounded-lg font-medium text-base text-red-600">
<span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" />
</svg>
</span>
<span class="flex-1 text-right">{{ $prev.Name }}</span>
</a>
{{ end }}
</li>
<li>
{{ if $next }}
<a href="{{ $next.URL }}"
class="w-full h-full px-4 py-3 lg:p-4 flex justify-between gap-x-4 border border-gray-300 hover:border-red-400 rounded-lg font-medium text-base text-red-600">
<span class="flex-1 text-left">{{ $next.Name}}</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
</svg>
</span>
</a>
{{ range $index, $menu := $menus }}
{{ if eq $menu.Page $context.Page }}
{{ $prev = index $menus (sub $index 1)}}
{{ $next = index $menus (add $index 1)}}
{{ end }}
</li>
</ul>
</nav>
{{ end }}

<nav class="py-16">
<ul class="grid grid-cols-1 lg:grid-cols-2 justify-between gap-4">
<li>
{{ if $prev }}
<a href="{{ $prev.URL }}"
class="w-full h-full px-4 py-3 lg:p-4 flex justify-between gap-x-4 border border-gray-300 hover:border-red-400 rounded-lg font-medium text-base text-red-600">
<span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" />
</svg>
</span>
<span class="flex-1 text-right">{{ $prev.Name }}</span>
</a>
{{ end }}
</li>
<li>
{{ if $next }}
<a href="{{ $next.URL }}"
class="w-full h-full px-4 py-3 lg:p-4 flex justify-between gap-x-4 border border-gray-300 hover:border-red-400 rounded-lg font-medium text-base text-red-600">
<span class="flex-1 text-left">{{ $next.Name}}</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
</svg>
</span>
</a>
{{ end }}
</li>
</ul>
</nav>
{{ end }}
{{ end }}
4 changes: 2 additions & 2 deletions themes/inlive/layouts/partials/head/css.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

{{ $styles := resources.Get "css/tailwind.css" }}
{{ $styles = $styles | resources.PostCSS }}
{{ if or (eq hugo.Environment "production") (and (eq hugo.Environment "development") (not .Site.IsServer)) }}
{{ if or (eq hugo.Environment "production") (and (eq hugo.Environment "development") (not hugo.IsServer)) }}
{{ $styles = $styles | minify | fingerprint | resources.PostProcess }}
{{ else if .Site.IsServer }}
{{ else if hugo.IsServer }}
{{ $styles = $styles | resources.ExecuteAsTemplate (printf "tailwind.%v.css" now.UnixMilli) .}}
{{ end }}
<link href="{{ $styles.RelPermalink }}" rel="stylesheet">

0 comments on commit 0078705

Please sign in to comment.