Hi there !
I’m trying to create dynmic routing in a project I’m working on.
I added a static page that list all the tags available on the blog by modifying the routes.yaml
as followed:
routes:
/tags/: tags
I also added a {{#get 'tags'}}
inside my tags.hbs
file to pull up all the tags from Ghost. This has worked well. But then If found this sentence about the data
property in the documentation:
This property can fetch [data] to be made available in a handlebars template, avoiding the need to use
{{get}}
everywhere.
So it thought about giving it a try to remove the call to {{#get}}
from my template. Thus, I changed my routes.yaml
file to what I understood was the Right Way of doing:
routes:
/tags/:
template: tags
data:
tags:
resource: tags
type: read
What I suppose this config means is:
- Create a route matching
/tags/
- Render it with the
tags.hbs
template - Add a
tags
variable containing all the tags to the template’s context
Note that I’m note quite sure of what the type
property do. I tried with the browse
value: no success.
Also changed the content of my tags.hbs
file to this:
{{!< default}}
<main role="main">
<ul>
{{#foreach tags}}
<li>
<a class="link f2" href="{{url}}" title="{{name}}">{{name}}</a>
</li>
{{/foreach}}
</ul>
</main>
Problem is, when uploading the new routes.yaml
and trying to access the /tags/
route, I’m welcomed with a 422
error and a somewhat cryptic message:
There’s obviously something wrong in my configuration… but what ?
Would anyone know what this message is trying to tell me ? Have I done something wrong in my routes.yaml
file or elsewhere ?
Thanks in advance for your input !