-
-
Notifications
You must be signed in to change notification settings - Fork 5
Allow configuring file extension (e.g. .md) for files generated by perron:sync_sources #174
Description
Summary
When using the programmatic content feature (perron:sync_sources), Perron always
generates files with a .erb extension. There is currently no way to specify that
the generated files should use a different extension, such as .md.
Current behavior
Given a resource class with source_template, running bin/rails perron:sync_sources
always produces .erb files:
app/content/posts/
1.erb
2.erb
3.erb
Even when the template content is pure Markdown (front matter + body), the generated
file is .erb, which bypasses the Markdown parser and feels inconsistent with
manually-created .md resources.
Expected / desired behavior
It would be useful to configure the file extension at the resource level so that
generated files can be .md for Markdown-heavy content (blog posts, documentation
pages, editorial content, etc.).
A possible API could look like:
class Content::Post < Perron::Resource
source :posts, format: :md
def self.source_template(sources)
post = sources.posts
<<~TEMPLATE
---
title: #{post.title}
date: #{post.published_at}
---
#{post.body}
TEMPLATE
end
endOr alternatively via a dedicated class-level macro:
class Content::Post < Perron::Resource
source :posts
source_format :md
endContext
- Perron version: 0.18
- Ruby version: 4.0.2
- Rails version: 8.1.2