The custom story templates give you a blank canvas to create whatever you wish and pass it to the library via The 'opts' object
Pass an object containing your custom templates to the templates key of the opts object.
This is what your server/app.js file might look like
...
ampRoutes(app, {
templates: {
text: ({ story, config, seo }) => (
<CustomTextStoryTemplate
story={story}
config={config}
seo={seo}
),
"live-blog": (props) => <CustomLiveBlogStoryTemplate {...props}>
}
})
...
- pass a function that returns your template (react component)
- this function takes an object as a parameter having the foll keys:
story- the story object that platform givesconfig- an object containingpublisherConfig,ampConfigandopts. ThepublisherConfigis the same as response of /api/v1/config. TheampConfigis an amp-specific config given by api/v1/amp/config.optscontains an object inside it calledfeatureConfigwhich provides config needed by features like inline config for infinite scroll, related stories etc.
CustomTextStoryTemplateis the template you've built using AMP library components and/or your own amp html. All your text stories will render this template.text,live-blogare the story template names. They must match thestory-templatein platform's story api response
To see what all the library exports, go to AMP Library Exports