From ac83849ff084d7ff1244d3618cd57e34bc2bba88 Mon Sep 17 00:00:00 2001 From: Regis Philibert Date: Tue, 19 May 2020 10:05:08 -0400 Subject: [PATCH] Improve README and comments --- README.md | 13 ++++++++++--- func/private/GetConfig.html | 4 +++- func/private/go.html | 3 +++ func/private/import.html | 10 +++++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 07bc7dc..f76f682 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # TND Netlify CMS Hugo Module -This module, in its phase 1, tends to simplify the construct of Netlify CMS lone config file and set up the Netlify CMS page wherever on the project. +This module try to simplify the construct of Netlify CMS lone config file. It also sets up the Netlify CMS page wherever on the project with minimal user intervention. -By using Hugo's Data files system to store and maintain reusable data objects which can be imported in the Netlify CMS configuration file as collections or fields, the module ease up on maintaining this wall of glyph that can quickly become your favorite CMS' `config.yml` +In order to be able to reuse data objects inside the lone NetlifyCMS `config.yaml` file, this module makes use of Hugo's data file to store said data objects and allow them to be recursively imported in the configuration file. ## The Import statement ``` @@ -11,6 +11,13 @@ import collection posts ``` ## Adding to your project + +1. Add this module's path to your `module.imports` config array +``` +module: + imports: + - path: github.com/theNewDynamic/hugo-module-tnd-netlify-cms +``` 1. Create a page where your Netlify CMS dasboard should live. 2. Add the `netlifycms` layout to it through Front Matter. 3. Add the `netlifycms_config` output format to it through Front Matter (alongside HTML): @@ -77,4 +84,4 @@ fields: label: "Title" name: "title" widget: "string" -``` +``` \ No newline at end of file diff --git a/func/private/GetConfig.html b/func/private/GetConfig.html index 1c906e9..8a35bca 100644 --- a/func/private/GetConfig.html +++ b/func/private/GetConfig.html @@ -5,7 +5,9 @@ @context Any - @access public + @return Map + + @access private @example - Go Template {{ with partial "tnd-netlifycms/private/GetConfig" . }} diff --git a/func/private/go.html b/func/private/go.html index 58905f4..3614c36 100644 --- a/func/private/go.html +++ b/func/private/go.html @@ -7,6 +7,9 @@ @access private + @use + - private/GetConfig + @example - Go Template {{- with partial "tnd-netlifycms/private/go" . -}} {{ . }} diff --git a/func/private/import.html b/func/private/import.html index 72f712f..96d0490 100644 --- a/func/private/import.html +++ b/func/private/import.html @@ -1,7 +1,7 @@ {{/* import - Reads a data object, look for an import statement and returns the correspondig data if present in data files. If not import found - returns the context data as is. + Reads a data object, look for an import statement and returns the correspondig data if present in data files. + If no import found returns the context data as is. @author @regisphilibert @@ -9,11 +9,11 @@ @return Any (.) - @access public + @access private @example - Go Template - {{ partial "path" context }} - {{ partialCached "path" context "variant" }} + {{ with partialCached "tnd-netlifycms/private/import" . . }} + {{ end }} */}} {{/* regex101.com > https://regex101.com/r/TFA6WQ/1 */}} {{ $pattern := "^import ([a-zA-Z]*) ([a-zA-Z/_-]*)$" }}