Skip to content

Instantly share code, notes, and snippets.

@dkua
Created December 15, 2016 21:03
Show Gist options
  • Save dkua/b5b7c7a21b41ea91720420c6356d0408 to your computer and use it in GitHub Desktop.
Save dkua/b5b7c7a21b41ea91720420c6356d0408 to your computer and use it in GitHub Desktop.
<!-- Bibliography data -->
{{ $numParams := len .Params }}
{{ if eq $numParams 0 }}
{{ if isset .Page.Params "bibliography" }}
{{ $.Scratch.Set "bib_source" .Page.Params.bibliography }}
{{ end }}
{{ if isset .Page.Params "bibliography_ignore" }}
{{ $.Scratch.Set "bib_ignore" .Page.Params.bibliography_ignore }}
{{ end }}
{{ else if eq $numParams 1 }}
{{ $.Scratch.Set "bib_source" (.Get 0) }}
{{ else if eq $numParams 2 }}
{{ $.Scratch.Set "bib_source" (.Get 0) }}
{{ $.Scratch.Set "bib_ignore" (.Get 1) }}
{{ end }}
{{ $src := (index .Site.Data.bibliographies ($.Scratch.Get "bib_source")) }}
{{ $ignore := (split ($.Scratch.Get "bib_ignore") ",") }}
{{ $.Scratch.Set "length" (len $src) }}
<div class="bibliography">
<ul>
{{ range $index, $ref := (where $src "id" "not in" $ignore) }}
{{ $.Scratch.Set "index" $index }}
{{ $.Scratch.Set "ref" $ref }}
{{ partial "bibliography/citation" $ }}
{{ end }}
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment