diff --git a/exampleSite/content/shortcodes/siteparam.en.md b/exampleSite/content/shortcodes/siteparam.en.md new file mode 100644 index 0000000000..f431ffb904 --- /dev/null +++ b/exampleSite/content/shortcodes/siteparam.en.md @@ -0,0 +1,23 @@ +--- +title: Site param +description : "Get value of site params variables in your page." +--- + +`siteparam` shortcode is used to help you print values of site params. + +For instance, in this current site, the `editURL` variable is used in `config.toml` + +```toml +[params] + editURL = "https://github.com/matcornic/hugo-theme-learn/edit/master/exampleSite/content/" +``` + +Use the `siteparam` shortcode to display its value. + +``` +`editURL` Value : {{%/* siteparam "editURL" */%}} +``` + +is displayed as + +`editURL` Value : {{% siteparam "editURL" %}} \ No newline at end of file diff --git a/exampleSite/content/shortcodes/siteparam.fr.md b/exampleSite/content/shortcodes/siteparam.fr.md new file mode 100644 index 0000000000..508100b947 --- /dev/null +++ b/exampleSite/content/shortcodes/siteparam.fr.md @@ -0,0 +1,23 @@ +--- +title: Site param +description : "Afficher la valeur d'un paramètre global du site dans votre page" +--- + +Les shortcode `siteparam` est utilisé pour vous aider à afficher des valeurs provenant des paramètres globaux du site. + +Par exemple, dans ce site, le paramètre `editURL` est utilisé dans le fichier `config.toml` + +```toml +[params] + editURL = "https://github.com/matcornic/hugo-theme-learn/edit/master/exampleSite/content/" +``` + +Utilisez le shortcode `siteparam` pour affichier sa valeur. + +``` +Valeur de `editURL` : {{%/* siteparam "editURL" */%}} +``` + +s'affiche comme + +Valeur de `editURL` : {{% siteparam "editURL" %}} \ No newline at end of file diff --git a/layouts/shortcodes/siteparam.html b/layouts/shortcodes/siteparam.html new file mode 100644 index 0000000000..20cd2ca3b7 --- /dev/null +++ b/layouts/shortcodes/siteparam.html @@ -0,0 +1,7 @@ +{{- $paramName := (.Get 0) -}} +{{- $siteParams := .Site.Params -}} +{{- with $paramName -}} + {{- with $siteParams -}} + {{- index . (lower $paramName) -}} + {{- end -}} +{{- end -}} \ No newline at end of file