Skip to content

Commit

Permalink
fix #904 (new command still output Liquid code by default in posts.md)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Aug 18, 2024
1 parent 9793325 commit a84ef9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions bridgetown-core/lib/site_template/src/posts.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ title: Posts
---

<ul>
<%- if options["templates"] == "erb" -%>
<%% collections.posts.resources.each do |post| %>
<%- if options["templates"] == "liquid" -%>
{% for post in collections.posts.resources %}
<li>
<a href="<%%= post.relative_url %>"><%%= post.data.title %></a>
<a href="{{ post.relative_url }}">{{ post.data.title }}</a>
</li>
<%% end %>
{% endfor %}
<%- elsif options["templates"] == "serbea" -%>
{% collections.posts.resources.each do |post| %}
{% collections.posts.each do |post| %}
<li>
<a href="{{ post.relative_url }}">{{ post.data.title }}</a>
</li>
{% end %}
<%- else -%>
{% for post in collections.posts.resources %}
<%% collections.posts.each do |post| %>
<li>
<a href="{{ post.relative_url }}">{{ post.data.title }}</a>
<a href="<%%= post.relative_url %>"><%%= post.data.title %></a>
</li>
{% endfor %}
<%% end %>
<%- end -%>
</ul>

Expand Down
15 changes: 8 additions & 7 deletions bridgetown-core/test/test_new_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def static_template_files
assert_includes output, success_message
end

should "copy the static files for postcss configuration in site template to the new directory" do
should "copy the static files for erb templates config in site template to the new directory" do
postcss_config_files = ["/postcss.config.js", "/frontend/styles/index.css"]
postcss_template_files = static_template_files + postcss_config_files + template_config_files + erb_config_files + esbuild_config_files
generated_template_files = static_template_files + postcss_config_files + template_config_files + erb_config_files + esbuild_config_files

capture_output do
Bridgetown::Commands::Base.start(argumentize(@args))
Expand All @@ -117,22 +117,22 @@ def static_template_files
f.end_with?("welcome-to-bridgetown.md")
end

assert_same_elements postcss_template_files, new_site_files
assert_same_elements generated_template_files, new_site_files
end

should "copy the static files for erb templates config to the new directory" do
should "copy the static files for liquid templates config to the new directory" do
postcss_config_files = ["/postcss.config.js", "/frontend/styles/index.css"]
postcss_template_files = static_template_files + postcss_config_files + template_config_files + erb_config_files + esbuild_config_files
generated_template_files = static_template_files + postcss_config_files + template_config_files + liquid_config_files + esbuild_config_files

capture_output do
Bridgetown::Commands::Base.start(argumentize("#{@args} -t erb"))
Bridgetown::Commands::Base.start(argumentize("#{@args} -t liquid"))
end

new_site_files = dir_contents(@full_path).reject do |f|
f.end_with?("welcome-to-bridgetown.md")
end

assert_same_elements postcss_template_files, new_site_files
assert_same_elements generated_template_files, new_site_files
end

should "process any ERB files" do
Expand All @@ -157,6 +157,7 @@ def static_template_files
end

assert_same_elements erb_template_files, new_site_files
assert_match(%r!<% collections\.posts\.each do |post| %>!, File.read("#{@full_path_source}/posts.md"))
end

should "force created folder" do
Expand Down

0 comments on commit a84ef9f

Please sign in to comment.