Dynamic routing, passing in data

Not sure if this is possible, but here goes:

I’m trying to create a series of “primary tag” pages that show posts with the given primary tag, but grouped by secondary tags of my choosing.

I have currently got this going using a combination of routes and hard-coded templates. E.g

// my routes.yaml:
    template: features

// features.hbs
{{#get "tags" slug="features" include='count.posts' as |tag| }}

{{> "primary-tag-section" primary_tag="features" secondary_tag="interviews"}}
{{> "primary-tag-section" primary_tag="features" secondary_tag="adventures"}}

My primary-tag-section partial then outputs posts and secondary tag details based on the two variables passed in.

Is there any way I could configure the page directly via routes.yaml?


    template: primary-tag-page
      primary_tag: features
        - interviews
        - adventures
    template: primary-tag-page
      primary_tag: something
        - tag-2
        - tag3

Just to answer my own post - in case someone stumbles upon it:

I couldn’t do what I wanted… but I did manage to create a template that uses page data to do something similar:

  1. create a page using the new template
  2. use the page tags to drive what’s actually shown on the page - e.g. loop over the tags to output groups of post cards related to that tag.

Works a treat.

I’ve got a second, similar template that uses the primary tag on the page to further filter down my results.

1 Like