From 0ad1a368e307c339056ed1e84ef34510604b4b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Pollak?= Date: Thu, 6 Aug 2026 14:07:34 -0400 Subject: [PATCH] Recognize .md files in theme roots as templates The API now accepts .md files alongside .json/.yml at the theme root; teach FSTheme to classify them as templates so pull/push/sync/watch pick them up. --- lib/bootic_cli/themes/fs_theme.rb | 4 ++-- spec/fixtures/theme/readme.md | 3 +++ spec/themes/fs_theme_spec.rb | 23 +++++++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 spec/fixtures/theme/readme.md diff --git a/lib/bootic_cli/themes/fs_theme.rb b/lib/bootic_cli/themes/fs_theme.rb index 0c2a86d..4235e5c 100644 --- a/lib/bootic_cli/themes/fs_theme.rb +++ b/lib/bootic_cli/themes/fs_theme.rb @@ -31,13 +31,13 @@ def ==(other) ASSETS_DIR = 'assets'.freeze TEMPLATE_PATTERNS = [ - '*.html', '*.css', '*.js', '*.json', '*.yml', + '*.html', '*.css', '*.js', '*.json', '*.yml', '*.md', 'sections/*.html', 'partials/*.html', 'data/*.json', 'data/*.yml' ].freeze ASSET_PATTERNS = [File.join(ASSETS_DIR, '*')].freeze ASSET_PATH_REGEX = /^assets\/[^\/]+$/.freeze - TEMPLATE_PATH_REGEX = /^[^\/]+\.(html|css|scss|js|json|yml)$/.freeze + TEMPLATE_PATH_REGEX = /^[^\/]+\.(html|css|scss|js|json|yml|md)$/.freeze SECTION_PATH_REGEX = /^(sections|partials)\/[^\/]+\.html$/.freeze DATA_PATH_REGEX = /^data\/[^\/]+\.(json|yml)$/.freeze diff --git a/spec/fixtures/theme/readme.md b/spec/fixtures/theme/readme.md new file mode 100644 index 0000000..ad35b6d --- /dev/null +++ b/spec/fixtures/theme/readme.md @@ -0,0 +1,3 @@ +# Theme readme + +Some notes about this theme. diff --git a/spec/themes/fs_theme_spec.rb b/spec/themes/fs_theme_spec.rb index fc5bd12..39c40c7 100644 --- a/spec/themes/fs_theme_spec.rb +++ b/spec/themes/fs_theme_spec.rb @@ -30,12 +30,13 @@ expect(subject.assets.size).to eq 1 it_is_an_asset(subject.assets.first, file_name: 'script.js') - expect(subject.templates.size).to eq 5 + expect(subject.templates.size).to eq 6 it_is_a_template(subject.templates[0], file_name: 'layout.html') it_is_a_template(subject.templates[1], file_name: 'master.css') it_is_a_template(subject.templates[2], file_name: 'strings.en.json') - it_is_a_template(subject.templates[3], file_name: 'sections/gallery.html') - it_is_a_template(subject.templates[4], file_name: 'data/test.json') + it_is_a_template(subject.templates[3], file_name: 'readme.md') + it_is_a_template(subject.templates[4], file_name: 'sections/gallery.html') + it_is_a_template(subject.templates[5], file_name: 'data/test.json') end it "#add_template" do @@ -44,19 +45,29 @@ file = File.new('./spec/fixtures/theme/foo.html') expect(file.read).to eq 'Hello!' - expect(subject.templates.size).to eq 6 - expect(subject.templates.map(&:file_name).sort).to eq ['data/test.json', 'foo.html', 'layout.html', 'master.css', 'sections/gallery.html', 'strings.en.json'] + expect(subject.templates.size).to eq 7 + expect(subject.templates.map(&:file_name).sort).to eq ['data/test.json', 'foo.html', 'layout.html', 'master.css', 'readme.md', 'sections/gallery.html', 'strings.en.json'] tpl = subject.templates.find{|t| t.file_name == 'foo.html' } expect(tpl.updated_on).to eq file.mtime.utc subject.remove_template 'foo.html' end + it "recognizes .md files at the theme root as templates" do + subject.add_template 'CHANGELOG.md', '# Changes' + + tpl = subject.templates.find { |t| t.file_name == 'CHANGELOG.md' } + expect(tpl).not_to be_nil + expect(tpl.body).to eq '# Changes' + + subject.remove_template 'CHANGELOG.md' + end + it "#remove_template" do subject.add_template 'foo.html', 'Hello!' subject.remove_template 'foo.html' - expect(subject.templates.size).to eq 5 + expect(subject.templates.size).to eq 6 expect(File.exist?('./spec/fixtures/theme/foo.html')).to be false end