mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
75ee1624bd
* feat(external-link-guard): add native redirect mode and improve external-link guard UX * fix(external-link-guard): remove redirect_url and clarify scope/new_tab_policy docs * i18n(external-link-guard): localize guard texts across non-English locales * feat(config)!: migrate `site.Params.externalIcon` to `site.Params.link.external_icon` * refactor: implement regular and card link rendering * feat(link-guard): implement link redirection page with copy and confirm functionality * revert * feat: implement link guard dialog for external links --------- Co-authored-by: Cell <1024@lruihao.cn>
146 lines
6.9 KiB
HTML
146 lines
6.9 KiB
HTML
{{- $params := partial "function/params.html" -}}
|
|
|
|
{{- /* Git info */ -}}
|
|
{{- $gitRepo := "" -}}
|
|
{{- $blobURL := "" -}}
|
|
{{- $sourceURL := "" -}}
|
|
{{- $editURL := "" -}}
|
|
{{- $reportURL := "" -}}
|
|
{{- with .Site.Params.gitInfo -}}
|
|
{{- if .Repo -}}
|
|
{{- $gitRepo = strings.TrimSuffix "/" .Repo -}}
|
|
{{- $blobURL = printf "%v/blob/%v/%v/{path}" $gitRepo .Branch .Dir -}}
|
|
{{- $editURL = printf "%v/edit/%v/%v/{path}" $gitRepo .Branch .Dir -}}
|
|
{{- $reportURL = printf "%v/issues/new?%v" $gitRepo .IssueTpl -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
<div class="post-footer" id="post-footer">
|
|
<div class="post-info">
|
|
<div class="post-info-line">
|
|
<div class="post-info-mod">
|
|
{{- $updateTitle := dict "Date" ("2006-01-02 15:04:05" | .Lastmod.Format) | T "single.updatedOnDate" -}}
|
|
<span title="{{ $updateTitle }}">
|
|
{{- with .Lastmod | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
|
|
{{- dict "Date" . | T "single.updatedOnDate" -}}
|
|
{{- if $gitRepo -}}
|
|
{{- with $.GitInfo -}}
|
|
{{- $title := printf "%v
%v
Commit: %v [%v]
Author: %v<%v>
Date: %v" .Subject .Body .Hash .AbbreviatedHash .AuthorName .AuthorEmail (.AuthorDate | dateFormat "2006-01-02 15:04:05") -}}
|
|
{{- if ne .AuthorDate .CommitDate -}}
|
|
{{- $title = printf "%s
Commit Date: %v" $title (.CommitDate | dateFormat "2006-01-02 15:04:05") -}}
|
|
{{- end -}}
|
|
<a class="git-hash" href="{{ printf `%v/commit/%v` $gitRepo .Hash }}" rel="external nofollow noopener noreferrer" target="_blank" title="{{ $title | safeHTML }}">
|
|
{{- dict "Class" "fa-solid fa-hashtag" | partial "plugin/icon.html" -}}
|
|
{{- .AbbreviatedHash -}}
|
|
</a>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
</span>
|
|
</div>
|
|
{{- if not $params.password -}}
|
|
{{- with $params.license | string -}}
|
|
<div class="post-info-license">
|
|
<span>{{ . | safeHTML }}</span>
|
|
</div>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
</div>
|
|
{{- if not $params.password -}}
|
|
<div class="post-info-line">
|
|
<div class="post-info-md">
|
|
{{- $linkOptions := slice -}}
|
|
{{- if $params.LinkToMarkdown -}}
|
|
{{- with .OutputFormats.Get "markdown" -}}
|
|
{{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "single.readMarkdown") "Content" (T "single.readMarkdown") -}}
|
|
{{- $linkOptions = $linkOptions | append $options -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- if $params.LinkToSource | and $gitRepo -}}
|
|
{{- $link := replace $blobURL "{path}" $.File.Path -}}
|
|
{{- $sourceURL = $params.sourceURL | default (add $link "?plain=1") -}}
|
|
{{- $options := dict "Class" "link-to-source" "Destination" $sourceURL "Title" (T "single.viewSource") "Content" (T "single.viewSource") -}}
|
|
{{- $linkOptions = $linkOptions | append $options -}}
|
|
{{- end -}}
|
|
{{- if $params.LinkToEdit | and $gitRepo -}}
|
|
{{- $link := replace $editURL "{path}" $.File.Path -}}
|
|
{{- $editURL = $params.editURL | default $link -}}
|
|
{{- $options := dict "Class" "link-to-edit" "Destination" $editURL "Title" (T "single.editThisPage") "Content" (T "single.editThisPage") -}}
|
|
{{- $linkOptions = $linkOptions | append $options -}}
|
|
{{- end -}}
|
|
{{- if $params.LinkToReport | and $gitRepo -}}
|
|
{{- $link := replace $reportURL "{title}" ($.Title | urlquery) -}}
|
|
{{- $link = replace $link "{URL}" $.Permalink -}}
|
|
{{- $link = replace $link "{sourceURL}" $sourceURL -}}
|
|
{{- $options := dict "Class" "link-to-report" "Destination" $link "Title" (T "single.reportIssue") "Content" (T "single.reportIssue") -}}
|
|
{{- $linkOptions = $linkOptions | append $options -}}
|
|
{{- end -}}
|
|
{{- if $params.LinkToVscode | and hugo.IsServer | and (not $.File.IsContentAdapter) -}}
|
|
{{- $link := printf "vscode://file/%v" $.File.Filename -}}
|
|
{{- $options := dict "Class" "link-to-vscode" "Destination" $link "Title" (T "single.openInEditor") "Content" (T "single.openInEditor") -}}
|
|
{{- $linkOptions = $linkOptions | append $options -}}
|
|
{{- end -}}
|
|
{{- range $linkOptions -}}
|
|
{{- $commonOptions := dict "ExternalIcon" false -}}
|
|
<span>{{ partial "plugin/link.html" (. | merge $commonOptions) }}</span>
|
|
{{- end -}}
|
|
</div>
|
|
<div class="post-info-share">
|
|
<span>
|
|
{{- partial "plugin/share.html" . -}}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
{{- end -}}
|
|
</div>
|
|
|
|
<div class="post-info-more">
|
|
<section class="post-tags">
|
|
{{- $tagTerms := .GetTerms "tags" -}}
|
|
{{- if $tagTerms -}}
|
|
{{- dict "Class" "fa-solid fa-tags me-1" | partial "plugin/icon.html" -}}
|
|
{{- range $tagTerms -}}
|
|
{{- $href := partial "function/escapeurl.html" .RelPermalink -}}
|
|
{{- $title := printf "%v - %v" (T "tags") .LinkTitle -}}
|
|
<a href="{{ $href }}" class="post-tag" title="{{ $title }}">{{ .LinkTitle }}</a>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
</section>
|
|
<section>
|
|
{{- $relLangURL := relLangURL "" -}}
|
|
<span><a href="javascript:void(0);" onclick="window.history.back();">{{ T "single.back" }}</a></span> | <span><a href="{{ $relLangURL }}">{{ T "single.home" }}</a></span>
|
|
</section>
|
|
</div>
|
|
|
|
{{- $navigation := .Site.Params.navigation -}}
|
|
<div class="post-nav">
|
|
{{- $pages := .Site.Store.Get "mainSectionPages" -}}
|
|
{{- $prev := $pages.Prev . -}}
|
|
{{- $next := $pages.Next . -}}
|
|
{{- /* Show the post navigation in section pages */ -}}
|
|
{{- if $navigation.inSection -}}
|
|
{{- $prev = .PrevInSection -}}
|
|
{{- $next = .NextInSection -}}
|
|
{{- end -}}
|
|
{{- /* Reverse the next/previous post navigation order */ -}}
|
|
{{- if $navigation.reverse -}}
|
|
{{- $prev = $pages.Next . -}}
|
|
{{- $next = $pages.Prev . -}}
|
|
{{- end -}}
|
|
{{- with $prev -}}
|
|
{{- $capitalizeTitles := .Param "capitalizeTitles" -}}
|
|
<a href="{{ .RelPermalink }}" class="post-nav-item" rel="prev" title="{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}">
|
|
{{- dict "Class" "fa-solid fa-angle-left" | partial "plugin/icon.html" -}}
|
|
{{- cond $capitalizeTitles (title .LinkTitle) .LinkTitle -}}
|
|
</a>
|
|
{{- end -}}
|
|
{{ with $next }}
|
|
{{- $capitalizeTitles := .Param "capitalizeTitles" -}}
|
|
<a href="{{ .RelPermalink }}" class="post-nav-item" rel="next" title="{{ cond $capitalizeTitles (title .LinkTitle) .LinkTitle }}">
|
|
{{- cond $capitalizeTitles (title .LinkTitle) .LinkTitle -}}
|
|
{{- dict "Class" "fa-solid fa-angle-right" | partial "plugin/icon.html" -}}
|
|
</a>
|
|
{{- end -}}
|
|
</div>
|
|
</div>
|