We want to use content from a static page as a preamble to the list of posts:
on the home page
on each tag collection’s index page [software, support]
The docs don’t seem to deal with this scenario, so we have made various monkey patches based on tutorials and Forum posts, with very limited success
This shouldn’t be that difficult - we’re sure someone can lay this out in 30 seconds !
Since they all use index.hbs I assume we need some macros inserted above the list of posts to fetch page content. We would love a snippet for this.
We have adjusted routes.yaml by guesswork, and it probably needs correction as well (quoted below).
We would be very grateful for any help given.
------ begin routes.yaml -------------------------------------------
routes:
/:
data:
post: page.about
template: index
collections:
/:
permalink: /{slug}/
template:
- index
/software/:
permalink: /software/{slug}/
template:
- index
filter: tag:software+tag:-support
/support/:
permalink: /support/{slug}/
filter: tag:support+tag:-software
taxonomies:
tag: /tag/{slug}/
------- end routes.yaml -------------------------------------------
Many thanks Ghosties !
John
November 26, 2018, 5:58am
2
Hi Ian,
The index route doesn’t have any data associated with it by default, so there’s nowhere for a data
property in routes.yaml to inject into.
But there’s no reason you can’t just pull the content from a single post directly in the template file. For instance, adding this to index.hbs
would render the content of a post with a slug of welcome
as the intro section on your template:
{{#get "posts" slug="welcome" as |intro|}}
{{#intro}}
{{content}}
{{/intro}}
{{/get}}
More info here:
John, excellent advice - thanks.
This loads the intro content beautifully into the home page, however I have now lost the ‘post cards’ previously appearing there.
Can I have it all ?
P.S. still seeing post cards on the tag index pages [support, software] using the index.hbs.
routes.yml:
routes:
/:
template: index
collections:
/:
permalink: /{slug}/
template:
- home
/software/:
permalink: /software/{slug}/
template:
- index
filter: tag:software+tag:-support
/support/:
permalink: /support/{slug}/
template:
- index
filter: tag:support+tag:-software
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
home.hbs:
{{!-- The main content area --}}
{{#get "posts" slug="about" as |intro|}}
{{#intro}}
<article class="post-full {{post_class}} {{#unless feature_image}}no-image{{/unless}}">
<section class="post-full-content">
<div class="post-content">
{{content}}
</div>
</section>
</article>
{{/intro}}
{{/get}}
<div class="post-feed">
{{#foreach posts}}
{{!-- The tag below includes the markup for each post - partials/post-card.hbs --}}
{{> "post-card"}}
{{/foreach}}
</div>
</div>
No, the post cards are appearing, but hidden behind the {{content}} DIV.
It’s all there, just needs the layout unscrambled
system
Closed
December 15, 2018, 1:42pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.