src/templates.js

Summary

Maintainability
A
0 mins
Test Coverage
const createAmpHeader = ({
  headOverride, style, canonicalUrl, title, extraHeadHTML
}) => `
<html amp>
  <head>${typeof headOverride === 'string' ? headOverride : `
    <meta charset="utf-8">
    <link rel="canonical" href="${canonicalUrl || ""}">
    <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
    <style amp-custom>
      ${style || ""}
    </style>
    <style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <title>${title || ""}</title>
    ${extraHeadHTML || ""}
  `}</head>`;

export const createAmpPage = (contentHTML, opts) => (
`${createAmpHeader(opts)}
  <body>
    ${contentHTML}
  </body>
</html>`
);