diff --git a/content/works.md b/content/works.md index 2bea73e..126adbc 100644 --- a/content/works.md +++ b/content/works.md @@ -4,4 +4,4 @@ layout: single aliases: [stories] --- -{{< works >}} +{{< works corpus="works" collections="collections" creators="creators" >}} diff --git a/layouts/partials/nav.html b/layouts/_partials/nav.html similarity index 100% rename from layouts/partials/nav.html rename to layouts/_partials/nav.html diff --git a/layouts/partials/title/full.html b/layouts/_partials/title/full.html similarity index 100% rename from layouts/partials/title/full.html rename to layouts/_partials/title/full.html diff --git a/layouts/_partials/work.html b/layouts/_partials/work.html new file mode 100644 index 0000000..da2c30e --- /dev/null +++ b/layouts/_partials/work.html @@ -0,0 +1,36 @@ +{{- $work := .work }} +{{- $works := .works }} +{{- $creators := .creators }} +{{- /* This is really ugly, but alas, it is precisely what we need. */ -}} +
{{ $work.title }} by + {{ range $k, $author := $work.authors }} + {{- if index $creators $author }}{{ $author | markdownify }}{{ else }}{{ $author | markdownify }}{{ end }} + {{- if ne (add $k 1) ($work.authors | len) }}, {{ end }} + {{- end }} + {{- range $contributor := $work.contributors }}, + {{ if index $creators $contributor }}{{ $contributor | markdownify }}{{ else }}{{ $contributor | markdownify }}{{ end }} + (contributor) + {{- end }} +
+
+{{ $work.description | markdownify }} + +{{- $subworks := where $works "parent" "eq" $work.title }} +{{- if gt (len $subworks) 0 }} +

Associated works

+
+ {{- range $subwork := where $works "parent" "eq" $work.title }} + {{ partial "work.html" (dict "work" $subwork "works" $works "creators" $creators) }} + {{- end }} +
+{{- end }} +
diff --git a/layouts/_shortcodes/works.html b/layouts/_shortcodes/works.html index 94098c8..2a823cd 100644 --- a/layouts/_shortcodes/works.html +++ b/layouts/_shortcodes/works.html @@ -1,128 +1,22 @@ -{{- with hugo.Data.works }} -{{- $works := . }} +{{- $works := index hugo.Data (.Get "corpus") }} +{{- $collections := index hugo.Data (.Get "collections") }} +{{- $creators := index hugo.Data (.Get "creators") }}
{{- range $work := sort (where (where $works "collection" nil) "parent" nil) "title" "asc" }} -
{{ $work.title }} by - {{ range $k, $author := $work.authors }} - {{- if index hugo.Data.creators $author }}{{ $author | markdownify }}{{ else }}{{ $author | markdownify }}{{ end }} - {{- if ne (add $k 1) ($work.authors | len) }}, {{ end }} - {{- end }} - {{- range $contributor := $work.contributors }}, - {{ if index hugo.Data.creators $contributor }}{{ $contributor | markdownify }}{{ else }}{{ $contributor | markdownify }}{{ end }} - (contributor) - {{- end }} -
-
- {{ $work.description | markdownify }} -
    -
  • Type: {{ $work.type }}
  • -
  • Characters and dates: - {{- range $k, $v := $work.years }} - {{ index $work.characters $k }} — {{ $v }} - {{- if ne (add $k 1) ($work.years | len) }}, {{- end }} - {{- end }}
  • - {{- if $work.cw }}
  • CWs: {{ $work.cw }}
  • {{- end }} - {{- if $work.spoilers }}
  • Spoilers: {{ $work.spoilers | markdownify }}
  • {{- end }} -
- {{- $subworks := where $works "parent" "eq" $work.title }} - {{- if gt (len $subworks) 0 }} -

Associated works

-
- {{- range $subwork := where $works "parent" "eq" $work.title }} -
{{ $subwork.title }} by - {{ range $k, $author := $subwork.authors }} - {{- if index hugo.Data.creators $author }}{{ $author | markdownify }}{{ else }}{{ $author | markdownify }}{{ end }} - {{- if ne (add $k 1) ($work.authors | len) }}, {{ end }} - {{- end }} - {{- range $contributor := $subwork.contributors }}, - {{ if index hugo.Data.creators $contributor }}{{ $contributor | markdownify }}{{ else }}{{ $contributor | markdownify }}{{ end }} - (contributor) - {{- end }} -
-
- {{ $subwork.description | markdownify }} -
    -
  • Type: {{ $subwork.type }}
  • -
  • Characters and dates:
      - {{- range $k, $v := $subwork.years }} -
    • {{ index $subwork.characters $k }} — {{ $v }}
    • - {{- end }} -
  • - {{- if $subwork.cw }}
  • CWs: {{ $subwork.cw }}
  • {{- end }} - {{- if $subwork.spoilers }}
  • Spoilers: {{ $subwork.spoilers | markdownify }}
  • {{- end }} -
-
- {{- end }} -
- {{- end }} -
+ {{ partial "work.html" (dict "work" $work "works" $works "creators" $creators) }} {{- end }}
- {{- range $collection := hugo.Data.collections }} + {{- range $collection := $collections }}

{{ $collection.title }}

{{- range $work := where $works "collection" $collection.id }} -
{{ $work.title }} by - {{ range $k, $author := $work.authors }} - {{- if index hugo.Data.creators $author }}{{ $author | markdownify }}{{ else }}{{ $author | markdownify }}{{ end }} - {{- if ne (add $k 1) ($work.authors | len) }}, {{ end }} - {{- end }} - {{- range $contributor := $work.contributors }}, - {{ if index hugo.Data.creators $contributor }}{{ $contributor | markdownify }}{{ else }}{{ $contributor | markdownify }}{{ end }} - (contributor) - {{- end }} -
-
- {{ $work.description | markdownify }} -
    -
  • Type: {{ $work.type }}
  • -
  • Characters and dates: - {{- range $k, $v := $work.years }} - {{ index $work.characters $k }} — {{ $v }} - {{- if ne (add $k 1) ($work.years | len) }}, {{- end }} - {{- end }}
  • - {{- if $work.cw }}
  • CWs: {{ $work.cw }}
  • {{- end }} - {{- if $work.spoilers }}
  • Spoilers: {{ $work.spoilers | markdownify }}
  • {{- end }} -
- {{- $subworks := where $works "parent" "eq" $work.title }} - {{- if gt (len $subworks) 0 }} -

Associated works

-
- {{- range $subwork := where $works "parent" "eq" $work.title }} -
{{ $subwork.title }} by - {{ range $k, $author := $subwork.authors }} - {{- if index hugo.Data.creators $author }}{{ $author | markdownify }}{{ else }}{{ $author | markdownify }}{{ end }} - {{- if ne (add $k 1) ($work.authors | len) }}, {{ end }} - {{- end }} - {{- range $contributor := $subwork.contributors }}, - {{ if index hugo.Data.creators $contributor }}{{ $contributor | markdownify }}{{ else }}{{ $contributor | markdownify }}{{ end }} - (contributor) - {{- end }} -
-
- {{ $subwork.description | markdownify }} -
    -
  • Type: {{ $subwork.type }}
  • -
  • Characters and dates:
      - {{- range $k, $v := $subwork.years }} -
    • {{ index $subwork.characters $k }} — {{ $v }}
    • - {{- end }} -
  • - {{- if $subwork.cw }}
  • CWs: {{ $subwork.cw }}
  • {{- end }} - {{- if $subwork.spoilers }}
  • Spoilers: {{ $subwork.spoilers | markdownify }}
  • {{- end }} -
-
- {{- end }} -
- {{- end }} -
+ {{ partial "work.html" (dict "work" $work "works" $works "creators" $creators) }} {{- end }}
{{- end }}
-{{- end }}