Skip to content
Open
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
24 changes: 12 additions & 12 deletions layouts/shortcodes/cite.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{/*
{{- /*

This shortcode adds a linked Author Date citation reference to the text, and a
hover pop-up with the full citation text. It also adds the citation to a map
Expand All @@ -23,21 +23,21 @@
matter with the `bibFile` parameter, or in a leaf bundle, with "bib" in
the file name.

*/}}
*/ -}}

{{- $errorMissingValue := "1 or 2 values must be supplied with this shortcode. You provided %d params. The first is required and should match an ID in the CSL-JSON bibliography file, the second is optional, and should be a page number or range of page numbers. Example: {{< cite \"Faure 1909\" \"304\" >}}" -}}
{{- $errorMissingNamedParams := "You must at least provide a citation key. It is required and should match an ID in the CSL-JSON bibliography file. Example: {{< cite key=\"Faure 1909\" >}}" -}}

{{- $defaultErrString := "No matching key was found for `%s` in the references. Please make sure to provide an available ID in your `bib.json` file." -}}

{{/* Set variables*/}}
{{- /* Set variables*/ -}}
{{- $key := "" -}}
{{- $keys := slice "" ";" -}}
{{- $pages := slice "" ";" -}}
{{- $suppressAuthor := false -}}
{{- $keySeparator := ";" -}}

{{/* -------------------- Named/Positional Params -------------------- */}}
{{- /* -------------------- Named/Positional Params -------------------- */ -}}
{{- if .IsNamedParams }}
{{/* -------------------- a) Named -------------------- */}}
{{- if not (.Get "key") -}}
Expand Down Expand Up @@ -68,20 +68,20 @@
{{- $totalRefs := len $keys -}}


{{/* -------------------- BEGIN Citation style -------------------- */}}
{{- /* -------------------- BEGIN Citation style -------------------- */ -}}
{{- $citationStyle := "apa" }}
{{- if $.Site.Params.citationStyle }}
{{- if templates.Exists (printf "partials/bibliography/%s-style.html" $.Site.Params.citationStyle) }}
{{- $citationStyle = $.Site.Params.citationStyle }}
{{- end }}
{{- end }}
{{- $partialPath := string (printf "bibliography/%s-style.html" $citationStyle) }}
{{/* -------------------- END Citation style -------------------- */}}
{{- /* -------------------- END Citation style -------------------- */ -}}

{{/* -------------------- BEGIN Bibliography path -------------------- */}}
{{- /* -------------------- BEGIN Bibliography path -------------------- */ -}}
{{- $bibliographyPath := "" }}

{{/* Default: check for a JSON file in the leaf bundle. */}}
{{- /* Default: check for a JSON file in the leaf bundle. */ -}}
{{- $pageResource := $.Page.Resources.GetMatch "*bib*.json" -}}
{{- if $pageResource }}
{{- $constructedBibResource := printf "content/%s%s" $.Page.File.Dir $pageResource.Name }}
Expand All @@ -95,7 +95,7 @@
{{- $bibliographyPath = $.Page.Params.bibFile -}}
{{- end }}

{{- if gt (len $bibliographyPath) 0 -}}{{/* Begin Bibliography Loop */}}
{{- if gt (len $bibliographyPath) 0 -}}{{- /* Begin Bibliography Loop */ -}}
{{- $bibliography := getJSON $bibliographyPath -}}
{{- /* -------------------- END Bibliography path -------------------- */ -}}

Expand All @@ -110,10 +110,10 @@
{{- $currentRef := . -}}
<span class="hugo-cite-group">

{{/* Add to the collection of cited references */}}
{{- /* Add to the collection of cited references */ -}}
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}

{{/* Add to the collection of cited references */}}
{{- /* Add to the collection of cited references */ -}}
{{- $.Page.Scratch.SetInMap "citedBib" $key $currentRef -}}

<a href="#{{- $key | urlize -}}"><span class="visually-hidden">Citation: </span>
Expand Down Expand Up @@ -191,4 +191,4 @@

{{- end -}}
{{- /* END loop over keys*/ -}}
)</span>
)</span>{{- /* caution: to ensure correct trim, have no white space / line break after this comment! */ -}}