Skip to content

[0.8.3] Feature/Custom components into shift-next config#38

Merged
jameskirkby merged 3 commits intomasterfrom
feature/custom-components-shift-next-config
Apr 15, 2019
Merged

[0.8.3] Feature/Custom components into shift-next config#38
jameskirkby merged 3 commits intomasterfrom
feature/custom-components-shift-next-config

Conversation

@jameskirkby
Copy link
Contributor

This PR allows custom components to be passed to shift-next through the shiftNextConfig.set() function, for example:

shiftNextConfig.set({
  ...
  customTemplateComponents: {
    hero: Hero,
    top_level_categories: TopLevelCategories,
    sixty_forty: SixtyForty,
    article_body_quote: ArticleBodyQuote,
    article_hero: ArticleHero,
    article_headings: ArticleHeadings,
    article_body: ArticleBody,
    article_image: ArticleImage,
    article_double_image: ArticleDoubleImage,
    article_products: ArticleProducts,
    article_button: ArticleButton,
    share_bar: ShareBar,
    related_articles: ArticleRelatedArticles
  }
})

This means that the components don't need to go through shift-react-components, as this was causing issues where the custom components weren't showing in the shift-react-components Config, which meant that custom components weren't showing on the page

Also, small refactor to the renderComponents() function in shift-next to use a .map() instead of a forloop

Added some basic documentation too

@jameskirkby jameskirkby self-assigned this Apr 12, 2019
Copy link
Contributor

@Azfletch Azfletch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jameskirkby jameskirkby merged commit 6c026ef into master Apr 15, 2019
@jameskirkby jameskirkby deleted the feature/custom-components-shift-next-config branch April 15, 2019 12:47
*/
export default function renderComponents (pageComponents) {
// Merge any custom template components with the ones from shift-react-components
const templateComponentsManifest = Object.assign({}, buildTemplateComponentsManifest(), Config.get().customTemplateComponents)
Copy link
Contributor

@hubertpompecki hubertpompecki Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change in place shift-react-components can now export the templateComponentManifest directly instead of exporting buildTemplateComponentsManifest . The reason the manifest was exported as a function was so that the call to config would happen at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a ticket for this

Copy link
Contributor

@hubertpompecki hubertpompecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing against this change in principle but I am surprised that it's needed in the first place. I thought we recently looked at adding template components and verified that it worked OK?

@jameskirkby
Copy link
Contributor Author

@hubertpompecki it worked, then it stopped working for a reason I couldn't figure out. A couple of us looked into it and got nowhere

Feels a bit long to do this too:
next front-end -> shift-react-components -> shift-next -> next front-end

When instead, this PR does this:
next front-end -> shift-next -> next front-end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments