Skip to content

Commit

Permalink
🎉Feat: add automatic generation of mastodon verification links
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Sajid Imami <[email protected]>
  • Loading branch information
AliSajid committed Dec 3, 2024
1 parent fcb0f1e commit 61f51b2
Showing 1 changed file with 33 additions and 0 deletions.
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

0 comments on commit 61f51b2

Please sign in to comment.