Skip to content

Commit

Permalink
Simplify page routing
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Apr 7, 2024
1 parent e1731aa commit cf34adf
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ preprocess do
write_sitemap_file
end

# all pages
compile '/**/*.{html,md}' do
filter :erb
filter :kramdown, auto_ids: false if item.identifier =~ '/**/*.md'
Expand All @@ -15,6 +16,21 @@ compile '/**/*.{html,md}' do
filter :tidy if @config[:prod]
end

# home and error page
route '/*.{html,md}' do
item.identifier.without_ext + '.html'
end

route '/**/*.{html,md}' do
# section home
if item.identifier =~ '**/index.*'
item.identifier.without_ext + ".html"
# every other page
else
item.identifier.without_ext + '/index.html'
end
end

ignore '/css/{vendor,bits}/*'
compile '/css/*.scss' do
filter :dart_sass, :style => (@config[:prod] ? :compressed : :expanded)
Expand All @@ -40,22 +56,6 @@ compile '/sitemap.xml' do
write '/sitemap.xml'
end

route '/**/*.{html,md}' do
# homepage
if item.identifier =~ '/index.*'
'/index.html'
# error page
elsif item.identifier =~ '/404.*'
'/404.html'
# section home
elsif item.identifier =~ '**/index.*'
item.identifier.without_ext + ".html"
# every other page
else
item.identifier.without_ext + '/index.html'
end
end

# duplicate some files
compile '/ads.txt' do
write item.identifier
Expand Down

0 comments on commit cf34adf

Please sign in to comment.