Last active
          November 6, 2017 17:23 
        
      - 
      
- 
        Save takakd/373f5d835a1d5d47e0bb136d02612bc6 to your computer and use it in GitHub Desktop. 
    sample-hugo-json
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "posts": [ | |
| {{ $list := .Data.Pages -}} | |
| {{ $len := (len $list) -}} | |
| {{ if lt 0 $len -}} | |
| {{ range first 1 $list -}} | |
| { | |
| "id" : {{ .Date.Format "20060102150405" | jsonify }}, | |
| "date" : {{ if .Date }}{{ .Date.Format "2006.01.02" | jsonify }}{{else}}""{{end}}, | |
| "title" : {{ .Title | jsonify }}, | |
| "summary" : {{ .Summary | jsonify }}, | |
| "body" : {{ .Content | jsonify }}, | |
| "tags" : {{ if .Params.tags }}{{ .Params.tags | jsonify }}{{ else }}[]{{ end }}, | |
| "some-ex-param" : {{ if .Params.someexparam }}{{ .Params.someexparam | jsonify }}{{ else }}false{{ end }} | |
| } | |
| {{- end -}} | |
| {{- end -}} | |
| {{- if lt 1 $len -}} | |
| {{- range after 1 $list -}} | |
| ,{ | |
| "id" : {{ .Date.Format "20060102150405" | jsonify }}, | |
| "date" : {{ if .Date }}{{ .Date.Format "2006.01.02" | jsonify }}{{else}}""{{end}}, | |
| "title" : {{ .Title | jsonify }}, | |
| "summary" : {{ .Summary | jsonify }}, | |
| "body" : {{ .Content | jsonify }}, | |
| "tags" : {{ if .Params.tags }}{{ .Params.tags | jsonify }}{{ else }}[]{{ end }}, | |
| "some-ex-param" : {{ if .Params.sameexparam }}{{ .Params.sameexparam | jsonify }}{{ else }}false{{ end }} | |
| } | |
| {{- end -}} | |
| {{- end }} | |
| ] | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment