diff --git a/src/ssgs/eleventy.js b/src/ssgs/eleventy.js index 0d813dd..19c9f8a 100644 --- a/src/ssgs/eleventy.js +++ b/src/ssgs/eleventy.js @@ -72,6 +72,9 @@ export default class Eleventy extends Ssg { if (path === '_data' || path.endsWith('/_data')) { collectionConfig.disable_url = true; + collectionConfig.disable_add = true; + collectionConfig.disable_add_folder = true; + collectionConfig.disable_file_actions = true; } return collectionConfig; diff --git a/src/ssgs/hugo.js b/src/ssgs/hugo.js index 972f2e2..a38d91d 100644 --- a/src/ssgs/hugo.js +++ b/src/ssgs/hugo.js @@ -82,6 +82,9 @@ export default class Hugo extends Ssg { if (path === dataPath || path.endsWith(`/${dataPath}`)) { collectionConfig.disable_url = true; + collectionConfig.disable_add = true; + collectionConfig.disable_add_folder = true; + collectionConfig.disable_file_actions = true; } return collectionConfig; diff --git a/src/ssgs/jekyll.js b/src/ssgs/jekyll.js index b1dcec5..f8778e1 100644 --- a/src/ssgs/jekyll.js +++ b/src/ssgs/jekyll.js @@ -62,6 +62,31 @@ function toPostsKey(key) { return key.replace('drafts', 'posts'); } +/** + * Generates posts _inputs configuration. + * + * @param collectionKey {string} The posts key. + * @returns {Record} + */ +function generatePostsInputs(collectionKey) { + return { + categories: { + type: 'multiselect', + options: { + values: `collections.${collectionKey}[*].categories`, + allow_create: true, + }, + }, + tags: { + type: 'multiselect', + options: { + values: `collections.${collectionKey}[*].tags`, + allow_create: true, + }, + }, + }; +} + /** * Gets `collections` from Jekyll configuration in a standard format. * @@ -137,7 +162,12 @@ export default class Jekyll extends Ssg { key === 'drafts' || key.endsWith('_drafts'); - if (key === 'data' || (!options.collection?.output && !isKnownOutputCollection)) { + if (key === 'data') { + collectionConfig.disable_url = true; + collectionConfig.disable_add = true; + collectionConfig.disable_add_folder = true; + collectionConfig.disable_file_actions = true; + } else if (!options.collection?.output && !isKnownOutputCollection) { collectionConfig.disable_url = true; } @@ -150,15 +180,21 @@ export default class Jekyll extends Ssg { path: '[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]', }; + collectionConfig._inputs = generatePostsInputs(key); + collectionConfig.add_options ||= [ { name: `Add ${collectionConfig.singular_name || 'Post'}` }, { name: 'Add Draft', collection: toDraftsKey(key) }, ]; } else if (isDraftsPath(collectionConfig.path)) { + const postsKey = toPostsKey(key); + collectionConfig.create ||= { path: '', // TODO: this should not be required if publish_to is set - publish_to: toPostsKey(key), + publish_to: postsKey, }; + + collectionConfig._inputs = generatePostsInputs(postsKey); } return collectionConfig; diff --git a/toolproof_tests/eleventy/base.toolproof.yml b/toolproof_tests/eleventy/base.toolproof.yml index 4ac37e7..36730b5 100644 --- a/toolproof_tests/eleventy/base.toolproof.yml +++ b/toolproof_tests/eleventy/base.toolproof.yml @@ -28,7 +28,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/eleventy/subfolder-source.toolproof.yml b/toolproof_tests/eleventy/subfolder-source.toolproof.yml index 91235e5..142c1a3 100644 --- a/toolproof_tests/eleventy/subfolder-source.toolproof.yml +++ b/toolproof_tests/eleventy/subfolder-source.toolproof.yml @@ -29,7 +29,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/eleventy/templates-in-source.toolproof.yml b/toolproof_tests/eleventy/templates-in-source.toolproof.yml index 7266bc2..479beb0 100644 --- a/toolproof_tests/eleventy/templates-in-source.toolproof.yml +++ b/toolproof_tests/eleventy/templates-in-source.toolproof.yml @@ -33,7 +33,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/hugo/base.toolproof.yml b/toolproof_tests/hugo/base.toolproof.yml index 3fd1a2d..7ea5a0c 100644 --- a/toolproof_tests/hugo/base.toolproof.yml +++ b/toolproof_tests/hugo/base.toolproof.yml @@ -35,7 +35,10 @@ steps: ╎ "glob": [ ╎ "!_index.md" ╎ ], - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/hugo/data-dir.toolproof.yml b/toolproof_tests/hugo/data-dir.toolproof.yml index 7e3a866..f9099ab 100644 --- a/toolproof_tests/hugo/data-dir.toolproof.yml +++ b/toolproof_tests/hugo/data-dir.toolproof.yml @@ -37,7 +37,10 @@ steps: ╎ "glob": [ ╎ "!_index.md" ╎ ], - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/hugo/data-only.toolproof.yml b/toolproof_tests/hugo/data-only.toolproof.yml index 9dd2bb3..e1aa318 100644 --- a/toolproof_tests/hugo/data-only.toolproof.yml +++ b/toolproof_tests/hugo/data-only.toolproof.yml @@ -18,7 +18,10 @@ steps: ╎ "glob": [ ╎ "!_index.md" ╎ ], - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/hugo/example-site-only.toolproof.yml b/toolproof_tests/hugo/example-site-only.toolproof.yml index 732118e..10f1e8d 100644 --- a/toolproof_tests/hugo/example-site-only.toolproof.yml +++ b/toolproof_tests/hugo/example-site-only.toolproof.yml @@ -34,7 +34,10 @@ steps: ╎ "glob": [ ╎ "!_index.md" ╎ ], - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/hugo/subfolder-source.toolproof.yml b/toolproof_tests/hugo/subfolder-source.toolproof.yml index 16e5479..64632c5 100644 --- a/toolproof_tests/hugo/subfolder-source.toolproof.yml +++ b/toolproof_tests/hugo/subfolder-source.toolproof.yml @@ -37,7 +37,10 @@ steps: ╎ "glob": [ ╎ "!_index.md" ╎ ], - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/jekyll/base.toolproof.yml b/toolproof_tests/jekyll/base.toolproof.yml index e81b8fa..7466c21 100644 --- a/toolproof_tests/jekyll/base.toolproof.yml +++ b/toolproof_tests/jekyll/base.toolproof.yml @@ -90,6 +90,22 @@ steps: ╎ "create": { ╎ "path": "", ╎ "publish_to": "posts" + ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } ╎ } ╎ }, ╎ "news_drafts": { @@ -99,6 +115,22 @@ steps: ╎ "create": { ╎ "path": "", ╎ "publish_to": "news_posts" + ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } ╎ } ╎ }, ╎ "news_posts": { @@ -108,6 +140,22 @@ steps: ╎ "create": { ╎ "path": "[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]" ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } + ╎ }, ╎ "add_options": [ ╎ { ╎ "name": "Add Post" @@ -125,6 +173,22 @@ steps: ╎ "create": { ╎ "path": "[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]" ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } + ╎ }, ╎ "add_options": [ ╎ { ╎ "name": "Add Post" @@ -145,7 +209,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ }, ╎ "data_animals": { ╎ "path": "_data/animals", diff --git a/toolproof_tests/jekyll/default-collections.toolproof.yml b/toolproof_tests/jekyll/default-collections.toolproof.yml index baf26e7..6b198c2 100644 --- a/toolproof_tests/jekyll/default-collections.toolproof.yml +++ b/toolproof_tests/jekyll/default-collections.toolproof.yml @@ -26,6 +26,22 @@ steps: ╎ "create": { ╎ "path": "", ╎ "publish_to": "posts" + ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } ╎ } ╎ }, ╎ "news_drafts": { @@ -35,6 +51,22 @@ steps: ╎ "create": { ╎ "path": "", ╎ "publish_to": "news_posts" + ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } ╎ } ╎ }, ╎ "news_posts": { @@ -44,6 +76,22 @@ steps: ╎ "create": { ╎ "path": "[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]" ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.news_posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } + ╎ }, ╎ "add_options": [ ╎ { ╎ "name": "Add Post" @@ -61,6 +109,22 @@ steps: ╎ "create": { ╎ "path": "[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]" ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } + ╎ }, ╎ "add_options": [ ╎ { ╎ "name": "Add Post" @@ -75,7 +139,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ }, ╎ "data_animals": { ╎ "path": "_data/animals", diff --git a/toolproof_tests/justice-eleventy-template.toolproof.yml b/toolproof_tests/justice-eleventy-template.toolproof.yml index 1f3ee48..1f0e0ef 100644 --- a/toolproof_tests/justice-eleventy-template.toolproof.yml +++ b/toolproof_tests/justice-eleventy-template.toolproof.yml @@ -28,7 +28,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ } ╎ }, ╎ "timezone": "Pacific/Auckland", diff --git a/toolproof_tests/vonge_jekyll.toolproof.yml b/toolproof_tests/vonge_jekyll.toolproof.yml index 9e390a4..2a3200b 100644 --- a/toolproof_tests/vonge_jekyll.toolproof.yml +++ b/toolproof_tests/vonge_jekyll.toolproof.yml @@ -27,6 +27,22 @@ steps: ╎ "create": { ╎ "path": "", ╎ "publish_to": "posts" + ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } ╎ } ╎ }, ╎ "posts": { @@ -36,6 +52,22 @@ steps: ╎ "create": { ╎ "path": "[relative_base_path]/{date|year}-{date|month}-{date|day}-{title|slugify}.[ext]" ╎ }, + ╎ "_inputs": { + ╎ "categories": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].categories", + ╎ "allow_create": true + ╎ } + ╎ }, + ╎ "tags": { + ╎ "type": "multiselect", + ╎ "options": { + ╎ "values": "collections.posts[*].tags", + ╎ "allow_create": true + ╎ } + ╎ } + ╎ }, ╎ "add_options": [ ╎ { ╎ "name": "Add Post" @@ -55,7 +87,10 @@ steps: ╎ "path": "_data", ╎ "name": "Data", ╎ "icon": "data_usage", - ╎ "disable_url": true + ╎ "disable_url": true, + ╎ "disable_add": true, + ╎ "disable_add_folder": true, + ╎ "disable_file_actions": true ╎ }, ╎ "testimonials": { ╎ "path": "collections/_testimonials",