How to handle search, content, and collection sorting when converting data files to resources #743
Replies: 2 comments
-
@copiousfreetime Feel free to log an issue about the collection ordering…definitely seems like the ordering should happen after any resources are added in this particular case. I'm not sure what your question was re: layout…that seems fine to me. Feel free to log an issue on the Bridgetown Quick Search repo as well, I like the idea of the front matter with search terms. https://github.com/bridgetownrb/bridgetown-quick-search/issues |
Beta Was this translation helpful? Give feedback.
-
@jaredcwhite The issue was around no I was unsuccessfully asking In the more general case, of adding a dynamic site.data.people.each do |id, person|
add_resource name, "#{id}.md" do
___ person
# option a
layout :person
# no content - do it all in the layout
# option b
layout :person
content "statically generated string here"
# option c - does this even work?
layout :person
content ::PersonComponent.new(person: person)
# option d - assuming that `content` is further evaulated in the pipeline?
layout :person
content '<%= render PersonComponent.new(person: ...) %>'
end
end |
Beta Was this translation helpful? Give feedback.
-
I am converting data to resources like is mentioned in
https://www.bridgetownrb.com/docs/plugins/external-apis#builder-lifecycle-and-data-files, and I have come across a couple of issues that might be worth discussing:
here is a snippet of code explaining the issues
resource sorting
It looks like collection sorting is done during during the
:read
event, which means that builders that useadd_resource
during:post_read
will cause the collections to not be sorted correctly when it is time for the pages to be generated.using a layout as the template
Not sure if this is the best way to handle this, but it was the easiest. Just set the
layout
frontmatter on all the dynamically created resource and it just works. But, this causes the next issue.Is there a better solution? Should I be calling a component there?
content PersonBlock.new(person: person).render
or similar?quck-search content
The bridgetown quick search uses the
document.content
when indexing a page, which is the resource content, but in my case, there wasn't any resource content, so I ended up creating fake resource content to get indexed.I might suggest adding ina special front matter item for quick search so that that could get used instead of the content -- if there is no actual content?
say:
Then the liquid tempalte could be update to use that instead of the body content
Thoughts, comments? Looking for advice and some ideas, and will be willing to work on PRs.
Beta Was this translation helpful? Give feedback.
All reactions