mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-11 12:11:45 +00:00
feat: standardize page resource links via links + hugoblox.ids
Deprecates legacy fields Closes #765 - Add `modules/blox-tailwind/data/link_types.yaml` registry for link types and derived URLs - Add `layouts/_partials/functions/build_links.html` to normalize links (front matter, local pdf/cite.bib, `hugoblox.ids`, `projects`, `slides`), de-dupe, and warn on deprecated fields - Refactor `page_links.html` and `page_links_div.html` to render normalized links; use `icon: "pack/name"`; add English label fallbacks and new i18n keys - Migrate academic-cv starter: replace `external_link`/`url_*`, add SlideShare demo links, clear unresolved `slides` references
This commit is contained in:
1 parent
fc3e52b68f
commit
ab52b86a3b
12 files changed
+599
-218
No files matched your search
@@ -0,0 +1,150 @@
|
||||
types:
|
||||
pdf:
|
||||
label_i18n: btn_pdf
|
||||
icon: hero/document-text
|
||||
preprint:
|
||||
label_i18n: btn_preprint
|
||||
icon: hero/document-text
|
||||
doi:
|
||||
label_i18n: btn_doi
|
||||
icon: hero/link
|
||||
code:
|
||||
label_i18n: btn_code
|
||||
icon: hero/code-bracket
|
||||
dataset:
|
||||
label_i18n: btn_dataset
|
||||
icon: hero/circle-stack
|
||||
model:
|
||||
label_i18n: btn_model
|
||||
icon: hero/link
|
||||
slides:
|
||||
label_i18n: btn_slides
|
||||
icon: hero/presentation-chart-bar
|
||||
video:
|
||||
label_i18n: btn_video
|
||||
icon: hero/video-camera
|
||||
poster:
|
||||
label_i18n: btn_poster
|
||||
icon: hero/photo
|
||||
project:
|
||||
label_i18n: btn_project
|
||||
icon: hero/link
|
||||
site:
|
||||
label_i18n: btn_site
|
||||
icon: hero/link
|
||||
source:
|
||||
label_i18n: btn_source
|
||||
icon: hero/document
|
||||
bibtex:
|
||||
label_i18n: btn_cite
|
||||
icon: hero/document-duplicate
|
||||
canonical:
|
||||
label_i18n: btn_canonical
|
||||
icon: hero/link
|
||||
crosspost:
|
||||
label_i18n: btn_crosspost
|
||||
icon: hero/link
|
||||
discussion:
|
||||
label_i18n: btn_discussion
|
||||
icon: hero/link
|
||||
event:
|
||||
label_i18n: btn_event
|
||||
icon: hero/calendar
|
||||
calendar:
|
||||
label_i18n: btn_calendar
|
||||
icon: hero/calendar
|
||||
registration:
|
||||
label_i18n: btn_registration
|
||||
icon: hero/link
|
||||
demo:
|
||||
label_i18n: btn_demo
|
||||
icon: hero/link
|
||||
|
||||
# Mapping of identifier keys under `hugoblox.ids` to derived links
|
||||
derived:
|
||||
doi:
|
||||
type: doi
|
||||
label_i18n: btn_doi
|
||||
icon: hero/link
|
||||
url_template: "https://doi.org/{id}"
|
||||
arxiv:
|
||||
type: preprint
|
||||
label_i18n: btn_preprint
|
||||
icon: hero/document-text
|
||||
url_template: "https://arxiv.org/abs/{id}"
|
||||
openreview:
|
||||
type: preprint
|
||||
label_i18n: btn_preprint
|
||||
icon: hero/document-text
|
||||
url_template: "https://openreview.net/forum?id={id}"
|
||||
acl_id:
|
||||
type: source
|
||||
label_i18n: btn_source
|
||||
icon: hero/document
|
||||
url_template: "https://aclanthology.org/{id}"
|
||||
hal:
|
||||
type: source
|
||||
label_i18n: btn_hal
|
||||
icon: hero/document
|
||||
url_template: "https://hal.science/{id}"
|
||||
dblp:
|
||||
type: source
|
||||
label_i18n: btn_dblp
|
||||
icon: hero/document
|
||||
url_template: "https://dblp.org/rec/{id}.html"
|
||||
isbn:
|
||||
type: source
|
||||
label_i18n: btn_isbn
|
||||
icon: hero/document
|
||||
url_template: "https://openlibrary.org/isbn/{id}"
|
||||
osf:
|
||||
type: source
|
||||
label_i18n: btn_osf
|
||||
icon: hero/document
|
||||
url_template: "https://osf.io/{id}"
|
||||
zenodo:
|
||||
type: source
|
||||
label_i18n: btn_zenodo
|
||||
icon: hero/document
|
||||
url_template: "https://zenodo.org/records/{id}"
|
||||
kaggle_dataset:
|
||||
type: dataset
|
||||
label_i18n: btn_kaggle
|
||||
icon: hero/circle-stack
|
||||
url_template: "https://www.kaggle.com/datasets/{id}"
|
||||
kaggle_competition:
|
||||
type: site
|
||||
label_i18n: btn_kaggle
|
||||
icon: hero/link
|
||||
url_template: "https://www.kaggle.com/competitions/{id}"
|
||||
openalex:
|
||||
type: source
|
||||
label_i18n: btn_openalex
|
||||
icon: hero/document
|
||||
url_template: "https://openalex.org/{id}"
|
||||
semanticscholar:
|
||||
type: source
|
||||
label_i18n: btn_semanticscholar
|
||||
icon: hero/document
|
||||
url_template: "https://www.semanticscholar.org/paper/{id}"
|
||||
pwc:
|
||||
type: site
|
||||
label_i18n: btn_pwc
|
||||
icon: hero/link
|
||||
url_template: "https://paperswithcode.com/paper/{id}"
|
||||
huggingface_model:
|
||||
type: model
|
||||
label_i18n: btn_model
|
||||
icon: hero/link
|
||||
url_template: "https://huggingface.co/{id}"
|
||||
huggingface_dataset:
|
||||
type: dataset
|
||||
label_i18n: btn_dataset
|
||||
icon: hero/circle-stack
|
||||
url_template: "https://huggingface.co/datasets/{id}"
|
||||
huggingface_space:
|
||||
type: demo
|
||||
label_i18n: btn_demo
|
||||
icon: hero/link
|
||||
url_template: "https://huggingface.co/spaces/{id}"
|
||||
|
||||
@@ -90,6 +90,46 @@
|
||||
- id: btn_source
|
||||
translation: Source Document
|
||||
|
||||
# New link types
|
||||
- id: btn_doi
|
||||
translation: DOI
|
||||
- id: btn_site
|
||||
translation: Site
|
||||
- id: btn_canonical
|
||||
translation: Canonical
|
||||
- id: btn_crosspost
|
||||
translation: Crosspost
|
||||
- id: btn_discussion
|
||||
translation: Discussion
|
||||
- id: btn_event
|
||||
translation: Event
|
||||
- id: btn_calendar
|
||||
translation: Calendar
|
||||
- id: btn_registration
|
||||
translation: Registration
|
||||
- id: btn_demo
|
||||
translation: Demo
|
||||
- id: btn_model
|
||||
translation: Model
|
||||
- id: btn_hal
|
||||
translation: HAL
|
||||
- id: btn_dblp
|
||||
translation: DBLP
|
||||
- id: btn_isbn
|
||||
translation: ISBN
|
||||
- id: btn_osf
|
||||
translation: OSF
|
||||
- id: btn_zenodo
|
||||
translation: Zenodo
|
||||
- id: btn_kaggle
|
||||
translation: Kaggle
|
||||
- id: btn_openalex
|
||||
translation: OpenAlex
|
||||
- id: btn_semanticscholar
|
||||
translation: Semantic Scholar
|
||||
- id: btn_pwc
|
||||
translation: Papers With Code
|
||||
|
||||
- id: btn_copy
|
||||
translation: Copy
|
||||
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
{{/*
|
||||
Hugo Blox Page Link Builder
|
||||
Build a normalized list of page links from:
|
||||
- Author-provided front matter `links` (array order respected)
|
||||
- Auto-detected resources (local PDF, cite.bib)
|
||||
- Derived identifiers from `hugoblox.ids`
|
||||
- Associated internal `projects` references
|
||||
|
||||
Inputs: dict { "page": . , "is_list": 0|1 }
|
||||
Output: slice of dicts with fields: type, url, icon, labelKey, label, contexts, rel
|
||||
|
||||
Deprecations handled with warnings and mapped:
|
||||
- external_link -> type: site
|
||||
- url_pdf -> type: pdf
|
||||
- url_preprint -> type: preprint
|
||||
- url_code -> type: code
|
||||
- url_dataset -> type: dataset
|
||||
- url_poster -> type: poster
|
||||
- url_project -> type: project
|
||||
- url_slides -> type: slides
|
||||
- url_source -> type: source
|
||||
- url_video -> type: video
|
||||
*/}}
|
||||
|
||||
{{ $page := .page }}
|
||||
{{ $is_list := .is_list }}
|
||||
|
||||
{{ $types := site.Data.link_types.types }}
|
||||
{{ $derived := site.Data.link_types.derived }}
|
||||
|
||||
{{ $links := slice }}
|
||||
{{ $seen := newScratch }}
|
||||
{{ $seen.Set "set" (dict) }}
|
||||
|
||||
{{/* 1) Author-provided links (array order) */}}
|
||||
{{ with $page.Params.links }}
|
||||
{{ range . }}
|
||||
{{/* Support new fields: type, url, icon (pack/name), label, contexts, rel; legacy: name */}}
|
||||
{{ $type := .type | default "custom" }}
|
||||
{{ $url := .url | default "" }}
|
||||
{{/* Optional provider+id derivation for common platforms */}}
|
||||
{{ if and (not $url) .id }}
|
||||
{{ if eq $type "doi" }}
|
||||
{{ $url = replace (index (index $derived "doi") "url_template") "{id}" (printf "%v" .id) }}
|
||||
{{ else if and (eq $type "preprint") (eq .provider "arxiv") }}
|
||||
{{ $url = replace (index (index $derived "arxiv") "url_template") "{id}" (printf "%v" .id) }}
|
||||
{{ else if and (eq $type "preprint") (eq .provider "openreview") }}
|
||||
{{ $url = replace (index (index $derived "openreview") "url_template") "{id}" (printf "%v" .id) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $typeF := $type }}
|
||||
{{ $urlF := $url }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (.icon | default (index (index $types $typeF) "icon") | default "hero/link")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"label" (.label | default .name)
|
||||
"contexts" (.contexts | default (slice "list" "page"))
|
||||
"rel" .rel
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* 2) Associated projects (internal) */}}
|
||||
{{ with $page.Params.projects }}
|
||||
{{ range . }}
|
||||
{{ with (site.GetPage (printf "project/%s" .)) }}
|
||||
{{ $typeF := "project" }}
|
||||
{{ $urlF := .RelPermalink }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* 2b) Slides relation parameter (legacy but common) */}}
|
||||
{{ with $page.Params.slides }}
|
||||
{{ with (site.GetPage (printf "slides/%s" .)) }}
|
||||
{{ $typeF := "slides" }}
|
||||
{{ $urlF := .RelPermalink }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ warnf "`slides` relation could not resolve to a page for %s" $page.File.Path }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* 3) Auto-detected resources (local PDF by content basename, cite.bib) */}}
|
||||
{{ with $page.File.ContentBaseName }}
|
||||
{{ with ($page.Resources.GetMatch (printf "%s.pdf" .)) }}
|
||||
{{ $typeF := "pdf" }}
|
||||
{{ $urlF := .RelPermalink }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with ($page.Resources.GetMatch "cite.bib") }}
|
||||
{{ $typeF := "bibtex" }}
|
||||
{{ $urlF := .RelPermalink }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* 4) Derived links from identifiers under `hugoblox.ids` */}}
|
||||
{{ with $page.Params.hugoblox }}
|
||||
{{ with .ids }}
|
||||
{{ range $key, $val := . }}
|
||||
{{ with (index $derived $key) }}
|
||||
{{ $der := . }}
|
||||
{{ $typeF := index $der "type" }}
|
||||
{{ $urlF := replace (index $der "url_template") "{id}" (printf "%v" $val) }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index $der "icon")
|
||||
"labelKey" (index $der "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* 5) Legacy fields -> deprecation warnings and normalized items */}}
|
||||
{{/* external_link */}}
|
||||
{{ with $page.Params.external_link }}
|
||||
{{ warnf "`external_link` is deprecated. Use `links: [{type: site, url: ...}]` in %s" $page.File.Path }}
|
||||
{{ $typeF := "site" }}
|
||||
{{ $urlF := . }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* top-level doi */}}
|
||||
{{ with $page.Params.doi }}
|
||||
{{ warnf "Top-level `doi` is deprecated. Use `hugoblox.ids: { doi: ... }` in %s" $page.File.Path }}
|
||||
{{ with (index $derived "doi") }}
|
||||
{{ $der := . }}
|
||||
{{ $typeF := index $der "type" }}
|
||||
{{ $urlF := replace (index $der "url_template") "{id}" (printf "%v" $page.Params.doi) }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index $der "icon")
|
||||
"labelKey" (index $der "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $typeF := "doi" }}
|
||||
{{ $urlF := printf "https://doi.org/%v" $page.Params.doi }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* Map of legacy url_* to new types */}}
|
||||
{{ $legacy := dict
|
||||
"url_pdf" "pdf"
|
||||
"url_preprint" "preprint"
|
||||
"url_code" "code"
|
||||
"url_dataset" "dataset"
|
||||
"url_poster" "poster"
|
||||
"url_project" "project"
|
||||
"url_slides" "slides"
|
||||
"url_source" "source"
|
||||
"url_video" "video"
|
||||
}}
|
||||
{{ range $legacyKey, $legacyType := $legacy }}
|
||||
{{ with index $page.Params $legacyKey }}
|
||||
{{ warnf "`%s` is deprecated. Use `links: [{type: %s, url: ...}]` in %s" $legacyKey $legacyType $page.File.Path }}
|
||||
{{/* Resolve relative resource if present */}}
|
||||
{{ $u := . }}
|
||||
{{ with ($page.Resources.GetMatch $u) }}
|
||||
{{ $u = .RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $u = $u | relURL }}
|
||||
{{ end }}
|
||||
{{ $typeF := $legacyType }}
|
||||
{{ $urlF := $u }}
|
||||
{{ $keyF := printf "%s::%s" $typeF $urlF }}
|
||||
{{ if not ($seen.Get (printf "set.%s" $keyF)) }}
|
||||
{{ $seen.SetInMap "set" $keyF true }}
|
||||
{{ $links = $links | append (dict
|
||||
"type" $typeF
|
||||
"url" $urlF
|
||||
"icon" (index (index $types $typeF) "icon")
|
||||
"labelKey" (index (index $types $typeF) "label_i18n")
|
||||
"contexts" (slice "list" "page")
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{- return $links -}}
|
||||
@@ -1,167 +1,74 @@
|
||||
{{ $is_list := .is_list }}
|
||||
{{ $page := .page }}
|
||||
{{ $link := "" }}
|
||||
|
||||
{{/* ***** TODO: Deprecate `url_preprint` in favour of `url_pdf` given there's now a dedicated "Preprint" pub. type. ***** */}}
|
||||
{{ with $page.Params.url_preprint }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ i18n "btn_preprint" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ $pdf := "" }}
|
||||
{{ $resource := $page.Resources.GetMatch (printf "%s.pdf" $page.File.ContentBaseName) }}
|
||||
{{ with $resource }}
|
||||
{{ $pdf = .RelPermalink }}
|
||||
{{ else }}
|
||||
{{ if $page.Params.url_pdf }}
|
||||
{{ $pdf = $page.Params.url_pdf | relURL }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* Build normalized links (new API) */}}
|
||||
{{ $built := partial "functions/build_links" (dict "page" $page "is_list" $is_list) }}
|
||||
|
||||
{{ with $pdf }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ . }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "document-text" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_pdf" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ $resource := $page.Resources.GetMatch "cite.bib" }}
|
||||
{{ with $resource }}
|
||||
<button class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}} js-cite-clipboard cursor-pointer" type="button" data-filename="{{ .RelPermalink }}">
|
||||
{{ partial "functions/get_icon" (dict "name" "document-duplicate" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
<span>{{ i18n "btn_cite" }}</span>
|
||||
</button>
|
||||
{{ end }}
|
||||
{{ with $page.Params.url_code }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "code-bracket" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_code" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ with $page.Params.url_dataset }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "circle-stack" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_dataset" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ if $page.Params.projects }}
|
||||
{{ range $page.Params.projects }}
|
||||
{{ with (site.GetPage (printf "project/%s" .)) }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ .RelPermalink }}">
|
||||
{{ i18n "btn_project" }}
|
||||
</a>
|
||||
{{ else }}
|
||||
{{/* errorf "The `projects` parameter in `content/%s` references a project file, `content/project/%s`, which cannot be found. Please either set `projects = []` or fix the reference." $page.File.Path . */}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ with $page.Params.url_project }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ . }}" target="_blank" rel="noopener">
|
||||
{{ i18n "btn_project" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with $page.Params.url_poster }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "photo" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_poster" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ if $page.Params.slides }}
|
||||
{{ with (site.GetPage (printf "slides/%s" $page.Params.slides)) }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ .RelPermalink }}" target="_blank">
|
||||
{{ partial "functions/get_icon" (dict "name" "presentation-chart-bar" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_slides" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ with $page.Params.url_slides }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "presentation-chart-bar" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_slides" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with $page.Params.url_video }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "video-camera" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_video" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ with $page.Params.url_source }}
|
||||
{{ $resource := $page.Resources.GetMatch . }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $link = . | relURL }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener">
|
||||
{{ partial "functions/get_icon" (dict "name" "document" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ i18n "btn_source" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ with $page.Params.doi }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="https://doi.org/{{ . }}" target="_blank" rel="noopener">
|
||||
DOI
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ range $page.Params.links }}
|
||||
{{ $pack := or .icon_pack "fas" }}
|
||||
{{ $pack_prefix := $pack }}
|
||||
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
|
||||
{{ $pack_prefix = "fa" }}
|
||||
{{ end }}
|
||||
{{ $link := .url | default "" }}
|
||||
{{ $scheme := (urls.Parse $link).Scheme }}
|
||||
{{ $target := "" }}
|
||||
{{ if not $scheme }}
|
||||
{{ $resource := $page.Resources.GetMatch $link }}
|
||||
{{ if $resource }}
|
||||
{{ $link = $resource.RelPermalink }}
|
||||
{{ $ctx := cond $is_list "list" "page" }}
|
||||
|
||||
{{/* English fallbacks if i18n key is missing in a locale */}}
|
||||
{{ $fallbackByKey := dict
|
||||
"btn_pdf" "PDF"
|
||||
"btn_preprint" "Preprint"
|
||||
"btn_doi" "DOI"
|
||||
"btn_code" "Code"
|
||||
"btn_dataset" "Dataset"
|
||||
"btn_model" "Model"
|
||||
"btn_slides" "Slides"
|
||||
"btn_video" "Video"
|
||||
"btn_poster" "Poster"
|
||||
"btn_project" "Project"
|
||||
"btn_site" "Site"
|
||||
"btn_source" "Source Document"
|
||||
"btn_canonical" "Canonical"
|
||||
"btn_crosspost" "Crosspost"
|
||||
"btn_discussion" "Discussion"
|
||||
"btn_event" "Event"
|
||||
"btn_calendar" "Calendar"
|
||||
"btn_registration" "Registration"
|
||||
"btn_demo" "Demo"
|
||||
"btn_cite" "Cite"
|
||||
}}
|
||||
|
||||
{{ range $built }}
|
||||
{{ if in .contexts $ctx }}
|
||||
{{ $url := .url | default "" }}
|
||||
{{ $scheme := (urls.Parse $url).Scheme }}
|
||||
{{ $target := "" }}
|
||||
{{ $rel := slice }}
|
||||
{{ with .rel }}{{ $rel = . }}{{ end }}
|
||||
{{ if not $scheme }}
|
||||
{{ with ($page.Resources.GetMatch $url) }}
|
||||
{{ $url = .RelPermalink }}
|
||||
{{ else }}
|
||||
{{ $url = $url | relURL }}
|
||||
{{ end }}
|
||||
{{ else if in (slice "http" "https") $scheme }}
|
||||
{{ $target = "target=\"_blank\"" }}
|
||||
{{ $rel = $rel | append "noopener" }}
|
||||
{{ end }}
|
||||
|
||||
{{ $classes := printf "hb-attachment-link %s" (cond $is_list "hb-attachment-link-small" "hb-attachment-link-large") }}
|
||||
{{ $label := .label }}
|
||||
{{ with .labelKey }}
|
||||
{{ if not $label }}
|
||||
{{ $label = (i18n .) | default (index $fallbackByKey .) | default "Link" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if not $label }}
|
||||
{{ $label = "Link" }}
|
||||
{{ end }}
|
||||
|
||||
{{ if eq .type "bibtex" }}
|
||||
<button class="{{ $classes }} js-cite-clipboard cursor-pointer" type="button" data-filename="{{ $url }}">
|
||||
{{ partial "functions/get_icon" (dict "name" (.icon | default "hero/document-duplicate") "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
<span>{{ $label }}</span>
|
||||
</button>
|
||||
{{ else }}
|
||||
{{ $link = $link | relURL }}
|
||||
<a class="{{ $classes }}" href="{{ $url | safeURL }}" {{ $target | safeHTMLAttr }} {{ with $rel }}rel="{{ delimit . " " }}"{{ end }}>
|
||||
{{ partial "functions/get_icon" (dict "name" (.icon | default "hero/link") "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ $label }}
|
||||
</a>
|
||||
{{ end }}
|
||||
{{ else if in (slice "http" "https") $scheme }}
|
||||
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
|
||||
{{ end }}
|
||||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-link-small{{else}}hb-attachment-link-large{{end}}" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
|
||||
{{ partial "functions/get_icon" (dict "name" "link" "attributes" "style=\"height: 1em\" class='inline-block'") }}
|
||||
{{ if .icon }}<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} {{if .name}}mr-1{{end}}"></i>{{end}}
|
||||
{{- with .name }}{{ . | safeHTML }}{{ end -}}
|
||||
</a>
|
||||
{{ end }}
|
||||
@@ -1,12 +1,8 @@
|
||||
{{/* Div wrapper around page links. */}}
|
||||
{{/* The wrapper is hidden when the page has no link buttons. */}}
|
||||
{{/* Div wrapper around page links. Hidden if page has no links. */}}
|
||||
|
||||
{{ $has_attachments := partial "functions/has_attachments" . }}
|
||||
{{ if $has_attachments | or .Params.external_link }}
|
||||
{{ $built := partial "functions/build_links" (dict "page" . "is_list" 0) }}
|
||||
{{ if gt (len $built) 0 }}
|
||||
<div class="">
|
||||
{{ with .Params.external_link }}
|
||||
<a class="btn btn-outline-primary my-1" href="{{ . }}" target="_blank" rel="noopener">{{ i18n "open_project_site" }}</a>
|
||||
{{ end }}
|
||||
{{ partial "page_links" (dict "page" . "is_list" 0) }}
|
||||
</div>
|
||||
{{ end }}
|
||||
Reference in new issue
Block a user