Dynamic routing - page/post data context in default.hbs + nested navigation on custom collections


#1

I’ve just started developing a theme and have run into a problem that has been raised before.

This is the referenced issue in Github.

The version of Ghost I’m running is 2.6.1.

This is my routes.yaml file.

routes:
  /: home
  /about/:
    data:
      page: page.about
    template:
      - about

collections:
  /news/:
    permalink: /news/{slug}/
    data:
      page: page.news
    template:
      - news

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

In the admin I have static pages set up with slugs about and news. I would like to use these to manage things like the page title, meta title, meta description, social card information, etc. However as the previous topic suggests the page data is not coming through in context. The {{meta_title}} for the /about/ route is the blog title, and for the /news/ collection it’s the blog title with the pagination information appended, e.g. (Page 1). Strangely though the {{meta_description}} property is being populated in the template correctly.

That’s the first query/issue.

The second is that the {{current}} helper in the {{navigation}}. I have /news/ as one of my navigation items which for the listing page correctly adds the nav-current class, however for the nested posts /news/{slug}/ it is not set. Is it possible to do this?

Thanks in advance!


#2

I have the same issue.
can not change title when use custom collections

/product/:
permalink: /product/{slug}/
filter: tag:[product]
data: page.tmp-product

the web title show “site-name Page1"