Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from hugo-fixit:master #41

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/css/_core/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ header {
border-radius: $global-border-radius;
border: 1px solid $menu-border-color;
background-color: $header-background-color;
max-height: 60vh;
overflow-y: auto;
@include transition(box-shadow 0.3s ease);
@include box-shadow(0 0 1.5rem 0 rgba(0, 0, 0, 0.1));

Expand Down
2 changes: 2 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,8 @@ enableEmoji = true
# Depends on open custom blocks https://fixit.lruihao.cn/references/blocks/
[params.customPartials]
head = []
menuDesktop = []
menuMobile = []
profile = []
aside = []
comment = []
Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
{{- end -}}
{{- end -}}

{{- define "custom-menu:desktop" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.menuDesktop -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-menu:mobile" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.menuMobile -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-profile" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.profile -}}
Expand Down
33 changes: 33 additions & 0 deletions layouts/partials/head/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,39 @@
<link rel="alternate" type="application/feed+json" href="{{ .Permalink }}" title="{{ $title }}" />
{{- end -}}

{{- /* Mastodon Validation for the site */ -}}
{{- with .Site.Params.social.Mastodon -}}
{{- $mastodonConfig := . -}}
{{- $id := "" -}}
{{- $prefix := "https://mastodon.social/" -}}

{{- /* Check if Mastodon is a string */ -}}
{{- if printf "%T" $mastodonConfig | eq "string" -}}
{{- $id = strings.TrimPrefix "@" $mastodonConfig -}}

{{- /* Check if Mastodon is a map/object */ -}}
{{- else if printf "%T" $mastodonConfig | eq "map[string]interface {}" -}}
{{- $id = .Id | default .id | default "" | strings.TrimPrefix "@" -}}
{{- $prefix = .Prefix | default .prefix | default $prefix -}}

{{- /* If it's neither a string nor a map, do nothing */ -}}
{{- else -}}
{{- errorf "Invalid Mastodon configuration: %#v" $mastodonConfig -}}
{{- end -}}

{{- /* Remove trailing slash from prefix */ -}}
{{- $prefix = strings.TrimSuffix "/" $prefix -}}

{{- /* Construct profile URL */ -}}
{{- $profileUrl := printf "%s/@%s" $prefix $id -}}

{{- /* Only proceed if we have a valid ID */ -}}
{{- if $id -}}
<link rel="me" href="{{ $profileUrl }}" />
<meta name="fediverse:creator" content="{{ $id }}@{{ (urls.Parse $prefix).Host }}" />
{{- end -}}
{{- end -}}

{{- /* style.min.css */ -}}
{{- $options := dict "Source" "css/style.scss" "Fingerprint" $fingerprint -}}
{{- $toCSS := dict "targetPath" "css/style.min.css" "enableSourceMap" true -}}
Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
</ul>
</li>
{{- end -}}

{{- /* Custom menu items in the desktop header */ -}}
{{- block "custom-menu:desktop" . }}{{ end -}}
</ul>
</nav>
</div>
Expand Down Expand Up @@ -305,6 +308,9 @@
</select>
</span>
{{- end -}}

{{- /* Custom menu items in the mobile header */ -}}
{{- block "custom-menu:mobile" . }}{{ end -}}
</li>
</ul>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.16-f66dc32e" -}}
{{- .Scratch.Set "version" "v0.3.16-fda3fa66" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down
Loading