Skip to content

Commit

Permalink
Align structure with modern TND Modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
regisphilibert committed Aug 19, 2020
1 parent ad3badf commit d3e248a
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 11 deletions.
36 changes: 35 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# OS
.DS_Store
Thumbs.db

# IDEs
.buildpath
.project
.settings/
.build/
.idea/
nbproject/
public

# Vagrant
.vagrant/

# FE Setup
.bin/node_modules/
/node_modules/
/npm-debug.log.*
/npm-debug.log
/npm-debug.log*
/dist/
/src/client.config.json
/docs/

/junit.xml
partials/structure/stylesheet.html

# Hugo
hugo_stats.json
resources
.DS_Store
public

# Local Netlify folder
.netlify
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@ This module try to simplify the construct of Netlify CMS lone config file. It al

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
## Requirements

Requirements:
- Go 1.14
- Hugo 0.61.0

## Installation

If not already, [init](https://gohugo.io/hugo-modules/use-modules/#initialize-a-new-module) your project as Hugo Module:

```
$: hugo mod init {repo_url}
```

Configure your project's module to import this module:

```yaml
# config.yaml
module:
imports:
- path: github.com/theNewDynamic/hugo-module-tnd-netlifycms
```
## Usage
### The Import statement
```
import collection posts
| type | | file name
```
## Adding to your project
### Adding to your project


1. Add this module's path to your `module.imports` config array
Expand All @@ -31,7 +56,7 @@ outputs:
4. Add your Netlify config data in `data/netlifycms/config.yaml` and use (or not) `import` statements.
5. Add the data files matching your imports statements to the `data/netlifycms` dir under `/collections` and `/fields`

## Example of the base config data file
### Example of the base config data file

```yaml
# data/netlifycms/config.yaml
Expand All @@ -49,7 +74,7 @@ collections:
- import collection posts #--> data/netlifycms/collections/posts.yaml
```

## Example of a Collection data file
### Example of a Collection data file

```yaml
# data/netlifycms/collections/posts.yaml
Expand Down Expand Up @@ -77,7 +102,7 @@ fields:
}
```

## Example of a Field data file
### Example of a Field data file

```yaml
# data/netlifycms/fields/title.yaml
Expand All @@ -86,7 +111,7 @@ name: "title"
widget: "string"
```

## Module Settings
### Settings

Module settings are set as part of the shared `data/netlifycms/config.yaml` file under the reserved `tnd_netlifycms` map key.

Expand Down Expand Up @@ -126,3 +151,7 @@ In this example, we use the load the project's stylesheet for the Articles previ
CMS.registerPreviewTemplate("articles", PostPreview);
</script>
```
## theNewDynamic
This project is maintained and loved by [thenewDynamic](https://www.thenewdynamic.com).
4 changes: 2 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module:
mounts:
- source: templates
target: layouts/netlifycms
- source: func
target: layouts/partials/tnd-netlifycms
- source: partials
target: layouts/partials/tnd-netlifycms
- source: console
target: layouts/partials/tnd-netlifycms
outputFormats:
netlifycms_debug:
baseName: config
Expand Down
17 changes: 17 additions & 0 deletions console/err.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{/*
err
Emits a warning using the module's Header.

@author @regisphilibert

@context String

@access public

@example - Go Template
{{ partial "tnd-forms/warn" $message }}
*/}}
{{ $header := "TND Module NetlifyCMS" }}
{{ errorf "\n%s:\n%s" $header . }}

{{ return true }}
17 changes: 17 additions & 0 deletions console/warn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{/*
warn
Emits a warning using the module's Header.

@author @regisphilibert

@context String

@access public

@example - Go Template
{{ partial "tnd-forms/warn" $message }}
*/}}
{{ $header := "TND Module NetlifyCMS" }}
{{ warnf "\n%s:\n%s" $header . }}

{{ return true }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions func/private/import.html → partials/private/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
{{ with index . $file }}
{{ $return = . }}
{{ else }}
{{ warnf "We couldn't find %s/%s" $type $file }}
{{ partial "tnd-netlifycms/warn" (printf "We couldn't find %s/%s" $type $file) }}
{{ end }}
{{ else }}
{{ warnf "We couldn't find Type %s" $type }}
{{ partial "tnd-netlifycms/warn" (printf "We couldn't find Type %s" $type) }}
{{ end }}
{{ end }}
{{ end }}
Expand Down
File renamed without changes.

0 comments on commit d3e248a

Please sign in to comment.