{{/* APA-Style Citation Book Template : Author Surname, First Initial. Second Initial. (Year). Book title: Subtitle. Place of Publication: Publisher. [DOI] Journal Template: Author, I. N. (Year). Title of the article. Title of the Journal or Periodical, volume number(issue number), page numbers. [DOI] https://apastyle.apa.org/style-grammar-guidelines/references/examples */}} {{/* BEGIN author */}} {{- define "authorPart" }} {{- $authors := .author }} {{- if $authors -}} {{- $totalAuthors := len $authors -}} {{- range $authorIndex, $author := $authors -}} {{- if and (gt $totalAuthors 1) (lt (add $authorIndex 2) $totalAuthors) -}}, {{ end -}} {{ if eq $totalAuthors (add $authorIndex 2) -}} & {{ end -}}{{/* Last name has ampersand */}} {{- end -}} {{- else -}}{{/* Fallback if no authors are specified */}} ({{- i18n "apa_no_author_abbr" | default "n.a." | upper -}}). {{- end -}} {{- end -}}{{/* END author */}} {{/* BEGIN editor */}} {{- define "editorPart" }} {{- $editors := .editor }} {{- if $editors -}} {{- $totalEditors := len $editors -}} {{- range $editorIndex, $editor := $editors -}} {{- with $editor.family -}} {{ . }} {{- end -}} {{- with $editor.given -}}, {{ substr . 0 1 }}. {{- end -}}{{/* First letter (initial). */}} {{- with $editor.secondInitial -}} {{- substr . 0 1 -}}.{{- end -}} {{- if and (gt $totalEditors 1) (lt (add $editorIndex 2) $totalEditors) -}}, {{ end -}} {{ if eq $totalEditors (add $editorIndex 2) -}} & {{ end -}}{{/* Last name has ampersand */}} {{- end -}} {{- end -}} {{- end -}}{{/* END editor */}} {{/* BEGIN issued (year of publication) */}} {{- define "issuedPart" }} {{- if and (isset . "issued") (isset .issued "date-parts") -}} {{/* range of dates */}} () {{- else }} ({{ i18n "apa_no_date_abbr" | default "n.d." }}){{/* no date */}} {{- end }} {{- end }}{{/* END issued */}} {{/* BEGIN full issued (year, month day) */}} {{- define "issuedFullPart" }} {{- if and (isset . "issued") (isset .issued "date-parts") -}} () {{- else }} (s.d.){{/* no date */}} {{- end }} {{- end }}{{/* END issued */}} {{/* BEGIN DOI */}} {{- define "DOIPart" }} {{- if .DOI }} https://doi.org/{{- .DOI -}} {{- else if .URL }} {{- i18n "apa_retrieved_from" | default "Retrieved from" -}} {{ .URL }} {{- end -}} {{- end -}} {{- /* END DOI*/ -}} {{/* BEGIN ArchivalID */}} {{- define "ArchivalID" }} {{ if isset . "archive" -}} {{ i18n "archive_available_from" | default "Available from" }} {{- echoParam . "archive" -}}. {{- if isset . "archive_location" -}} ({{- echoParam . "archive_location" -}}){{- end }}. {{- end }} {{- end -}} {{- /* END ArchivalID */ -}} {{/* -------------------- BEGIN TYPES -------------------- */}} {{/* -------------------- BEGIN BOOK TYPE -------------------- */}} {{- if eq .type "book" -}} {{- if .author -}} {{- template "authorPart" . -}} {{- else if .editor -}}{{/* Display editors if no authors*/}} {{- template "editorPart" . -}} {{- end -}} {{- template "issuedPart" . }}. {{- if .title -}} {{/* italicize title */}} {{- .title | markdownify -}} {{- if .subtitle }}: {{ .subtitle | markdownify }}{{- end -}} {{/* close to avoid space */}} {{- end -}} {{- if or (isset . "edition") (isset . "page") }} ( {{- with .edition -}} {{ . }} {{- end -}} {{- if and (isset . "edition") (isset . "page") -}}, {{ end -}} {{- if isset . "page" -}} {{- end -}} ){{- end -}}. {{ if isset . "publisher-place" -}} {{- end -}} {{- with .publisher -}} {{- . -}} . {{- end }} {{- template "DOIPart" . -}} {{/* -------------------- END BOOK TYPE -------------------- */}} {{/* -------------------- BEGIN CHAPTER TYPE -------------------- */}} {{- else if eq .type "chapter" -}} {{ template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{- .title | markdownify -}} {{- if .subtitle }}: {{ .subtitle | markdownify }}{{- end -}} . {{- end -}} {{- if isset . "container-title" -}} {{- i18n "apa_in" | default "In" -}} {{- if .editor -}} {{- template "editorPart" . }} (Eds.), {{- end -}} {{/* italicize title */}} {{- echoParam . "container-title" -}} .{{/* close to avoid space */}} {{- end -}} {{- if or (isset . "edition") (isset . "page") -}} ( {{- if isset . "edition" -}} {{ .edition }} {{- if isset . "page" -}}, {{ end -}} {{- end -}} {{- if isset . "page" -}} pp. {{ replace .page "-" "–" }} {{- end -}} ){{- end -}}. {{ if isset . "publisher-place" -}} {{- end -}} {{- with .publisher -}} {{- . -}} . {{- end }} {{- template "DOIPart" . -}} {{/* -------------------- END CHAPTER TYPE -------------------- */}} {{/* -------------------- BEGIN ARTICLE TYPE -------------------- */}} {{- else if or (eq .type "article-journal") (eq .type "article") -}} {{- template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{- .title | markdownify -}} . {{- end -}} {{- if isset . "container-title" -}} {{- if .editor -}}{{/* Add `In` before name of Eds. and title*/}} {{- i18n "apa_in" | default "In" -}} {{- template "editorPart" . }} (Eds.), {{- end -}} {{/* italicize journal title */}} {{- echoParam . "container-title" -}} {{- if isset . "volume" -}} , {{- .volume -}} {{- end -}} {{- if isset . "issue" }}({{ .issue }}) {{- end -}} .{{- end -}} {{- if isset . "page" -}} {{ replace .page "-" "–" }}. {{- end -}} {{- template "DOIPart" . -}} {{/* -------------------- END ARTICLE TYPE -------------------- */}} {{/* -------------------- BEGIN WEBPAGE TYPE -------------------- */}} {{- else if eq .type "webpage" -}} {{- template "authorPart" . -}} {{- template "issuedFullPart" . -}}. {{- template "DOIPart" . -}} {{/* -------------------- END WEBPAGE TYPE -------------------- */}} {{/* -------------------- BEGIN BLOGPOST TYPE -------------------- */}} {{- else if eq .type "post-weblog" -}} {{- template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{- .title | markdownify -}} {{- end -}} {{- if isset . "genre" -}} [{{- echoParam . "genre" -}}] {{- end -}}.  {{- if isset . "container-title" -}} {{- if .editor -}}{{/* Add `In` before name of Eds. and title*/}} {{- i18n "apa_in" | default "In" -}} {{- template "editorPart" . }} (Eds.), {{- end -}} {{- echoParam . "container-title" -}} {{- if isset . "volume" -}} , {{- .volume -}} {{- end -}} {{- if isset . "issue" }}({{ .issue }}) {{- end -}} .{{- end -}} {{- if isset . "page" -}} {{ replace .page "-" "–" }}. {{- end -}} {{- template "DOIPart" . -}} {{/* -------------------- END BLOGPOST TYPE -------------------- */}} {{/* -------------------- BEGIN DEGREE WORK TYPE -------------------- */}} {{- else if eq .type "thesis" -}} {{- template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{- .title | markdownify -}} {{- end -}} {{- if isset . "genre" -}} ({{- echoParam . "genre" -}}) {{- end -}}. {{- if isset . "publisher-place" -}} {{- end -}} {{- with .publisher -}} {{- . -}}{{- end -}} {{ if isset . "publisher-place" -}}, {{- echoParam . "publisher-place" -}}. {{- end }} {{- template "ArchivalID" . -}} {{- template "DOIPart" . -}} {{/* -------------------- END DEGREE WORK TYPE -------------------- */}} {{/* -------------------- BEGIN REPORT TYPE -------------------- */}} {{- else if eq .type "report" -}} {{- template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{- .title | markdownify -}} {{- end -}} {{- if isset . "number" -}} ({{- echoParam . "number" -}}) {{- end -}}.  {{- if isset . "publisher-place" -}} {{- end -}} {{- with .publisher -}} {{- . -}}{{- end -}} {{ if isset . "publisher-place" -}}: {{- echoParam . "publisher-place" -}}. {{- end }} {{- template "ArchivalID" . -}} {{- template "DOIPart" . -}} {{/* -------------------- END REPORT TYPE -------------------- */}} {{/* -------------------- BEGIN DEFAULT APA -------------------- */}} {{- else -}} {{- template "authorPart" . }} {{- template "issuedPart" . }}. {{- if .title -}} {{/* italicize title */}} {{- .title | markdownify -}} {{- if .subtitle }}: {{ .subtitle | markdownify }}{{- end -}} {{/* close to avoid space */}} {{- end -}} {{- if isset . "edition" }} ( {{ .edition }} ){{- end -}}. {{ if isset . "publisher-place" -}} {{- end -}} {{- with .publisher -}} {{- . -}} . {{- end }} {{- template "DOIPart" . -}} {{- end -}} {{/* -------------------- END DEFAULT APA -------------------- */}} {{/* -------------------- END TYPES -------------------- */}}