-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
✨ Custom post templates #9073
✨ Custom post templates #9073
Conversation
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073 - add `{{gh-psm-template-select}}` component - allows selection of a custom template for a post if the active theme has custom templates - loads themes on render, only hitting the server if not already in the store - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template - adds `customTemplate` attr to `Post` model - adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates - add `.gh-select.disabled` styles to make disabled selects look visually disabled
cc2def3
to
9c7c55f
Compare
Ready for testing! |
I tested this successfully with a custom template. Also changed the theme, which doesn't have this specific template and it falls back to the default |
@@ -34,5 +38,10 @@ module.exports = function toJSON(name, checkedTheme) { | |||
} | |||
} | |||
|
|||
// CASE: if you want a JSON response for a single theme, which is not active. | |||
if (_.find(themeResult, {active: true}) && active.get()) { | |||
_.find(themeResult, {active: true}).templates = active.get().customTemplates; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
34113bd
to
2a99504
Compare
templateList.unshift(postObject.custom_template); | ||
if (themes.getActive() && !themes.getActive().hasTemplate(slugTemplate)) { | ||
templateList.unshift(postObject.custom_template); | ||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
- @todo: reconsider 150 length
- i've added the basic logic to gscan on my branch - the changes there aren't final at all, just for testing
- @todo: permissions - return 404 of :name does not exist - right now it only returns the active theme hardcoded - API endpoint implementation (RAW)
- gscan extracts the custom templates
- ensure we return custom templates - take care if no active theme instance exists
- if custom_template exists, it has the highest priority
- same behaviour in Admin panel
A file which is 100 characters long, looks like custom-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4fe3df6
to
5c21605
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still keen to change GQL to not return 2 different template lists, but we can work on that later.
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073 - add `{{gh-psm-template-select}}` component - allows selection of a custom template for a post if the active theme has custom templates - loads themes on render, only hitting the server if not already in the store - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template - adds `customTemplate` attr to `Post` model - adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates - add `.gh-select.disabled` styles to make disabled selects look visually disabled
any documentation on this ? |
@wassimseif There is documentation on https://themes.ghost.org and a blog post, plus a help guide is coming early next week. If you have any suggestions for documentation improvements, say hello in slack 🙃 |
refs #9060
Please look at the single commits for context.
TODO