Switch absolute links to relative links

This is to make testing and deploying between different versions easier
such as Netlify deployments.
This commit is contained in:
Gabriel Arazas 2023-04-28 00:53:55 +08:00
parent 6ef52bcd53
commit 092df10444
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
8 changed files with 14 additions and 11 deletions

View File

@ -22,6 +22,9 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
=== Updated
* Switch from absolute links to relative links.
This is to make testing between different versions easier such as Netlify builds.
* Update class names of several components.
** `.icon` has been updated to `.site__icon`.

View File

@ -11,7 +11,7 @@ Otherwise, we take the pages of a section. */ -}}
{{- range (.Paginate $pages).Pages }}
<article class="post">
<h1><a href="{{ .Permalink }}" aria-label="{{ .Title }}">{{ .Title }}</a></h1>
<h1><a href="{{ .RelPermalink }}" aria-label="{{ .Title }}">{{ .Title }}</a></h1>
{{ partial "partials/components/post-meta.html" . }}
</article>
{{- end }}

View File

@ -50,7 +50,7 @@
{{- $langs := slice }}
{{- range .Translations }}
{{- $lang := cond (ne .Language.LanguageName nil) .Language.LanguageName .Lang }}
{{ $lang_links = $lang_links | append (printf "<a href=%s>%s</a>" .Permalink $lang) }}
{{ $lang_links = $lang_links | append (printf "<a href=%s>%s</a>" .RelPermalink $lang) }}
{{ $langs = $langs | append $lang }}
{{- end }}
<p data-content-translations="{{ jsonify $langs }}">{{ i18n "available_translations" }}: {{ delimit $lang_links "," (printf " %s " (i18n "and")) }}</p>

View File

@ -15,7 +15,7 @@
{{- range $pages }}
<li class="post--list">
<date class="post--list__date" datetime="{{ .PublishDate }}">{{ .PublishDate.Format "2006-01-02" }}</date>
<a class="post--list__title" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
<a class="post--list__title" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</li>
{{- end }}
</ul>

View File

@ -13,7 +13,7 @@
"name" $name)
(resources.Get "templates/heroicon.svg") }}
<svg class="site__icon">
<use href="{{ $res.Permalink }}#{{ $name }}"></use>
<use href="{{ $res.RelPermalink }}#{{ $name }}"></use>
</svg>
{{ end }}
@ -27,6 +27,6 @@
"name" $name)
(resources.Get "templates/simple-icon.svg") }}
<svg class="site__icon">
<use href="{{ $res.Permalink }}#{{ $name }}"></use>
<use href="{{ $res.RelPermalink }}#{{ $name }}"></use>
</svg>
{{- end }}

View File

@ -22,7 +22,7 @@
{{ $links := sort .links "id" "asc" }}
{{ $links = sort $links "weight" "asc" }}
{{- range $links -}}
<a {{ if $useImage }}class="site__social-icon"{{ end }} rel="me" href="{{ .url | absLangURL }}" aria-label="{{ with .name }}{{ . }}{{ else }}{{ .id }}{{ end }}">
<a {{ if $useImage }}class="site__social-icon"{{ end }} rel="me" href="{{ .url | relLangURL }}" aria-label="{{ with .name }}{{ . }}{{ else }}{{ .id }}{{ end }}">
{{- if $useImage }}
{{- partial "components/simple-icon.html" (dict "id" .id) }}
{{- else }}

View File

@ -17,7 +17,7 @@
{{- if hugo.IsProduction }}
{{- $style = $style | resources.Minify | resources.Fingerprint -}}
{{- end }}
<link rel="stylesheet" href="{{ $style.Permalink }}" />
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
{{- /* Persistent theme.
It's a very small script so there's little effect on perceived performance. */ -}}
<script>
@ -27,7 +27,7 @@ It's a very small script so there's little effect on perceived performance. */ -
}
</script>
<link rel="shortcut icon" href="{{ absURL "favicon.png" }}" />
<link rel="shortcut icon" href="{{ relURL "favicon.png" }}" />
{{- /* Some sane <meta> tags default */ -}}
{{ hugo.Generator }}
@ -49,7 +49,7 @@ It's a very small script so there's little effect on perceived performance. */ -
{{- /* Linking all of the output formats for discovery. */ -}}
{{- range .OutputFormats }}
{{- printf "<link rel=%q type=%q href=%q />" .Rel .MediaType.Type .Permalink | safeHTML }}
{{- printf "<link rel=%q type=%q href=%q />" .Rel .MediaType.Type .RelPermalink | safeHTML }}
{{- end }}

View File

@ -1,11 +1,11 @@
<header aria-label="Site header">
<nav class="site__nav-header">
<a class="site__title" href="{{ "" | absLangURL }}">{{ $.Site.Title }}</a>
<a class="site__title" href="{{ "" | relLangURL }}">{{ $.Site.Title }}</a>
<ul class="site__list">
{{ with $.Site.Menus.main }}
{{ range . -}}
<li>
<a href="{{ .URL | absLangURL }}">{{- .Name -}}</a>
<a href="{{ .URL | relLangURL }}">{{- .Name -}}</a>
</li>
{{ end }}
{{ end }}