Bug: Can't Route by page custom templates. EX: About, Contact, etc.. #1314
Unanswered
JoeStantonCode
asked this question in
Q&A
Replies: 1 comment
-
Hey @JoeStantonCode. You can use the possibleTemplatesList hook to add you own template resolution. You can consume the export class TemplateNameResolverPlugin {
constructor() {}
apply(hooks) {
hooks.addFilter('possibleTemplatesList', 'faust', (templates, data) => {
const templateName = data?.seedNode?.template?.templateName;
if (templateName && templateName !== 'Default') {
return Array.from(new Set([templateName, ...templates]));
}
return templates;
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Does this codebase support routing by custom template names? Right now it appears all the routes are based upon ContentType->Node->Name.
Is there a way to also handle routes by ContentType->Template->TemplateName? Right now it appears all the templates will just use the page node name.
WordPress Template:
about.php
/* Template Name: About */
contact.php
/* Template Name: Contact */
and then within the wp-templates->index.js we would have something along these lines?
About: about,
Contact: contact
Let me know if this is currently possible or if this would be a future feature? It'd be really nice to be able to route by custom template names so we can serve up different layouts and queries for about, contact, team, etc. Thanks! Great code base here.
Beta Was this translation helpful? Give feedback.
All reactions