From c95eedd4099b6df222702cd2a084ba4817e00b1c Mon Sep 17 00:00:00 2001 From: Ross Phillips <12723297+rphillips-cc@users.noreply.github.com> Date: Mon, 19 Dec 2022 16:28:40 +1300 Subject: [PATCH] Assign files to collections based on paths rather than matching jekyll collection --- .../generators/collections.rb | 108 +++-- lib/cloudcannon-jekyll/logger.rb | 4 + script/test-all-versions | 2 +- spec/expected/2.4.0/ignored-collection.json | 84 +--- .../path-based-collections.json} | 178 ++++---- spec/expected/3.0.0/ignored-collection.json | 83 +--- .../3.0.0/path-based-collections.json | 395 +++++++++++++++++ spec/expected/3.3.1/ignored-collection.json | 90 +--- .../3.3.1/path-based-collections.json | 401 +++++++++++++++++ spec/expected/3.8.5/ignored-collection.json | 90 +--- .../3.8.5/path-based-collections.json | 400 +++++++++++++++++ .../collections-config-override.json | 2 +- spec/expected/4.3.1/ignored-collection.json | 271 ++++++++++++ .../{4.2.1 => 4.3.1}/json-config.json | 2 +- .../legacy-collections-dir.json | 2 +- spec/expected/{4.2.1 => 4.3.1}/legacy.json | 2 +- spec/expected/{4.2.1 => 4.3.1}/no-config.json | 2 +- .../4.3.1/path-based-collections.json | 408 ++++++++++++++++++ .../{4.2.1 => 4.3.1}/site-config.json | 2 +- .../{4.2.1 => 4.3.1}/yaml-config.json | 2 +- .../ignored-collection/cloudcannon.config.yml | 1 - .../ignored-collection/other/_drafts/wip.md | 7 - .../other/_posts/2020-08-10-category-test.md | 10 - spec/fixtures/path-based-collections/404.html | 7 + .../path-based-collections/_config.yml | 32 ++ .../path-based-collections/_data/company.yml | 6 + .../path-based-collections/_data/footer.yml | 6 + .../_drafts/incomplete.md | 0 .../_layouts/default.html | 67 +++ .../path-based-collections/_layouts/post.html | 11 + .../_posts/2016-08-10-awesome-things.md | 0 .../_posts/2016-11-11-good-stuff.md | 0 .../_posts/_defaults.md | 0 .../_staff_members/_defaults.md | 4 + .../_staff_members/jane-doe.md | 5 + .../_staff_members/john-doe.md | 5 + .../path-based-collections/about.html | 14 + .../fixtures/path-based-collections/blog.html | 12 + .../cloudcannon.config.yml | 75 ++++ .../contact-success.html | 6 + .../path-based-collections/contact.html | 35 ++ .../path-based-collections/content.md | 5 + .../path-based-collections/index.html | 19 + .../more-pages/another-page.html | 5 + .../path-based-collections/robots.txt | 6 + .../path-based-collections/static-page.html | 11 + spec/generator_spec.rb | 14 + 47 files changed, 2421 insertions(+), 470 deletions(-) rename spec/expected/{4.2.1/ignored-collection.json => 2.4.0/path-based-collections.json} (72%) create mode 100644 spec/expected/3.0.0/path-based-collections.json create mode 100644 spec/expected/3.3.1/path-based-collections.json create mode 100644 spec/expected/3.8.5/path-based-collections.json rename spec/expected/{4.2.1 => 4.3.1}/collections-config-override.json (99%) create mode 100644 spec/expected/4.3.1/ignored-collection.json rename spec/expected/{4.2.1 => 4.3.1}/json-config.json (99%) rename spec/expected/{4.2.1 => 4.3.1}/legacy-collections-dir.json (99%) rename spec/expected/{4.2.1 => 4.3.1}/legacy.json (99%) rename spec/expected/{4.2.1 => 4.3.1}/no-config.json (99%) create mode 100644 spec/expected/4.3.1/path-based-collections.json rename spec/expected/{4.2.1 => 4.3.1}/site-config.json (99%) rename spec/expected/{4.2.1 => 4.3.1}/yaml-config.json (99%) delete mode 100644 spec/fixtures/ignored-collection/other/_drafts/wip.md delete mode 100644 spec/fixtures/ignored-collection/other/_posts/2020-08-10-category-test.md create mode 100644 spec/fixtures/path-based-collections/404.html create mode 100644 spec/fixtures/path-based-collections/_config.yml create mode 100644 spec/fixtures/path-based-collections/_data/company.yml create mode 100644 spec/fixtures/path-based-collections/_data/footer.yml rename spec/fixtures/{ignored-collection => path-based-collections}/_drafts/incomplete.md (100%) create mode 100644 spec/fixtures/path-based-collections/_layouts/default.html create mode 100644 spec/fixtures/path-based-collections/_layouts/post.html rename spec/fixtures/{ignored-collection => path-based-collections}/_posts/2016-08-10-awesome-things.md (100%) rename spec/fixtures/{ignored-collection => path-based-collections}/_posts/2016-11-11-good-stuff.md (100%) rename spec/fixtures/{ignored-collection => path-based-collections}/_posts/_defaults.md (100%) create mode 100644 spec/fixtures/path-based-collections/_staff_members/_defaults.md create mode 100644 spec/fixtures/path-based-collections/_staff_members/jane-doe.md create mode 100644 spec/fixtures/path-based-collections/_staff_members/john-doe.md create mode 100644 spec/fixtures/path-based-collections/about.html create mode 100644 spec/fixtures/path-based-collections/blog.html create mode 100644 spec/fixtures/path-based-collections/cloudcannon.config.yml create mode 100644 spec/fixtures/path-based-collections/contact-success.html create mode 100644 spec/fixtures/path-based-collections/contact.html create mode 100644 spec/fixtures/path-based-collections/content.md create mode 100644 spec/fixtures/path-based-collections/index.html create mode 100644 spec/fixtures/path-based-collections/more-pages/another-page.html create mode 100644 spec/fixtures/path-based-collections/robots.txt create mode 100644 spec/fixtures/path-based-collections/static-page.html diff --git a/lib/cloudcannon-jekyll/generators/collections.rb b/lib/cloudcannon-jekyll/generators/collections.rb index 9e7d961..c94b059 100644 --- a/lib/cloudcannon-jekyll/generators/collections.rb +++ b/lib/cloudcannon-jekyll/generators/collections.rb @@ -24,8 +24,7 @@ def initialize(site, config) def generate_collections_config collections = @site.config['collections'] || {} - input_collections_config = @config['collections_config'] || {} - collections_config = input_collections_config.reject { |_, v| v == false } + collections_config = @config['collections_config'] || {} return collections_config if @config['collections_config_override'] @@ -54,11 +53,9 @@ def generate_collections_config } end - collection_keys = (defaults.keys + collections.keys).uniq + collection_keys = (collections_config.keys + defaults.keys + collections.keys).uniq collection_keys.each do |key| - next if input_collections_config[key] == false - processed = (defaults[key] || {}) .merge(collections[key] || {}) .merge(collections_config[key] || {}) @@ -74,8 +71,6 @@ def generate_collections_config end @split_posts.each_key do |key| - next if input_collections_config[key] == false - posts_path = @split_posts[key]&.first&.relative_path&.sub(%r{(^|/)_posts.*}, '\1_posts') next unless posts_path @@ -89,8 +84,6 @@ def generate_collections_config end @split_drafts.each_key do |key| - next if input_collections_config[key] == false - drafts_path = @split_drafts[key]&.first&.relative_path&.sub(%r{(^|/)_drafts.*}, '\1_drafts') next unless drafts_path @@ -114,33 +107,53 @@ def drafts_paths paths.empty? ? [File.join('/', @collections_dir, '_drafts')] : paths end + def each_document(&block) + @site.pages.each(&block) + @site.static_files.each(&block) + @site.collections.each_value { |coll| coll.docs.each(&block) } + all_drafts.each(&block) + + # Jekyll 2.x.x doesn't have posts in site.collections + all_posts.each(&block) if IS_JEKYLL_2_X_X + end + def generate_collections(collections_config) + assigned_pages = {} collections = {} - collections_config.each_key do |key| - next if key == 'data' + path_map = collections_config_path_map(collections_config) + + each_document do |doc| + next unless allowed_document?(doc) + + key = document_collection_key(doc, path_map) + + unless key + Logger.warn "⚠️ No collection for #{doc.relative_path.bold}" + next + end + + if collections_config.dig(key, 'parser') == false + Logger.warn "⚠️ Ignoring #{doc.relative_path.bold} in #{key.bold} collection" + next + end collections[key] ||= [] + collections[key].push(document_to_json(doc, key)) - next if collections_config.dig(key, 'parser') == false + assigned_pages[doc.relative_path] = true if doc.instance_of?(Jekyll::Page) + end - collections[key] = if key == 'posts' || key.end_with?('/posts') - @split_posts[key] - elsif key == 'drafts' || key.end_with?('/drafts') - @split_drafts[key] - else - @site.collections[key]&.docs - end + collections_config.each_key do |key| + next if key == 'data' collections[key] ||= [] - collections[key] = collections[key].map do |doc| - document_to_json(doc, key) - end end if collections.key?('pages') && collections['pages'].empty? - collections['pages'] = all_pages.map do |doc| - document_to_json(doc, 'pages') + all_pages.each do |page| + assigned = assigned_pages[page.relative_path] + collections['pages'].push(document_to_json(page, 'pages')) unless assigned end end @@ -152,7 +165,7 @@ def remove_empty_collection_config(collections_config, collections) should_delete = if key == 'data' !data_files? else - collections[key].empty? && collection_config['auto_discovered'] + collections[key]&.empty? && collection_config['auto_discovered'] end if should_delete @@ -177,6 +190,27 @@ def document_type(doc) end end + def collections_config_path_map(collections_config) + unsorted = collections_config.map do |key, collection_config| + { + key: key, + path: "/#{collection_config['path']}/".sub(%r{/+}, '/') + } + end + + unsorted.sort_by { |pair| pair[:path].length }.reverse + end + + def document_collection_key(doc, path_map) + path = "/#{File.join(@collections_dir, doc.relative_path)}/".sub(%r{/+}, '/') + + collection_path_pair = path_map.find do |pair| + path.start_with? pair[:path] + end + + collection_path_pair[:key] if collection_path_pair + end + def legacy_document_data(doc) legacy_data = {} legacy_data['categories'] = doc.categories if doc.respond_to?(:categories) @@ -247,15 +281,27 @@ def all_drafts end def all_pages - html_pages = @site.pages.select do |page| - page.html? || page.url.end_with?('/') - end + pages = @site.pages.select { |doc| allowed_page?(doc) } + static_pages = @site.static_files.select { |doc| allowed_static_file?(doc) } + pages + static_pages + end - static_pages = @site.static_files.select do |static_page| - STATIC_EXTENSIONS.include?(static_page.extname) + def allowed_document?(doc) + if doc.instance_of?(Jekyll::Page) + allowed_page?(doc) + elsif doc.instance_of?(Jekyll::StaticFile) + allowed_static_file?(doc) + else + true end + end + + def allowed_page?(page) + page.html? || page.url.end_with?('/') + end - html_pages + static_pages + def allowed_static_file?(static_file) + STATIC_EXTENSIONS.include?(static_file.extname) end def data_files? diff --git a/lib/cloudcannon-jekyll/logger.rb b/lib/cloudcannon-jekyll/logger.rb index 95682a1..194769a 100644 --- a/lib/cloudcannon-jekyll/logger.rb +++ b/lib/cloudcannon-jekyll/logger.rb @@ -8,5 +8,9 @@ class Logger def self.info(str) Jekyll.logger.info('CloudCannon:', str) end + + def self.warn(str) + Jekyll.logger.warn('CloudCannon:', str) + end end end diff --git a/script/test-all-versions b/script/test-all-versions index 9342e3b..01d322c 100755 --- a/script/test-all-versions +++ b/script/test-all-versions @@ -6,5 +6,5 @@ JEKYLL_VERSION=2.4.0 bundle update && $(dirname "$0")/test && JEKYLL_VERSION=3.0.0 bundle update && $(dirname "$0")/test && JEKYLL_VERSION=3.3.1 bundle update && $(dirname "$0")/test && JEKYLL_VERSION=3.8.5 bundle update && $(dirname "$0")/test && -JEKYLL_VERSION=4.2.1 bundle update && $(dirname "$0")/test +JEKYLL_VERSION=4.3.1 bundle update && $(dirname "$0")/test diff --git a/spec/expected/2.4.0/ignored-collection.json b/spec/expected/2.4.0/ignored-collection.json index 05ee7e6..f0888d6 100644 --- a/spec/expected/2.4.0/ignored-collection.json +++ b/spec/expected/2.4.0/ignored-collection.json @@ -57,21 +57,6 @@ "auto_discovered": true, "path": "_data", "output": false - }, - "drafts": { - "auto_discovered": true, - "path": "_drafts", - "output": false - }, - "other/posts": { - "auto_discovered": true, - "path": "other/_posts", - "output": true - }, - "other/drafts": { - "auto_discovered": true, - "path": "other/_drafts", - "output": false } }, "collection_groups": [ @@ -91,6 +76,8 @@ } ], "collections": { + "posts": [], + "drafts": [], "staff_members": [], "pages": [ { @@ -172,68 +159,6 @@ "url": "/static-page.html", "collection": "pages" } - ], - "drafts": [ - { - "layout": "post", - "categories": [ - "business" - ], - "title": "WIP", - "date": "2016-08-10 00:00:00 +0000", - "author_staff_member": "jane-doe", - "image": null, - "slug": "incomplete", - "tags": [ - - ], - "path": "_drafts/incomplete.md", - "url": "/business/2016/08/10/incomplete/", - "collection": "drafts", - "id": "/business/2016/08/10/incomplete" - } - ], - "other/posts": [ - { - "layout": "post", - "categories": [ - "other", - "stuff" - ], - "title": "Category test", - "author": "/staff-members/jane-doe", - "image": null, - "large_header": false, - "date": "2020-08-10 00:00:00 +0000", - "slug": "category-test", - "tags": [ - - ], - "path": "other/_posts/2020-08-10-category-test.md", - "url": "/other/stuff/2020/08/10/category-test/", - "collection": "other/posts", - "id": "/other/stuff/2020/08/10/category-test" - } - ], - "other/drafts": [ - { - "layout": "post", - "categories": [ - "other" - ], - "title": "Other WIP", - "author": "/staff-members/jane-doe", - "image": "/uploads/example-upload.png", - "slug": "wip", - "tags": [ - - ], - "date": "2024-01-01 00:00:00 +1300", - "path": "other/_drafts/wip.md", - "url": "/other/2024/01/01/wip/", - "collection": "other/drafts", - "id": "/other/2024/01/01/wip" - } ] }, "data": { @@ -252,10 +177,7 @@ "title": "Links" } ], - "categories": [ - "stuff", - "other" - ], + "categories": [], "tags": [] }, "source": "/spec/fixtures/ignored-collection", diff --git a/spec/expected/4.2.1/ignored-collection.json b/spec/expected/2.4.0/path-based-collections.json similarity index 72% rename from spec/expected/4.2.1/ignored-collection.json rename to spec/expected/2.4.0/path-based-collections.json index a42b762..117acf3 100644 --- a/spec/expected/4.2.1/ignored-collection.json +++ b/spec/expected/2.4.0/path-based-collections.json @@ -7,27 +7,25 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "2.4.0", "environment": "development", "metadata": { "markdown": "kramdown", "kramdown": { "auto_ids": true, - "toc_levels": [ - 1, - 2, - 3, - 4, - 5, - 6 - ], + "coderay": { + "coderay_bold_every": 10, + "coderay_css": "style", + "coderay_line_number_start": 1, + "coderay_line_numbers": "inline", + "coderay_tab_width": 4, + "coderay_wrap": "div" + }, "entity_output": "as_char", - "smart_quotes": "lsquo,rsquo,ldquo,rdquo", - "input": "GFM", - "hard_wrap": false, - "guess_lang": true, "footnote_nr": 1, - "show_warnings": false + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "toc_levels": "1..6", + "use_coderay": false }, "commonmark": null } @@ -45,16 +43,27 @@ "staff_members": { "output": false, "custom": "indeed", + "sort_key": "name", + "singular_name": "staff_member", "auto_discovered": false, - "parser": false, "path": "_staff_members" }, + "posts": { + "output": true, + "auto_discovered": true, + "path": "_posts" + }, "pages": { "auto_discovered": true, "path": "", "output": true, "filter": "strict" }, + "more_pages": { + "auto_discovered": false, + "path": "more-pages", + "output": true + }, "data": { "auto_discovered": true, "path": "_data", @@ -64,16 +73,6 @@ "auto_discovered": true, "path": "_drafts", "output": false - }, - "other/posts": { - "auto_discovered": true, - "path": "other/_posts", - "output": true - }, - "other/drafts": { - "auto_discovered": true, - "path": "other/_drafts", - "output": false } }, "collection_groups": [ @@ -93,7 +92,72 @@ } ], "collections": { - "staff_members": [], + "staff_members": [ + { + "layout": "default", + "name": "Jane Doe", + "credentials": "LLB", + "path": "_staff_members/jane-doe.md", + "url": "/staff_members/jane-doe.html", + "collection": "staff_members" + }, + { + "layout": "default", + "name": "John Doe", + "credentials": "LLB", + "path": "_staff_members/john-doe.md", + "url": "/staff_members/john-doe.html", + "collection": "staff_members" + } + ], + "posts": [ + { + "layout": "post", + "categories": [ + "stuff" + ], + "title": "Awesome things", + "date": "2016-08-10 00:00:00 +0000", + "author": "/staff-members/jane-doe", + "image": null, + "slug": "awesome-things", + "tags": [ + + ], + "path": "_posts/2016-08-10-awesome-things.md", + "url": "/stuff/2016/08/10/awesome-things/", + "collection": "posts", + "id": "/stuff/2016/08/10/awesome-things" + }, + { + "layout": "post", + "categories": [ + "stuff" + ], + "title": "Good stuff", + "date": "2016-11-11 00:00:00 +0000", + "author": "/staff-members/john-doe", + "image": "/images/example.png", + "slug": "good-stuff", + "tags": [ + + ], + "path": "_posts/2016-11-11-good-stuff.md", + "url": "/stuff/2016/11/11/good-stuff/", + "collection": "posts", + "id": "/stuff/2016/11/11/good-stuff" + } + ], + "more_pages": [ + { + "layout": "default", + "title": "Another Page", + "call_to_action": "Contact", + "path": "more-pages/another-page.html", + "url": "/more-pages/another-page/", + "collection": "more_pages" + } + ], "pages": [ { "layout": "default", @@ -178,16 +242,14 @@ "drafts": [ { "layout": "post", - "draft": true, "categories": [ - "Business" + "business" ], "title": "WIP", "date": "2016-08-10 00:00:00 +0000", "author_staff_member": "jane-doe", "image": null, "slug": "incomplete", - "ext": ".md", "tags": [ ], @@ -196,52 +258,6 @@ "collection": "drafts", "id": "/business/2016/08/10/incomplete" } - ], - "other/posts": [ - { - "layout": "post", - "draft": false, - "categories": [ - "other", - "Stuff" - ], - "title": "Category test", - "author": "/staff-members/jane-doe", - "image": null, - "large_header": false, - "date": "2020-08-10 00:00:00 +0000", - "slug": "category-test", - "ext": ".md", - "tags": [ - - ], - "path": "other/_posts/2020-08-10-category-test.md", - "url": "/other/stuff/2020/08/10/category-test/", - "collection": "other/posts", - "id": "/other/stuff/2020/08/10/category-test" - } - ], - "other/drafts": [ - { - "layout": "post", - "draft": true, - "categories": [ - "other" - ], - "title": "Other WIP", - "author": "/staff-members/jane-doe", - "image": "/uploads/example-upload.png", - "slug": "wip", - "ext": ".md", - "tags": [ - - ], - "date": "2024-01-01 00:00:00 +1300", - "path": "other/_drafts/wip.md", - "url": "/other/2024/01/01/wip/", - "collection": "other/drafts", - "id": "/other/2024/01/01/wip" - } ] }, "data": { @@ -261,13 +277,19 @@ } ], "categories": [ - "Stuff", - "other" + "stuff" ], "tags": [] }, - "source": "/spec/fixtures/ignored-collection", + "source": "/spec/fixtures/path-based-collections", "timezone": "Etc/UTC", + "_snippets": { + "jekyll_include": { + "preview": { + "text": "Partial" + } + } + }, "data_config": { "footer": true }, diff --git a/spec/expected/3.0.0/ignored-collection.json b/spec/expected/3.0.0/ignored-collection.json index 30139c6..6b869d7 100644 --- a/spec/expected/3.0.0/ignored-collection.json +++ b/spec/expected/3.0.0/ignored-collection.json @@ -57,21 +57,6 @@ "auto_discovered": true, "path": "_data", "output": false - }, - "drafts": { - "auto_discovered": true, - "path": "_drafts", - "output": false - }, - "other/posts": { - "auto_discovered": true, - "path": "other/_posts", - "output": true - }, - "other/drafts": { - "auto_discovered": true, - "path": "other/_drafts", - "output": false } }, "collection_groups": [ @@ -91,6 +76,8 @@ } ], "collections": { + "posts": [], + "drafts": [], "staff_members": [], "pages": [ { @@ -172,67 +159,6 @@ "url": "/static-page.html", "collection": "pages" } - ], - "drafts": [ - { - "layout": "post", - "categories": [ - "Business" - ], - "title": "WIP", - "date": "2016-08-10 00:00:00 +0000", - "author_staff_member": "jane-doe", - "image": null, - "tags": [ - - ], - "path": "_drafts/incomplete.md", - "url": "/business/2016/08/10/incomplete/", - "collection": "drafts", - "id": "/business/2016/08/10/incomplete" - } - ], - "other/posts": [ - { - "layout": "post", - "categories": [ - "other", - "Stuff" - ], - "title": "Category test", - "author": "/staff-members/jane-doe", - "image": null, - "large_header": false, - "date": "2020-08-10 00:00:00 +0000", - "ext": ".md", - "slug": "category-test", - "tags": [ - - ], - "path": "other/_posts/2020-08-10-category-test.md", - "url": "/other/stuff/2020/08/10/category-test/", - "collection": "other/posts", - "id": "/other/stuff/2020/08/10/category-test" - } - ], - "other/drafts": [ - { - "layout": "post", - "categories": [ - - ], - "title": "Other WIP", - "author": "/staff-members/jane-doe", - "image": "/uploads/example-upload.png", - "tags": [ - - ], - "date": "2024-01-01 00:00:00 +1300", - "path": "other/_drafts/wip.md", - "url": "/2024/01/01/wip/", - "collection": "other/drafts", - "id": "/2024/01/01/wip" - } ] }, "data": { @@ -251,10 +177,7 @@ "title": "Links" } ], - "categories": [ - "Stuff", - "other" - ], + "categories": [], "tags": [] }, "source": "/spec/fixtures/ignored-collection", diff --git a/spec/expected/3.0.0/path-based-collections.json b/spec/expected/3.0.0/path-based-collections.json new file mode 100644 index 0000000..4e664aa --- /dev/null +++ b/spec/expected/3.0.0/path-based-collections.json @@ -0,0 +1,395 @@ +{ + "time": "2024-01-01T00:00:00+13:00", + "version": "0.0.3", + "cloudcannon": { + "name": "cloudcannon-jekyll", + "version": "*.*.*" + }, + "generator": { + "name": "jekyll", + "version": "3.0.0", + "environment": "development", + "metadata": { + "markdown": "kramdown", + "kramdown": { + "auto_ids": true, + "coderay": { + "coderay_bold_every": 10, + "coderay_css": "style", + "coderay_line_number_start": 1, + "coderay_line_numbers": "inline", + "coderay_tab_width": 4, + "coderay_wrap": "div" + }, + "entity_output": "as_char", + "footnote_nr": 1, + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "toc_levels": "1..6", + "enable_coderay": false + }, + "commonmark": null + } + }, + "paths": { + "dam_static": "", + "dam_uploads": "", + "static": "", + "uploads": "uploads", + "data": "_data", + "collections": "", + "layouts": "_layouts" + }, + "collections_config": { + "staff_members": { + "output": false, + "custom": "indeed", + "sort_key": "name", + "singular_name": "staff_member", + "auto_discovered": false, + "path": "_staff_members" + }, + "posts": { + "output": true, + "auto_discovered": true, + "permalink": "/:categories/:year/:month/:day/:title/", + "path": "_posts" + }, + "pages": { + "auto_discovered": true, + "path": "", + "output": true, + "filter": "strict" + }, + "more_pages": { + "auto_discovered": false, + "path": "more-pages", + "output": true + }, + "data": { + "auto_discovered": true, + "path": "_data", + "output": false + }, + "drafts": { + "auto_discovered": true, + "path": "_drafts", + "output": false + } + }, + "collection_groups": [ + { + "heading": "Blogging", + "collections": [ + "posts", + "drafts" + ] + }, + { + "heading": "Other", + "collections": [ + "pages", + "staff_members" + ] + } + ], + "collections": { + "staff_members": [ + { + "layout": "default", + "categories": [ + + ], + "name": "Jane Doe", + "credentials": "LLB", + "date": "2024-01-01 00:00:00 +1300", + "tags": [ + + ], + "path": "_staff_members/jane-doe.md", + "url": "/staff_members/jane-doe/", + "collection": "staff_members", + "id": "/staff_members/jane-doe" + }, + { + "layout": "default", + "categories": [ + + ], + "name": "John Doe", + "credentials": "LLB", + "date": "2024-01-01 00:00:00 +1300", + "tags": [ + + ], + "path": "_staff_members/john-doe.md", + "url": "/staff_members/john-doe/", + "collection": "staff_members", + "id": "/staff_members/john-doe" + } + ], + "posts": [ + { + "layout": "post", + "categories": [ + "Stuff" + ], + "title": "Awesome things", + "date": "2016-08-10 00:00:00 +0000", + "author": "/staff-members/jane-doe", + "image": null, + "ext": ".md", + "slug": "awesome-things", + "tags": [ + + ], + "path": "_posts/2016-08-10-awesome-things.md", + "url": "/stuff/2016/08/10/awesome-things/", + "collection": "posts", + "id": "/stuff/2016/08/10/awesome-things" + }, + { + "layout": "post", + "categories": [ + "Stuff" + ], + "title": "Good stuff", + "date": "2016-11-11 00:00:00 +0000", + "author": "/staff-members/john-doe", + "image": "/images/example.png", + "ext": ".md", + "slug": "good-stuff", + "tags": [ + + ], + "path": "_posts/2016-11-11-good-stuff.md", + "url": "/stuff/2016/11/11/good-stuff/", + "collection": "posts", + "id": "/stuff/2016/11/11/good-stuff" + } + ], + "more_pages": [ + { + "layout": "default", + "title": "Another Page", + "call_to_action": "Contact", + "path": "more-pages/another-page.html", + "url": "/more-pages/another-page/", + "collection": "more_pages" + } + ], + "pages": [ + { + "layout": "default", + "title": "Not Found", + "call_to_action": "Contact", + "permalink": "/404.html", + "sitemap": false, + "path": "404.html", + "url": "/404.html", + "collection": "pages" + }, + { + "layout": "default", + "title": "About", + "call_to_action": "Contact", + "path": "about.html", + "url": "/about/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Blog", + "call_to_action": "Contact", + "path": "blog.html", + "url": "/blog/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact Success", + "call_to_action": "Advice", + "sitemap": false, + "path": "contact-success.html", + "url": "/contact-success/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact", + "call_to_action": "Map", + "path": "contact.html", + "url": "/contact/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Content", + "call_to_action": "Contact", + "path": "content.md", + "url": "/content/", + "collection": "pages" + }, + { + "layout": "default", + "title": null, + "call_to_action": "Contact", + "quotes": [ + { + "text": "Hey there", + "name": "Bee" + }, + { + "text": "Hi mate", + "name": "Sea" + }, + { + "text": "Greetings to you", + "name": "Zed Zee" + } + ], + "path": "index.html", + "url": "/", + "collection": "pages" + }, + { + "layout": "default", + "path": "static-page.html", + "url": "/static-page.html", + "collection": "pages" + } + ], + "drafts": [ + { + "layout": "post", + "categories": [ + "Business" + ], + "title": "WIP", + "date": "2016-08-10 00:00:00 +0000", + "author_staff_member": "jane-doe", + "image": null, + "tags": [ + + ], + "path": "_drafts/incomplete.md", + "url": "/business/2016/08/10/incomplete/", + "collection": "drafts", + "id": "/business/2016/08/10/incomplete" + } + ] + }, + "data": { + "footer": [ + { + "links": [ + { + "link": "http://example.com", + "name": "Example" + }, + { + "link": "http://example.com", + "name": "Another Example" + } + ], + "title": "Links" + } + ], + "categories": [ + "Stuff" + ], + "tags": [] + }, + "source": "/spec/fixtures/path-based-collections", + "timezone": "Etc/UTC", + "_snippets": { + "jekyll_include": { + "preview": { + "text": "Partial" + } + } + }, + "data_config": { + "footer": true + }, + "base_url": "", + "_inputs": { + "heading_image": { + "type": "image", + "comment": "This image should be related to the content" + }, + "my_html": { + "type": "html", + "options": { + "italic": true, + "bold": true, + "styles": "hello.css" + } + } + }, + "_editables": { + "content": { + "image": true, + "bold": true + } + }, + "_select_data": { + "people": [ + "Jim", + "Pam" + ], + "greetings": { + "hello": "Hello!", + "hi": "Hi" + } + }, + "_structures": { + "gallery": { + "style": "select", + "values": [ + { + "label": "Image", + "image": "/path/to/source-image.png", + "value": { + "image": "/placeholder.png", + "caption": null + } + }, + { + "label": "External link", + "icon": "link", + "value": { + "url": null, + "title": null + } + } + ] + } + }, + "editor": { + "default_path": "basic" + }, + "source_editor": { + "tab_size": 2, + "show_gutter": false, + "theme": "dawn" + }, + "defaults": [ + { + "scope": { + "path": "" + }, + "values": { + "layout": "default" + } + }, + { + "scope": { + "path": "", + "type": "posts" + }, + "values": { + "layout": "post" + } + } + ] +} diff --git a/spec/expected/3.3.1/ignored-collection.json b/spec/expected/3.3.1/ignored-collection.json index e8ce254..77ecf19 100644 --- a/spec/expected/3.3.1/ignored-collection.json +++ b/spec/expected/3.3.1/ignored-collection.json @@ -50,21 +50,6 @@ "auto_discovered": true, "path": "_data", "output": false - }, - "drafts": { - "auto_discovered": true, - "path": "_drafts", - "output": false - }, - "other/posts": { - "auto_discovered": true, - "path": "other/_posts", - "output": true - }, - "other/drafts": { - "auto_discovered": true, - "path": "other/_drafts", - "output": false } }, "collection_groups": [ @@ -84,6 +69,8 @@ } ], "collections": { + "posts": [], + "drafts": [], "staff_members": [], "pages": [ { @@ -165,74 +152,6 @@ "url": "/static-page.html", "collection": "pages" } - ], - "drafts": [ - { - "layout": "post", - "draft": true, - "categories": [ - "Business" - ], - "title": "WIP", - "date": "2016-08-10 00:00:00 +0000", - "author_staff_member": "jane-doe", - "image": null, - "slug": "incomplete", - "ext": ".md", - "tags": [ - - ], - "path": "_drafts/incomplete.md", - "url": "/business/2016/08/10/incomplete/", - "collection": "drafts", - "id": "/business/2016/08/10/incomplete" - } - ], - "other/posts": [ - { - "layout": "post", - "draft": false, - "categories": [ - "other", - "Stuff" - ], - "title": "Category test", - "author": "/staff-members/jane-doe", - "image": null, - "large_header": false, - "date": "2020-08-10 00:00:00 +0000", - "slug": "category-test", - "ext": ".md", - "tags": [ - - ], - "path": "other/_posts/2020-08-10-category-test.md", - "url": "/other/stuff/2020/08/10/category-test/", - "collection": "other/posts", - "id": "/other/stuff/2020/08/10/category-test" - } - ], - "other/drafts": [ - { - "layout": "post", - "draft": true, - "categories": [ - "other" - ], - "title": "Other WIP", - "author": "/staff-members/jane-doe", - "image": "/uploads/example-upload.png", - "slug": "wip", - "ext": ".md", - "tags": [ - - ], - "date": "2024-01-01 00:00:00 +1300", - "path": "other/_drafts/wip.md", - "url": "/other/2024/01/01/wip/", - "collection": "other/drafts", - "id": "/other/2024/01/01/wip" - } ] }, "data": { @@ -251,10 +170,7 @@ "title": "Links" } ], - "categories": [ - "Stuff", - "other" - ], + "categories": [], "tags": [] }, "source": "/spec/fixtures/ignored-collection", diff --git a/spec/expected/3.3.1/path-based-collections.json b/spec/expected/3.3.1/path-based-collections.json new file mode 100644 index 0000000..985f996 --- /dev/null +++ b/spec/expected/3.3.1/path-based-collections.json @@ -0,0 +1,401 @@ +{ + "time": "2024-01-01T00:00:00+13:00", + "version": "0.0.3", + "cloudcannon": { + "name": "cloudcannon-jekyll", + "version": "*.*.*" + }, + "generator": { + "name": "jekyll", + "version": "3.3.1", + "environment": "development", + "metadata": { + "markdown": "kramdown", + "kramdown": { + "auto_ids": true, + "entity_output": "as_char", + "footnote_nr": 1, + "hard_wrap": false, + "input": "GFM", + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "toc_levels": "1..6" + }, + "commonmark": null + } + }, + "paths": { + "dam_static": "", + "dam_uploads": "", + "static": "", + "uploads": "uploads", + "data": "_data", + "collections": "", + "layouts": "_layouts" + }, + "collections_config": { + "staff_members": { + "output": false, + "custom": "indeed", + "sort_key": "name", + "singular_name": "staff_member", + "auto_discovered": false, + "path": "_staff_members" + }, + "posts": { + "output": true, + "permalink": "/:categories/:year/:month/:day/:title/", + "auto_discovered": true, + "path": "_posts" + }, + "pages": { + "auto_discovered": true, + "path": "", + "output": true, + "filter": "strict" + }, + "more_pages": { + "auto_discovered": false, + "path": "more-pages", + "output": true + }, + "data": { + "auto_discovered": true, + "path": "_data", + "output": false + }, + "drafts": { + "auto_discovered": true, + "path": "_drafts", + "output": false + } + }, + "collection_groups": [ + { + "heading": "Blogging", + "collections": [ + "posts", + "drafts" + ] + }, + { + "heading": "Other", + "collections": [ + "pages", + "staff_members" + ] + } + ], + "collections": { + "staff_members": [ + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "Jane Doe", + "credentials": "LLB", +"date": "2024-01-01 00:00:00 +1300", + "title": "Jane Doe", + "slug": "jane-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/jane-doe.md", + "url": "/staff_members/jane-doe/", + "collection": "staff_members", + "id": "/staff_members/jane-doe" + }, + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "John Doe", + "credentials": "LLB", +"date": "2024-01-01 00:00:00 +1300", + "title": "John Doe", + "slug": "john-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/john-doe.md", + "url": "/staff_members/john-doe/", + "collection": "staff_members", + "id": "/staff_members/john-doe" + } + ], + "posts": [ + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Awesome things", + "date": "2016-08-10 00:00:00 +0000", + "author": "/staff-members/jane-doe", + "image": null, + "slug": "awesome-things", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-08-10-awesome-things.md", + "url": "/stuff/2016/08/10/awesome-things/", + "collection": "posts", + "id": "/stuff/2016/08/10/awesome-things" + }, + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Good stuff", + "date": "2016-11-11 00:00:00 +0000", + "author": "/staff-members/john-doe", + "image": "/images/example.png", + "slug": "good-stuff", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-11-11-good-stuff.md", + "url": "/stuff/2016/11/11/good-stuff/", + "collection": "posts", + "id": "/stuff/2016/11/11/good-stuff" + } + ], + "more_pages": [ + { + "layout": "default", + "title": "Another Page", + "call_to_action": "Contact", + "path": "more-pages/another-page.html", + "url": "/more-pages/another-page/", + "collection": "more_pages" + } + ], + "pages": [ + { + "layout": "default", + "title": "Not Found", + "call_to_action": "Contact", + "permalink": "/404.html", + "sitemap": false, + "path": "404.html", + "url": "/404.html", + "collection": "pages" + }, + { + "layout": "default", + "title": "About", + "call_to_action": "Contact", + "path": "about.html", + "url": "/about/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Blog", + "call_to_action": "Contact", + "path": "blog.html", + "url": "/blog/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact Success", + "call_to_action": "Advice", + "sitemap": false, + "path": "contact-success.html", + "url": "/contact-success/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact", + "call_to_action": "Map", + "path": "contact.html", + "url": "/contact/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Content", + "call_to_action": "Contact", + "path": "content.md", + "url": "/content/", + "collection": "pages" + }, + { + "layout": "default", + "title": null, + "call_to_action": "Contact", + "quotes": [ + { + "text": "Hey there", + "name": "Bee" + }, + { + "text": "Hi mate", + "name": "Sea" + }, + { + "text": "Greetings to you", + "name": "Zed Zee" + } + ], + "path": "index.html", + "url": "/", + "collection": "pages" + }, + { + "layout": "default", + "path": "static-page.html", + "url": "/static-page.html", + "collection": "pages" + } + ], + "drafts": [ + { + "layout": "post", + "draft": true, + "categories": [ + "Business" + ], + "title": "WIP", + "date": "2016-08-10 00:00:00 +0000", + "author_staff_member": "jane-doe", + "image": null, + "slug": "incomplete", + "ext": ".md", + "tags": [ + + ], + "path": "_drafts/incomplete.md", + "url": "/business/2016/08/10/incomplete/", + "collection": "drafts", + "id": "/business/2016/08/10/incomplete" + } + ] + }, + "data": { + "footer": [ + { + "links": [ + { + "link": "http://example.com", + "name": "Example" + }, + { + "link": "http://example.com", + "name": "Another Example" + } + ], + "title": "Links" + } + ], + "categories": [ + "Stuff" + ], + "tags": [] + }, + "source": "/spec/fixtures/path-based-collections", + "timezone": "Etc/UTC", + "_snippets": { + "jekyll_include": { + "preview": { + "text": "Partial" + } + } + }, + "data_config": { + "footer": true + }, + "base_url": "", + "_inputs": { + "heading_image": { + "type": "image", + "comment": "This image should be related to the content" + }, + "my_html": { + "type": "html", + "options": { + "italic": true, + "bold": true, + "styles": "hello.css" + } + } + }, + "_editables": { + "content": { + "image": true, + "bold": true + } + }, + "_select_data": { + "people": [ + "Jim", + "Pam" + ], + "greetings": { + "hello": "Hello!", + "hi": "Hi" + } + }, + "_structures": { + "gallery": { + "style": "select", + "values": [ + { + "label": "Image", + "image": "/path/to/source-image.png", + "value": { + "image": "/placeholder.png", + "caption": null + } + }, + { + "label": "External link", + "icon": "link", + "value": { + "url": null, + "title": null + } + } + ] + } + }, + "editor": { + "default_path": "basic" + }, + "source_editor": { + "tab_size": 2, + "show_gutter": false, + "theme": "dawn" + }, + "defaults": [ + { + "scope": { + "path": "" + }, + "values": { + "layout": "default" + } + }, + { + "scope": { + "path": "", + "type": "posts" + }, + "values": { + "layout": "post" + } + } + ] +} diff --git a/spec/expected/3.8.5/ignored-collection.json b/spec/expected/3.8.5/ignored-collection.json index 6986d00..3969254 100644 --- a/spec/expected/3.8.5/ignored-collection.json +++ b/spec/expected/3.8.5/ignored-collection.json @@ -51,21 +51,6 @@ "auto_discovered": true, "path": "_data", "output": false - }, - "drafts": { - "auto_discovered": true, - "path": "_drafts", - "output": false - }, - "other/posts": { - "auto_discovered": true, - "path": "other/_posts", - "output": true - }, - "other/drafts": { - "auto_discovered": true, - "path": "other/_drafts", - "output": false } }, "collection_groups": [ @@ -85,6 +70,8 @@ } ], "collections": { + "posts": [], + "drafts": [], "staff_members": [], "pages": [ { @@ -166,74 +153,6 @@ "url": "/static-page.html", "collection": "pages" } - ], - "drafts": [ - { - "layout": "post", - "draft": true, - "categories": [ - "Business" - ], - "title": "WIP", - "date": "2016-08-10 00:00:00 +0000", - "author_staff_member": "jane-doe", - "image": null, - "slug": "incomplete", - "ext": ".md", - "tags": [ - - ], - "path": "_drafts/incomplete.md", - "url": "/business/2016/08/10/incomplete/", - "collection": "drafts", - "id": "/business/2016/08/10/incomplete" - } - ], - "other/posts": [ - { - "layout": "post", - "draft": false, - "categories": [ - "other", - "Stuff" - ], - "title": "Category test", - "author": "/staff-members/jane-doe", - "image": null, - "large_header": false, - "date": "2020-08-10 00:00:00 +0000", - "slug": "category-test", - "ext": ".md", - "tags": [ - - ], - "path": "other/_posts/2020-08-10-category-test.md", - "url": "/other/stuff/2020/08/10/category-test/", - "collection": "other/posts", - "id": "/other/stuff/2020/08/10/category-test" - } - ], - "other/drafts": [ - { - "layout": "post", - "draft": true, - "categories": [ - "other" - ], - "title": "Other WIP", - "author": "/staff-members/jane-doe", - "image": "/uploads/example-upload.png", - "slug": "wip", - "ext": ".md", - "tags": [ - - ], - "date": "2024-01-01 00:00:00 +1300", - "path": "other/_drafts/wip.md", - "url": "/other/2024/01/01/wip/", - "collection": "other/drafts", - "id": "/other/2024/01/01/wip" - } ] }, "data": { @@ -252,10 +171,7 @@ "title": "Links" } ], - "categories": [ - "Stuff", - "other" - ], + "categories": [], "tags": [] }, "source": "/spec/fixtures/ignored-collection", diff --git a/spec/expected/3.8.5/path-based-collections.json b/spec/expected/3.8.5/path-based-collections.json new file mode 100644 index 0000000..5dbffec --- /dev/null +++ b/spec/expected/3.8.5/path-based-collections.json @@ -0,0 +1,400 @@ +{ + "time": "2024-01-01T00:00:00+13:00", + "version": "0.0.3", + "cloudcannon": { + "name": "cloudcannon-jekyll", + "version": "*.*.*" + }, + "generator": { + "name": "jekyll", + "version": "3.8.5", + "environment": "development", + "metadata": { + "markdown": "kramdown", + "kramdown": { + "auto_ids": true, + "entity_output": "as_char", + "footnote_nr": 1, + "hard_wrap": false, + "input": "GFM", + "show_warnings": false, + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "toc_levels": "1..6" + }, + "commonmark": null + } + }, + "paths": { + "dam_static": "", + "dam_uploads": "", + "static": "", + "uploads": "uploads", + "data": "_data", + "collections": "", + "layouts": "_layouts" + }, + "collections_config": { + "staff_members": { + "output": false, + "custom": "indeed", + "sort_key": "name", + "singular_name": "staff_member", + "auto_discovered": false, + "path": "_staff_members" + }, + "posts": { + "output": true, + "permalink": "/:categories/:year/:month/:day/:title/", + "auto_discovered": true, + "path": "_posts" + }, + "pages": { + "auto_discovered": true, + "path": "", + "output": true, + "filter": "strict" + }, + "more_pages": { + "auto_discovered": false, + "path": "more-pages", + "output": true + }, + "data": { + "auto_discovered": true, + "path": "_data", + "output": false + }, + "drafts": { + "auto_discovered": true, + "path": "_drafts", + "output": false + } + }, + "collection_groups": [ + { + "heading": "Blogging", + "collections": [ + "posts", + "drafts" + ] + }, + { + "heading": "Other", + "collections": [ + "pages", + "staff_members" + ] + } + ], + "collections": { + "staff_members": [ + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "Jane Doe", + "credentials": "LLB", + "title": "Jane Doe", + "slug": "jane-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/jane-doe.md", + "url": "/staff_members/jane-doe/", + "collection": "staff_members", + "id": "/staff_members/jane-doe" + }, + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "John Doe", + "credentials": "LLB", + "title": "John Doe", + "slug": "john-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/john-doe.md", + "url": "/staff_members/john-doe/", + "collection": "staff_members", + "id": "/staff_members/john-doe" + } + ], + "posts": [ + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Awesome things", + "date": "2016-08-10 00:00:00 +0000", + "author": "/staff-members/jane-doe", + "image": null, + "slug": "awesome-things", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-08-10-awesome-things.md", + "url": "/stuff/2016/08/10/awesome-things/", + "collection": "posts", + "id": "/stuff/2016/08/10/awesome-things" + }, + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Good stuff", + "date": "2016-11-11 00:00:00 +0000", + "author": "/staff-members/john-doe", + "image": "/images/example.png", + "slug": "good-stuff", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-11-11-good-stuff.md", + "url": "/stuff/2016/11/11/good-stuff/", + "collection": "posts", + "id": "/stuff/2016/11/11/good-stuff" + } + ], + "more_pages": [ + { + "layout": "default", + "title": "Another Page", + "call_to_action": "Contact", + "path": "more-pages/another-page.html", + "url": "/more-pages/another-page/", + "collection": "more_pages" + } + ], + "pages": [ + { + "layout": "default", + "title": "Not Found", + "call_to_action": "Contact", + "permalink": "/404.html", + "sitemap": false, + "path": "404.html", + "url": "/404.html", + "collection": "pages" + }, + { + "layout": "default", + "title": "About", + "call_to_action": "Contact", + "path": "about.html", + "url": "/about/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Blog", + "call_to_action": "Contact", + "path": "blog.html", + "url": "/blog/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact Success", + "call_to_action": "Advice", + "sitemap": false, + "path": "contact-success.html", + "url": "/contact-success/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact", + "call_to_action": "Map", + "path": "contact.html", + "url": "/contact/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Content", + "call_to_action": "Contact", + "path": "content.md", + "url": "/content/", + "collection": "pages" + }, + { + "layout": "default", + "title": null, + "call_to_action": "Contact", + "quotes": [ + { + "text": "Hey there", + "name": "Bee" + }, + { + "text": "Hi mate", + "name": "Sea" + }, + { + "text": "Greetings to you", + "name": "Zed Zee" + } + ], + "path": "index.html", + "url": "/", + "collection": "pages" + }, + { + "layout": "default", + "path": "static-page.html", + "url": "/static-page.html", + "collection": "pages" + } + ], + "drafts": [ + { + "layout": "post", + "draft": true, + "categories": [ + "Business" + ], + "title": "WIP", + "date": "2016-08-10 00:00:00 +0000", + "author_staff_member": "jane-doe", + "image": null, + "slug": "incomplete", + "ext": ".md", + "tags": [ + + ], + "path": "_drafts/incomplete.md", + "url": "/business/2016/08/10/incomplete/", + "collection": "drafts", + "id": "/business/2016/08/10/incomplete" + } + ] + }, + "data": { + "footer": [ + { + "links": [ + { + "link": "http://example.com", + "name": "Example" + }, + { + "link": "http://example.com", + "name": "Another Example" + } + ], + "title": "Links" + } + ], + "categories": [ + "Stuff" + ], + "tags": [] + }, + "source": "/spec/fixtures/path-based-collections", + "timezone": "Etc/UTC", + "_snippets": { + "jekyll_include": { + "preview": { + "text": "Partial" + } + } + }, + "data_config": { + "footer": true + }, + "base_url": "", + "_inputs": { + "heading_image": { + "type": "image", + "comment": "This image should be related to the content" + }, + "my_html": { + "type": "html", + "options": { + "italic": true, + "bold": true, + "styles": "hello.css" + } + } + }, + "_editables": { + "content": { + "image": true, + "bold": true + } + }, + "_select_data": { + "people": [ + "Jim", + "Pam" + ], + "greetings": { + "hello": "Hello!", + "hi": "Hi" + } + }, + "_structures": { + "gallery": { + "style": "select", + "values": [ + { + "label": "Image", + "image": "/path/to/source-image.png", + "value": { + "image": "/placeholder.png", + "caption": null + } + }, + { + "label": "External link", + "icon": "link", + "value": { + "url": null, + "title": null + } + } + ] + } + }, + "editor": { + "default_path": "basic" + }, + "source_editor": { + "tab_size": 2, + "show_gutter": false, + "theme": "dawn" + }, + "defaults": [ + { + "scope": { + "path": "" + }, + "values": { + "layout": "default" + } + }, + { + "scope": { + "path": "", + "type": "posts" + }, + "values": { + "layout": "post" + } + } + ] +} diff --git a/spec/expected/4.2.1/collections-config-override.json b/spec/expected/4.3.1/collections-config-override.json similarity index 99% rename from spec/expected/4.2.1/collections-config-override.json rename to spec/expected/4.3.1/collections-config-override.json index 6689236..ccccc21 100644 --- a/spec/expected/4.2.1/collections-config-override.json +++ b/spec/expected/4.3.1/collections-config-override.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.3.1/ignored-collection.json b/spec/expected/4.3.1/ignored-collection.json new file mode 100644 index 0000000..09c43b0 --- /dev/null +++ b/spec/expected/4.3.1/ignored-collection.json @@ -0,0 +1,271 @@ +{ + "time": "2024-01-01T00:00:00+13:00", + "version": "0.0.3", + "cloudcannon": { + "name": "cloudcannon-jekyll", + "version": "*.*.*" + }, + "generator": { + "name": "jekyll", + "version": "4.3.1", + "environment": "development", + "metadata": { + "markdown": "kramdown", + "kramdown": { + "auto_ids": true, + "toc_levels": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "entity_output": "as_char", + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "input": "GFM", + "hard_wrap": false, + "guess_lang": true, + "footnote_nr": 1, + "show_warnings": false + }, + "commonmark": null + } + }, + "paths": { + "dam_static": "", + "dam_uploads": "", + "static": "", + "uploads": "uploads", + "data": "_data", + "collections": "", + "layouts": "_layouts" + }, + "collections_config": { + "staff_members": { + "output": false, + "custom": "indeed", + "auto_discovered": false, + "parser": false, + "path": "_staff_members" + }, + "pages": { + "auto_discovered": true, + "path": "", + "output": true, + "filter": "strict" + }, + "data": { + "auto_discovered": true, + "path": "_data", + "output": false + } + }, + "collection_groups": [ + { + "heading": "Blogging", + "collections": [ + "posts", + "drafts" + ] + }, + { + "heading": "Other", + "collections": [ + "pages", + "staff_members" + ] + } + ], + "collections": { + "staff_members": [], + "posts": [], + "drafts": [], + "pages": [ + { + "layout": "default", + "title": "Not Found", + "call_to_action": "Contact", + "permalink": "/404.html", + "sitemap": false, + "path": "404.html", + "url": "/404.html", + "collection": "pages" + }, + { + "layout": "default", + "title": "About", + "call_to_action": "Contact", + "path": "about.html", + "url": "/about/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Blog", + "call_to_action": "Contact", + "path": "blog.html", + "url": "/blog/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact Success", + "call_to_action": "Advice", + "sitemap": false, + "path": "contact-success.html", + "url": "/contact-success/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact", + "call_to_action": "Map", + "path": "contact.html", + "url": "/contact/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Content", + "call_to_action": "Contact", + "path": "content.md", + "url": "/content/", + "collection": "pages" + }, + { + "layout": "default", + "title": null, + "call_to_action": "Contact", + "quotes": [ + { + "text": "Hey there", + "name": "Bee" + }, + { + "text": "Hi mate", + "name": "Sea" + }, + { + "text": "Greetings to you", + "name": "Zed Zee" + } + ], + "path": "index.html", + "url": "/", + "collection": "pages" + }, + { + "layout": "default", + "path": "static-page.html", + "url": "/static-page.html", + "collection": "pages" + } + ] + }, + "data": { + "footer": [ + { + "links": [ + { + "link": "http://example.com", + "name": "Example" + }, + { + "link": "http://example.com", + "name": "Another Example" + } + ], + "title": "Links" + } + ], + "categories": [], + "tags": [] + }, + "source": "/spec/fixtures/ignored-collection", + "timezone": "Etc/UTC", + "data_config": { + "footer": true + }, + "base_url": "", + "_inputs": { + "heading_image": { + "type": "image", + "comment": "This image should be related to the content" + }, + "my_html": { + "type": "html", + "options": { + "italic": true, + "bold": true, + "styles": "hello.css" + } + } + }, + "_editables": { + "content": { + "image": true, + "bold": true + } + }, + "_select_data": { + "people": [ + "Jim", + "Pam" + ], + "greetings": { + "hello": "Hello!", + "hi": "Hi" + } + }, + "_structures": { + "gallery": { + "style": "select", + "values": [ + { + "label": "Image", + "image": "/path/to/source-image.png", + "value": { + "image": "/placeholder.png", + "caption": null + } + }, + { + "label": "External link", + "icon": "link", + "value": { + "url": null, + "title": null + } + } + ] + } + }, + "editor": { + "default_path": "basic" + }, + "source_editor": { + "tab_size": 2, + "show_gutter": false, + "theme": "dawn" + }, + "defaults": [ + { + "scope": { + "path": "" + }, + "values": { + "layout": "default" + } + }, + { + "scope": { + "path": "", + "type": "posts" + }, + "values": { + "layout": "post" + } + } + ] +} diff --git a/spec/expected/4.2.1/json-config.json b/spec/expected/4.3.1/json-config.json similarity index 99% rename from spec/expected/4.2.1/json-config.json rename to spec/expected/4.3.1/json-config.json index d142c88..ff2a688 100644 --- a/spec/expected/4.2.1/json-config.json +++ b/spec/expected/4.3.1/json-config.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.2.1/legacy-collections-dir.json b/spec/expected/4.3.1/legacy-collections-dir.json similarity index 99% rename from spec/expected/4.2.1/legacy-collections-dir.json rename to spec/expected/4.3.1/legacy-collections-dir.json index 05f0c40..e12de1a 100644 --- a/spec/expected/4.2.1/legacy-collections-dir.json +++ b/spec/expected/4.3.1/legacy-collections-dir.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.2.1/legacy.json b/spec/expected/4.3.1/legacy.json similarity index 99% rename from spec/expected/4.2.1/legacy.json rename to spec/expected/4.3.1/legacy.json index bbe2b05..d927839 100644 --- a/spec/expected/4.2.1/legacy.json +++ b/spec/expected/4.3.1/legacy.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.2.1/no-config.json b/spec/expected/4.3.1/no-config.json similarity index 99% rename from spec/expected/4.2.1/no-config.json rename to spec/expected/4.3.1/no-config.json index 1603eec..d37f475 100644 --- a/spec/expected/4.2.1/no-config.json +++ b/spec/expected/4.3.1/no-config.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.3.1/path-based-collections.json b/spec/expected/4.3.1/path-based-collections.json new file mode 100644 index 0000000..fab394f --- /dev/null +++ b/spec/expected/4.3.1/path-based-collections.json @@ -0,0 +1,408 @@ +{ + "time": "2024-01-01T00:00:00+13:00", + "version": "0.0.3", + "cloudcannon": { + "name": "cloudcannon-jekyll", + "version": "*.*.*" + }, + "generator": { + "name": "jekyll", + "version": "4.3.1", + "environment": "development", + "metadata": { + "markdown": "kramdown", + "kramdown": { + "auto_ids": true, + "toc_levels": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "entity_output": "as_char", + "smart_quotes": "lsquo,rsquo,ldquo,rdquo", + "input": "GFM", + "hard_wrap": false, + "guess_lang": true, + "footnote_nr": 1, + "show_warnings": false + }, + "commonmark": null + } + }, + "paths": { + "dam_static": "", + "dam_uploads": "", + "static": "", + "uploads": "uploads", + "data": "_data", + "collections": "", + "layouts": "_layouts" + }, + "collections_config": { + "staff_members": { + "output": false, + "custom": "indeed", + "sort_key": "name", + "singular_name": "staff_member", + "auto_discovered": false, + "path": "_staff_members" + }, + "posts": { + "output": true, + "permalink": "/:categories/:year/:month/:day/:title/", + "auto_discovered": true, + "path": "_posts" + }, + "pages": { + "auto_discovered": true, + "path": "", + "output": true, + "filter": "strict" + }, + "more_pages": { + "auto_discovered": false, + "path": "more-pages", + "output": true + }, + "data": { + "auto_discovered": true, + "path": "_data", + "output": false + }, + "drafts": { + "auto_discovered": true, + "path": "_drafts", + "output": false + } + }, + "collection_groups": [ + { + "heading": "Blogging", + "collections": [ + "posts", + "drafts" + ] + }, + { + "heading": "Other", + "collections": [ + "pages", + "staff_members" + ] + } + ], + "collections": { + "staff_members": [ + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "Jane Doe", + "credentials": "LLB", + "title": "Jane Doe", + "slug": "jane-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/jane-doe.md", + "url": "/staff_members/jane-doe/", + "collection": "staff_members", + "id": "/staff_members/jane-doe" + }, + { + "layout": "default", + "draft": false, + "categories": [ + + ], + "name": "John Doe", + "credentials": "LLB", + "title": "John Doe", + "slug": "john-doe", + "ext": ".md", + "tags": [ + + ], + "path": "_staff_members/john-doe.md", + "url": "/staff_members/john-doe/", + "collection": "staff_members", + "id": "/staff_members/john-doe" + } + ], + "posts": [ + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Awesome things", + "date": "2016-08-10 00:00:00 +0000", + "author": "/staff-members/jane-doe", + "image": null, + "slug": "awesome-things", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-08-10-awesome-things.md", + "url": "/stuff/2016/08/10/awesome-things/", + "collection": "posts", + "id": "/stuff/2016/08/10/awesome-things" + }, + { + "layout": "post", + "draft": false, + "categories": [ + "Stuff" + ], + "title": "Good stuff", + "date": "2016-11-11 00:00:00 +0000", + "author": "/staff-members/john-doe", + "image": "/images/example.png", + "slug": "good-stuff", + "ext": ".md", + "tags": [ + + ], + "path": "_posts/2016-11-11-good-stuff.md", + "url": "/stuff/2016/11/11/good-stuff/", + "collection": "posts", + "id": "/stuff/2016/11/11/good-stuff" + } + ], + "more_pages": [ + { + "layout": "default", + "title": "Another Page", + "call_to_action": "Contact", + "path": "more-pages/another-page.html", + "url": "/more-pages/another-page/", + "collection": "more_pages" + } + ], + "pages": [ + { + "layout": "default", + "title": "Not Found", + "call_to_action": "Contact", + "permalink": "/404.html", + "sitemap": false, + "path": "404.html", + "url": "/404.html", + "collection": "pages" + }, + { + "layout": "default", + "title": "About", + "call_to_action": "Contact", + "path": "about.html", + "url": "/about/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Blog", + "call_to_action": "Contact", + "path": "blog.html", + "url": "/blog/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact Success", + "call_to_action": "Advice", + "sitemap": false, + "path": "contact-success.html", + "url": "/contact-success/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Contact", + "call_to_action": "Map", + "path": "contact.html", + "url": "/contact/", + "collection": "pages" + }, + { + "layout": "default", + "title": "Content", + "call_to_action": "Contact", + "path": "content.md", + "url": "/content/", + "collection": "pages" + }, + { + "layout": "default", + "title": null, + "call_to_action": "Contact", + "quotes": [ + { + "text": "Hey there", + "name": "Bee" + }, + { + "text": "Hi mate", + "name": "Sea" + }, + { + "text": "Greetings to you", + "name": "Zed Zee" + } + ], + "path": "index.html", + "url": "/", + "collection": "pages" + }, + { + "layout": "default", + "path": "static-page.html", + "url": "/static-page.html", + "collection": "pages" + } + ], + "drafts": [ + { + "layout": "post", + "draft": true, + "categories": [ + "Business" + ], + "title": "WIP", + "date": "2016-08-10 00:00:00 +0000", + "author_staff_member": "jane-doe", + "image": null, + "slug": "incomplete", + "ext": ".md", + "tags": [ + + ], + "path": "_drafts/incomplete.md", + "url": "/business/2016/08/10/incomplete/", + "collection": "drafts", + "id": "/business/2016/08/10/incomplete" + } + ] + }, + "data": { + "footer": [ + { + "links": [ + { + "link": "http://example.com", + "name": "Example" + }, + { + "link": "http://example.com", + "name": "Another Example" + } + ], + "title": "Links" + } + ], + "categories": [ + "Stuff" + ], + "tags": [] + }, + "source": "/spec/fixtures/path-based-collections", + "timezone": "Etc/UTC", + "_snippets": { + "jekyll_include": { + "preview": { + "text": "Partial" + } + } + }, + "data_config": { + "footer": true + }, + "base_url": "", + "_inputs": { + "heading_image": { + "type": "image", + "comment": "This image should be related to the content" + }, + "my_html": { + "type": "html", + "options": { + "italic": true, + "bold": true, + "styles": "hello.css" + } + } + }, + "_editables": { + "content": { + "image": true, + "bold": true + } + }, + "_select_data": { + "people": [ + "Jim", + "Pam" + ], + "greetings": { + "hello": "Hello!", + "hi": "Hi" + } + }, + "_structures": { + "gallery": { + "style": "select", + "values": [ + { + "label": "Image", + "image": "/path/to/source-image.png", + "value": { + "image": "/placeholder.png", + "caption": null + } + }, + { + "label": "External link", + "icon": "link", + "value": { + "url": null, + "title": null + } + } + ] + } + }, + "editor": { + "default_path": "basic" + }, + "source_editor": { + "tab_size": 2, + "show_gutter": false, + "theme": "dawn" + }, + "defaults": [ + { + "scope": { + "path": "" + }, + "values": { + "layout": "default" + } + }, + { + "scope": { + "path": "", + "type": "posts" + }, + "values": { + "layout": "post" + } + } + ] +} diff --git a/spec/expected/4.2.1/site-config.json b/spec/expected/4.3.1/site-config.json similarity index 99% rename from spec/expected/4.2.1/site-config.json rename to spec/expected/4.3.1/site-config.json index 7925fd3..f5f1c1e 100644 --- a/spec/expected/4.2.1/site-config.json +++ b/spec/expected/4.3.1/site-config.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/expected/4.2.1/yaml-config.json b/spec/expected/4.3.1/yaml-config.json similarity index 99% rename from spec/expected/4.2.1/yaml-config.json rename to spec/expected/4.3.1/yaml-config.json index 538b0cf..ae1a95c 100644 --- a/spec/expected/4.2.1/yaml-config.json +++ b/spec/expected/4.3.1/yaml-config.json @@ -7,7 +7,7 @@ }, "generator": { "name": "jekyll", - "version": "4.2.1", + "version": "4.3.1", "environment": "development", "metadata": { "markdown": "kramdown", diff --git a/spec/fixtures/ignored-collection/cloudcannon.config.yml b/spec/fixtures/ignored-collection/cloudcannon.config.yml index 64149b0..9934a36 100644 --- a/spec/fixtures/ignored-collection/cloudcannon.config.yml +++ b/spec/fixtures/ignored-collection/cloudcannon.config.yml @@ -4,7 +4,6 @@ data_config: collections_config: staff_members: parser: false - posts: false paths: uploads: uploads diff --git a/spec/fixtures/ignored-collection/other/_drafts/wip.md b/spec/fixtures/ignored-collection/other/_drafts/wip.md deleted file mode 100644 index 104f7d0..0000000 --- a/spec/fixtures/ignored-collection/other/_drafts/wip.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Other WIP -categories: -author: /staff-members/jane-doe -image: /uploads/example-upload.png ---- -Test draft \ No newline at end of file diff --git a/spec/fixtures/ignored-collection/other/_posts/2020-08-10-category-test.md b/spec/fixtures/ignored-collection/other/_posts/2020-08-10-category-test.md deleted file mode 100644 index 715898e..0000000 --- a/spec/fixtures/ignored-collection/other/_posts/2020-08-10-category-test.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Category test -categories: - - Stuff -author: /staff-members/jane-doe -image: -large_header: false ---- - -Categories can be set with a folder structure. diff --git a/spec/fixtures/path-based-collections/404.html b/spec/fixtures/path-based-collections/404.html new file mode 100644 index 0000000..c5ee9c2 --- /dev/null +++ b/spec/fixtures/path-based-collections/404.html @@ -0,0 +1,7 @@ +--- +title: Not Found +call_to_action: Contact +permalink: /404.html +sitemap: false +--- +
This page doesn't exist.
diff --git a/spec/fixtures/path-based-collections/_config.yml b/spec/fixtures/path-based-collections/_config.yml new file mode 100644 index 0000000..2307c3f --- /dev/null +++ b/spec/fixtures/path-based-collections/_config.yml @@ -0,0 +1,32 @@ +# ---- +# Site + +title: Example site +url: "https://example.com" +baseurl: +description: Example site for testing +timezone: Etc/UTC + +collections: + staff_members: + output: false + custom: indeed + +defaults: + - scope: + path: "" + values: + layout: default + - scope: + path: "" + type: posts + values: + layout: post + +permalink: pretty + +exclude: + - Gemfile + - Gemfile.lock + - README.md + - LICENSE diff --git a/spec/fixtures/path-based-collections/_data/company.yml b/spec/fixtures/path-based-collections/_data/company.yml new file mode 100644 index 0000000..3b30801 --- /dev/null +++ b/spec/fixtures/path-based-collections/_data/company.yml @@ -0,0 +1,6 @@ +title: Example +description: Testing things +contact_email_address: contact@example.com +contact_phone_number: (12) 345 6789 +address: 123 Example Street, Exampleton +postal_address: PO Box 123, Exampleton diff --git a/spec/fixtures/path-based-collections/_data/footer.yml b/spec/fixtures/path-based-collections/_data/footer.yml new file mode 100644 index 0000000..f52e26e --- /dev/null +++ b/spec/fixtures/path-based-collections/_data/footer.yml @@ -0,0 +1,6 @@ +- title: Links + links: + - name: Example + link: http://example.com + - name: Another Example + link: http://example.com \ No newline at end of file diff --git a/spec/fixtures/ignored-collection/_drafts/incomplete.md b/spec/fixtures/path-based-collections/_drafts/incomplete.md similarity index 100% rename from spec/fixtures/ignored-collection/_drafts/incomplete.md rename to spec/fixtures/path-based-collections/_drafts/incomplete.md diff --git a/spec/fixtures/path-based-collections/_layouts/default.html b/spec/fixtures/path-based-collections/_layouts/default.html new file mode 100644 index 0000000..ec0dc5f --- /dev/null +++ b/spec/fixtures/path-based-collections/_layouts/default.html @@ -0,0 +1,67 @@ + + + + + + + + + +All about us!
+ +{{ member.name }} {{ member.credentials }}
+{{ member.content | markdownify }}
+Here's a blog. Subscribe with RSS.
+ +Thank you for reaching out.
diff --git a/spec/fixtures/path-based-collections/contact.html b/spec/fixtures/path-based-collections/contact.html new file mode 100644 index 0000000..edd33d8 --- /dev/null +++ b/spec/fixtures/path-based-collections/contact.html @@ -0,0 +1,35 @@ +--- +title: Contact +call_to_action: Map +--- +Contact us!
+ +{{ site.data.company.contact_phone_number }}
+ + +{{ site.data.company.contact_email_address }}
+ + + {{ site.data.company.postal_address | replace: ',', 'An example site.
+ +{% for quote in page.quotes %} +++{% endfor %} diff --git a/spec/fixtures/path-based-collections/more-pages/another-page.html b/spec/fixtures/path-based-collections/more-pages/another-page.html new file mode 100644 index 0000000..5ba297b --- /dev/null +++ b/spec/fixtures/path-based-collections/more-pages/another-page.html @@ -0,0 +1,5 @@ +--- +title: Another Page +call_to_action: Contact +--- +{{ quote.text }}
+By {{ quote.name }}
+
Another page here
diff --git a/spec/fixtures/path-based-collections/robots.txt b/spec/fixtures/path-based-collections/robots.txt new file mode 100644 index 0000000..780b5a3 --- /dev/null +++ b/spec/fixtures/path-based-collections/robots.txt @@ -0,0 +1,6 @@ +--- +layout: null +sitemap: false +--- +User-agent: * +Sitemap: {{ site.url }}/sitemap.xml \ No newline at end of file diff --git a/spec/fixtures/path-based-collections/static-page.html b/spec/fixtures/path-based-collections/static-page.html new file mode 100644 index 0000000..d3d9b02 --- /dev/null +++ b/spec/fixtures/path-based-collections/static-page.html @@ -0,0 +1,11 @@ + + + + +