-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Routing: custom meta title & body_class output for static routes using data key #10082
Comments
@godofredoninja Thanks. It's for sure the same underlying problem 👍 The helpers should respect the page context object. |
Is there a chance this will be fixed in the next release? :) |
@velobarplus if there's somebody from the community to pick it up and contribute a PR we'd definitely help and merge it asap ;) |
@kirrg001 I'm wiling to do this, but what's up with the missing resourceType in the StaticRoutesRouter, where shuold that be used?
what should the implementation of |
Nice 👍 We have to push the resource type into the e.g. resource type is "page" => context = [this.routerName, resourceType] |
If there is more than one data definition, the target url does not represent a single resource. I'd not do anything in this case and don't push the resource type. |
@kirrg001 ok so if a post is turned into a page, then This in turns calls getPostSchema method, but the
What to do in this case, should post turned into a page also fetch authors and tags so that full data is present, or should meta data in case of |
The static controller should probably auto include tags and authors if the resource is post | page. But i'd suggest to create separate and small pull requests per problem 👍 |
refs #10082 - this is a requirement if a static route represents a single resource e.g. `data: page.team` - the page resource will no longer live on it's original static url - instead, it now lives somewhere else - that means the whole site needs to act the same than the original static url - the resource does not contain any relations - we don't forward the correct context (page, post, user?) - we override the `include` property for now - need to wait for more use cases or bug reports for this controller - more changes will follow asap
All issues tagged with |
Just for information, workaround is described in detail in https://stackoverflow.com/a/54788950/466677 |
I've noticed this same issue and in my opinion, this basically makes custom routes useless — at least for what I am trying to do (replacing the home page). Technically it works but it's a pain without the I've tried numerous ideas as a workaround but came up empty-handed each time 🙈. I'm 🤞 for someone to take point on this and get it in on one of the next releases. |
Re-opening this to handle prioritisation |
…routes refs #10082 ``` routes: /news/: data: post.news ``` The twitter_image was not available, because the context is [news, post] and the data is in `data.post`. The context helper was incorrect. I think it is still not fully correct, but only focused on this use case. The meta layer needs a full refactoring.
refs TryGhost#10082 - meta_title output wrong meta title Only solves meta_title outout for this use case: ``` routes: /: data: page.{slug} template: t ```
refs TryGhost#10082 - throwed a 500 because this.page was not handled - v2 differentiates between page and post
refs #10082 - meta_title output wrong meta title Only solves meta_title outout for this use case: ``` routes: /: data: page.{slug} template: t ```
refs #10082 - throwed a 500 because this.page was not handled - v2 differentiates between page and post
Some fixes landed in 2.17.0. |
Further problems I see:
The areas need some love and time. |
The error is not catched/logged properly. Needs investigation why the error is happening. |
refs TryGhost#10082 - When specifying an existing page as an allias for collection, e.g: `data: page.it-is-a-page` it was failing to generate metadata
refs #10082 - When specifying an existing page as an allias for collection, e.g: `data: page.it-is-a-page` it was failing to generate metadata
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Reported in the forum: https://forum.ghost.org/t/when-using-dynamic-routes-meta-title-and-body-class-are-empty/3765
Custom Meta Title
If you use
It always outputs the blog meta title and not the custom page meta title.
I see two problems:
the StaticRoutesRouter does not forward the correct context, see. It has to forward the resource type as well (e.g.
page
) if thedata
key was provided.The meta title helper is not aware of the
this.page
context object ->data.page
.Body Class Helper
This helper also needs to respect
this.page
.Code suggestion:
Workaround
Ghost: master
The text was updated successfully, but these errors were encountered: