Changes file extension
This commit is contained in:
parent
1712a885d9
commit
dafaeaabda
@ -1,22 +0,0 @@
|
||||
<!--
|
||||
-- Hugo shortcode for content pages to access data file properties or counts
|
||||
--
|
||||
-- @param file data file to reference in ./data
|
||||
-- @param key key in the data file object whose value you want
|
||||
-- @param type `count` to get a count of all items if an array, `value` to get the key's value
|
||||
--
|
||||
-- {{% getdata file="icons.json" key="address-book" type="value" %}}
|
||||
-->
|
||||
|
||||
{{- $file := .Get "file" -}}
|
||||
{{- $key := .Get "key" -}}
|
||||
{{- $type := .Get "type" -}}
|
||||
{{- if eq $type "count" -}}
|
||||
{{- if $key -}}
|
||||
{{- (index .Site.Data $file $key) | len -}}
|
||||
{{- else -}}
|
||||
{{- (index .Site.Data $file) | len -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- index .Site.Data $file $key -}}
|
||||
{{- end -}}
|
22
Shortcodes/getdata.html.go
Normal file
22
Shortcodes/getdata.html.go
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Hugo shortcode for content pages to access data file properties or counts
|
||||
*
|
||||
* @param file data file to reference in ./data
|
||||
* @param key key in the data file object whose value you want
|
||||
* @param type `count` to get a count of all items if an array, `value` to get the key's value
|
||||
*
|
||||
* {{% getdata file="icons.json" key="address-book" type="value" %}}
|
||||
*/
|
||||
|
||||
{{- $file := .Get "file" -}}
|
||||
{{- $key := .Get "key" -}}
|
||||
{{- $type := .Get "type" -}}
|
||||
{{- if eq $type "count" -}}
|
||||
{{- if $key -}}
|
||||
{{- (index .Site.Data $file $key) | len -}}
|
||||
{{- else -}}
|
||||
{{- (index .Site.Data $file) | len -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- index .Site.Data $file $key -}}
|
||||
{{- end -}}
|
Loading…
Reference in New Issue
Block a user