Skip to content

Commit 9eee5ea

Browse files
committed
feat: add json back in
1 parent dfa1136 commit 9eee5ea

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ pygmentsStyle = "vs"
88

99
[outputs]
1010
home = [ "RSS", "HTML"]
11+
page = ["HTML", "JSON"]
1112

1213
[outputFormats]
1314
[outputFormats.RSS]
1415
mediatype = "application/rss"
1516
baseName = "feed"
1617

18+
[outputFormats.JSON]
19+
mediatype = "application/json"
20+
baseName = "all"
21+
1722
[params]
1823
helpRoot = ""

content/blog/all.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
layout: feed
3+
outputs:
4+
- json
5+
---

layouts/_default/feed.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{ "blog": [
2+
{{ range $i, $e := (where .Site.Pages "Section" "blog") }}
3+
{{ if $i }}, {{ end }}
4+
{
5+
"title": "{{ .Title }}",
6+
"url": "{{ .RelPermalink }}",
7+
"date": "{{ .PublishDate.Format "2006-01-02" }}",
8+
"timestamp": {{ mul (.PublishDate.Unix) 1000 }}
9+
}
10+
{{ end }}
11+
],
12+
"help": [
13+
{{ range $i, $e := (where .Site.Pages "Section" "help") }}
14+
{{ if $i }}, {{ end }}
15+
{
16+
"title": "{{ .Title }}",
17+
"url": "{{ .RelPermalink }}",
18+
"category": "{{ .Params.Category }}"
19+
}
20+
{{ end }}
21+
]
22+
}

layouts/blog/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h1>The JS Bin Blog</h1>
44

55
<ul class="posts">
6-
{{ range .Data.Pages -}}
6+
{{ range where .Data.Pages "Layout" "!=" "feed" -}}
77
<li>
88
<span class="date">{{ .PublishDate.Format "2-Jan, 2006" }}</span>
99
<a href="{{ .Permalink }}">{{ .Title }}</a>

0 commit comments

Comments
 (0)