-
I want to replace my existing website with Bridgetown - however, I want to keep the url paths the same so all the search indexes are still valid. It seems the autogenerated routing uses Can someone point me to the documentation (or code) to change the collection paths (and ideally the 'blessed' way to override that in code if there is no config setting for that). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Its quite a hack, but this does what I was trying for: Lets make a news file: mkdir src/news
touch src/news/breaking.md
---
layout: page
title: Breaking
date: 2022-03-07
---
**Breaking News**
EOF If go to: Now lets make an index page that collects all the 'news' files. touch src/news/index.md
cat <<EOF>>src/news/index.md
---
layout: page
title: News
date: 2022-03-07
---
**Some articles**
<% full_path, current_page = File.split(page.path) %>
<% path_list = Dir[full_path + "/*.md"].reject { |p| p.include?(current_page) } %>
<% file_list = path_list.map { |p| File.split(p).last.split('.').first } %>
<% title_list = path_list.map { |f| File.read(f).split("\n").detect {|t| t.include?('title: ') }.split.last } %>
<% link_list = title_list.zip(file_list) %>
<ul>
<% link_list.each do |title, file| %>
<li><a href="<%= file %>"><%= title %>- <%= file %></a></li>
<% end %>
</ul>
EOF now if you go to http://localhost:4000/news you should see your new page with the breaking news listed too. I am sure there is a better solution - probably with Bridgetown-Routes - but I haven't been able to get it working yet |
Beta Was this translation helpful? Give feedback.
Its quite a hack, but this does what I was trying for:
Lets make a news file:
If go to:
localhost:4000/news/breaking
we should see our page.Now lets make an index page that collects all the 'news' files.