2020年7月16日木曜日

開発環境

Build Websites With Hugo: Fast Web Development With Markdown (Brian P. Hogan(著)、Pragmatic Bookshelf)のChapter 4(Working with Data)、Your Turn 5、6.の解答を求めてみる。

portfolio/themes/basic/layouts/projects/list.json

{
"projects": [
 {{- range $index, $page := (where .Site.RegularPages "Type" "in" "projects)")}}
 {{- if $index -}} , {{- end }}
 {
  "url": {{- .Permalink | jsonify }},
  "title": {{- .Title | jsonify }}
 }
 {{- end }}
]
}

http://localhost:1313/projects/index.json

{
"projects": [
 {
  "url":"http://localhost:1313/projects/awesomeco/",
  "title":"Awesomeco"
 },
 {
  "url":"http://localhost:1313/projects/jabberwocky/",
  "title":"Jabberwocky"
 }
]
}

portfolio/themes/basic/layouts/projects/list.json

{
"projects": [
 {{- range $index, $page := (where .Site.RegularPages "Type" "in" "projects)")}}
 {{- if $index -}} , {{- end }}
 {
  "url": {{ .Permalink | jsonify }},
  "title": {{ .Title | jsonify }}
 }
 {{- end }}
]
}

http://localhost:1313/projects/index.json

{
"projects": [
 {
  "url": "http://localhost:1313/projects/awesomeco/",
  "title": "Awesomeco"},
 {
  "url": "http://localhost:1313/projects/jabberwocky/",
  "title": "Jabberwocky"}
]
}

portfolio/themes/basic/layouts/projects/list.json

{
"projects": [
 {{- range $index, $page := (where .Site.RegularPages "Type" "in" "projects)")}}
 {{- if $index -}} , {{- end }}
 {
  "url": {{- .Permalink | jsonify -}},
  "title": {{- .Title | jsonify -}}
 }
 {{- end }}
]
}

http://localhost:1313/projects/index.json

{
"projects": [
{
 "url":"http://localhost:1313/projects/awesomeco/",
 "title":"Awesomeco"},
{
 "url":"http://localhost:1313/projects/jabberwocky/",
 "title":"Jabberwocky"}
]
}

portfolio/themes/basic/layouts/projects/list.json

{
"projects": [
 {{- range $index, $page := (where .Site.RegularPages "Type" "in" "projects)")}}
 {{- if $index -}} , {{- end }}
 {
  "url": {{ .Permalink | jsonify }},
  "title": {{ .Title | jsonify }},
  "content": {{ .Content | jsonify }},
  "$index": {{ $index | jsonify }},
  "$page": {{ $page | jsonify }}
 }
 {{- end }}
]
}

0 コメント:

コメントを投稿