Add a JSON output format to single pages so they can be fetched async with JS
This commit is contained in:
parent
21cab74651
commit
3d7aa7a092
4 changed files with 40 additions and 36 deletions
|
@ -45,7 +45,7 @@ name = 'Eryn Wells'
|
|||
|
||||
[outputs]
|
||||
home = ['HTML', 'RSS']
|
||||
page = ['HTML']
|
||||
page = ['HTML', 'JSON']
|
||||
|
||||
[params]
|
||||
twitter = 'erynofwales'
|
||||
|
|
|
@ -3,41 +3,7 @@
|
|||
{{ end }}
|
||||
|
||||
{{ define "main" }}
|
||||
<article class="post-single">
|
||||
<header>
|
||||
{{ partial "development/draft_tag.html" . }}
|
||||
<div class="post-title">
|
||||
<h1>{{ .Title }}</h1>
|
||||
<div class="post-date"><time>{{ .Date | time.Format "January 2, 2006" }}</time></div>
|
||||
</div>
|
||||
</header>
|
||||
<section class="post-content">
|
||||
{{ .Content }}
|
||||
</section>
|
||||
|
||||
<!-- Post Tags -->
|
||||
{{ if .Params.tags }}
|
||||
<footer>
|
||||
<ul class="post-tags">
|
||||
{{ range .Params.tags }} {{ $href := print (absURL "tags/") (urlize .) }}
|
||||
<li><a href="{{ $href }}">{{ . }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</footer>
|
||||
{{ end }}
|
||||
|
||||
<!-- Post Nav -->
|
||||
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}<!---->
|
||||
{{ if and (gt (len $pages) 1) (in $pages . ) }}
|
||||
<nav class="post-nav">
|
||||
{{ with $pages.Next . }}
|
||||
<a class="prev" href="{{ .Permalink }}"><span>←</span><span>{{ .Name }}</span></a>
|
||||
{{ end }} {{ with $pages.Prev . }}
|
||||
<a class="next" href="{{ .Permalink }}"><span>{{ .Name }}</span><span>→</span></a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
</article>
|
||||
{{ partial "single_main.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "styles" }}
|
||||
|
|
4
layouts/_default/single.json
Normal file
4
layouts/_default/single.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"title": "{{ .Title }}",
|
||||
"main": "{{ partial `single_main.html` . }}"
|
||||
}
|
34
layouts/partials/single_main.html
Normal file
34
layouts/partials/single_main.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<article class="post-single">
|
||||
<header>
|
||||
{{ partial "development/draft_tag.html" . }}
|
||||
<div class="post-title">
|
||||
<h1>{{ .Title }}</h1>
|
||||
<div class="post-date"><time>{{ .Date | time.Format "January 2, 2006" }}</time></div>
|
||||
</div>
|
||||
</header>
|
||||
<section class="post-content">
|
||||
{{ .Content }}
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
{{ if .Params.tags }}
|
||||
<ul class="tags">
|
||||
{{ range .Params.tags }} {{ $href := print (absURL "tags/") (urlize .) }}
|
||||
<li><a href="{{ $href }}">{{ . }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||
{{ if and (gt (len $pages) 1) (in $pages . ) }}
|
||||
<nav class="post-nav">
|
||||
{{ with $pages.Prev . }}
|
||||
<a class="prev" href="{{ .Permalink }}"><span>←</span><span>{{ .Name }}</span></a>
|
||||
{{ end }}
|
||||
{{ with $pages.Next . }}
|
||||
<a class="next" href="{{ .Permalink }}"><span>{{ .Name }}</span><span>→</span></a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
</footer>
|
||||
</article>
|
Loading…
Add table
Add a link
Reference in a new issue