refactor: move default parameter values from template logic to params.toml (#1244)

This commit is contained in:
Jimmy
2026-01-26 15:50:18 +01:00
committed by GitHub
parent 3b753c9cc0
commit 3a03d69502
11 changed files with 33 additions and 27 deletions
@@ -35,7 +35,7 @@
<div>
{{ partial "helper/icon" "date" }}
<time class="article-time--published" datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
{{- .Date | time.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
{{- .Date | time.Format .Site.Params.dateFormat.published -}}
</time>
</div>
{{ end }}
@@ -12,7 +12,7 @@
<section class="article-lastmod">
{{ partial "helper/icon" "clock" }}
<span>
{{ T "article.lastUpdatedOn" }} {{ .Lastmod | time.Format ( or .Site.Params.dateFormat.lastUpdated "Jan 02, 2006 15:04 MST" ) }}
{{ T "article.lastUpdatedOn" }} {{ .Lastmod | time.Format .Site.Params.dateFormat.lastUpdated }}
</span>
</section>
{{- end -}}
@@ -1,4 +1,4 @@
{{- $host := default "https://cusdis.com" .Site.Params.comments.cusdis.host -}}
{{- $host := .Site.Params.comments.cusdis.host -}}
<div id="cusdis_thread" data-host="{{ $host }}" data-app-id="{{ .Site.Params.comments.cusdis.id }}"
data-page-id="{{ .File.UniqueID }}" data-page-url="{{ .Permalink }}" data-page-title="{{ .Title }}"></div>
<script async defer src="{{ $host }}/js/cusdis.es.js"></script>
@@ -5,13 +5,13 @@
data-repo-id="{{- .repoID -}}"
data-category="{{- .category -}}"
data-category-id="{{- .categoryID -}}"
data-mapping="{{- default `title` .mapping -}}"
data-strict="{{- default 0 .strict -}}"
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
data-emit-metadata="{{- default 0 .emitMetadata -}}"
data-input-position="{{- default `top` .inputPosition -}}"
data-theme="{{- default `light` .lightTheme -}}"
data-lang="{{- default `en` .lang -}}"
data-mapping="{{- .mapping -}}"
data-strict="{{- .strict -}}"
data-reactions-enabled="{{- .reactionsEnabled -}}"
data-emit-metadata="{{- .emitMetadata -}}"
data-input-position="{{- .inputPosition -}}"
data-theme="{{- .lightTheme -}}"
data-lang="{{- .lang -}}"
data-loading="{{- .loading -}}"
crossorigin="anonymous"
async
@@ -42,9 +42,9 @@
function handler() {
if (document.documentElement.dataset.scheme === "light") {
setGiscusTheme('{{- default "light" .lightTheme -}}');
setGiscusTheme('{{- .lightTheme -}}');
} else {
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
setGiscusTheme('{{- .darkTheme -}}');
}
}
})();
@@ -6,11 +6,11 @@
site_id: '{{ .site }}',
components: ['embed'],
url: '{{ $.Permalink }}',
max_shown_comments: {{ default 15 .max_shown_comments }},
max_shown_comments: {{ .max_shown_comments }},
theme: document.documentElement.dataset.scheme,
page_title: '{{ $.Title }}',
locale: '{{ default "en" .locale }}',
show_email_subscription: {{ default true .show_email_subscription }}
locale: '{{ .locale }}',
show_email_subscription: {{ .show_email_subscription }}
};
!function(e, n) {
@@ -14,7 +14,7 @@
props: {
title: "{{ $.Title }}",
options: {
autoCreateIssue: {{ default false .autoCreateIssue }},
autoCreateIssue: {{ .autoCreateIssue }},
owner: "{{ .owner }}",
repo: "{{ .repo }}",
clientId: "{{ .clientId }}",
+2 -2
View File
@@ -1,5 +1,5 @@
{{- $defaultColorScheme := default "auto" .Site.Params.colorScheme.default -}}
{{- if not (default false .Site.Params.colorScheme.toggle) -}}
{{- $defaultColorScheme := .Site.Params.colorScheme.default -}}
{{- if not .Site.Params.colorScheme.toggle -}}
{{/* If toggle is disabled, force default scheme */}}
<script>
(function() {
@@ -11,6 +11,6 @@
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) -}}
{{- if $image -}}
<meta name="twitter:card" content="{{ default `summary_large_image` .Site.Params.opengraph.twitter.card }}">
<meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />
{{- end -}}
+2 -2
View File
@@ -7,7 +7,7 @@
<header>
{{ with .Site.Params.sidebar.avatar }}
{{ if (default true .enabled) }}
{{ if .enabled }}
<figure class="site-avatar">
<a href="{{ .Site.BaseURL | relLangURL }}">
{{ if not .local }}
@@ -94,7 +94,7 @@
</li>
{{ end }}
{{ if (default false .Site.Params.colorScheme.toggle) }}
{{ if .Site.Params.colorScheme.toggle }}
<li id="dark-mode-toggle">
{{ partial "helper/icon" "toggle-left" }}
{{ partial "helper/icon" "toggle-right" }}