Skip to content

Commit 96a6fc9

Browse files
authored
feat: add the data function to fetch data from page data or site data (#40)
1 parent ad743a1 commit 96a6fc9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- $v := false }}
2+
{{- $key := replace .key "." "/" | printf "%s.{toml,yaml,yml,json}" }}
3+
{{- with .page.Resources.GetMatch $key }}
4+
{{- $v = .Content | transform.Unmarshal }}
5+
{{- else }}
6+
{{- $data := site.Data }}
7+
{{- $keys := split .key "." }}
8+
{{- range $keys }}
9+
{{- with index $data . }}
10+
{{- $data = . }}
11+
{{- $v = . }}
12+
{{- end }}
13+
{{- end }}
14+
{{- end }}
15+
{{- return $v -}}

0 commit comments

Comments
 (0)