Skip to content

Commit

Permalink
Merge pull request #267 from dpordomingo/all-endpoint
Browse files Browse the repository at this point in the history
create a "/json/all" endpoint
  • Loading branch information
dpordomingo authored Nov 9, 2018
2 parents 52af98f + 8699c94 commit 831458c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ package-lock.json
.env.local
.DS_Store

# intellij
# code editors
.idea
.vscode

# python - used to prepare the content sometimes
**/.ipynb_checkpoints
3 changes: 3 additions & 0 deletions content/json/all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: all
---
13 changes: 11 additions & 2 deletions themes/hugo-steam-theme/layouts/json/single.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{{ $pages := index .Site.Taxonomies.categories .Title }}
{{ if eq .Title "all" }}
{{ $pages := dict "Pages" .Site.RegularPages }}
{{ $.Scratch.Set "pages" $pages }}
{{else}}
{{ $pages := index .Site.Taxonomies.categories .Title }}
{{ $.Scratch.Set "pages" $pages }}
{{end}}

{{ $pages := $.Scratch.Get "pages" }}

{{ $.Scratch.Set "first" true }}
{"Posts": [
{{ range $k, $post := sort $pages.Pages "Date" "desc" }}
{{if eq $post.Type "post"}}
{{if and (eq $post.Type "post") (ne .Params.author nil) }}
{{if $.Scratch.Get "first"}}
{{ $.Scratch.Set "first" false }}
{{ else }}
Expand Down

0 comments on commit 831458c

Please sign in to comment.