Add flag for dynamic meta tags in the template

This commit is contained in:
Paul Kaplan 2018-12-17 14:55:27 -05:00
parent ad4442a310
commit c768fab47d
3 changed files with 33 additions and 27 deletions

View file

@ -167,7 +167,8 @@
"pattern": "^/projects(/editor|(/\\d+(/editor|/fullscreen|/embed)?)?)?/?(\\?.*)?$", "pattern": "^/projects(/editor|(/\\d+(/editor|/fullscreen|/embed)?)?)?/?(\\?.*)?$",
"routeAlias": "/projects/?$", "routeAlias": "/projects/?$",
"view": "preview/preview", "view": "preview/preview",
"title": "Scratch Project" "title": "Scratch Project",
"dynamicMetaTags": true
}, },
{ {
"name": "3faq", "name": "3faq",

View file

@ -8,11 +8,12 @@
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=<%= htmlWebpackPlugin.options.viewportWidth %>, initial-scale=1"> <meta name="viewport" content="width=<%= htmlWebpackPlugin.options.viewportWidth %>, initial-scale=1">
<title>Scratch - <%= htmlWebpackPlugin.options.title %></title>
<!-- Prevent mobile Safari from making phone numbers --> <!-- Prevent mobile Safari from making phone numbers -->
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<% if (!htmlWebpackPlugin.options.dynamicMetaTags) { %>
<title>Scratch - <%= htmlWebpackPlugin.options.title %></title>
<!-- Search & Open Graph--> <!-- Search & Open Graph-->
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" /> <meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
<meta name="google-site-verification" content="m_3TAXDreGTFyoYnEmU9mcKB4Xtw5mw6yRkuJtXRKxM" /> <meta name="google-site-verification" content="m_3TAXDreGTFyoYnEmU9mcKB4Xtw5mw6yRkuJtXRKxM" />
@ -25,6 +26,7 @@
<meta property="og:image:type" content="<%- htmlWebpackPlugin.options.og_image_type %>" /> <meta property="og:image:type" content="<%- htmlWebpackPlugin.options.og_image_type %>" />
<meta property="og:image:width" content="<%- htmlWebpackPlugin.options.og_image_width %>" /> <meta property="og:image:width" content="<%- htmlWebpackPlugin.options.og_image_width %>" />
<meta property="og:image:height" content="<%- htmlWebpackPlugin.options.og_image_height %>" /> <meta property="og:image:height" content="<%- htmlWebpackPlugin.options.og_image_height %>" />
<% } %>
<!-- Favicon & CSS normalize --> <!-- Favicon & CSS normalize -->
<link rel="shortcut icon" href="/favicon.ico" /> <link rel="shortcut icon" href="/favicon.ico" />
@ -60,6 +62,7 @@
<script src="/<%= htmlWebpackPlugin.files.chunks[htmlWebpackPlugin.options.route.name].entry %>"></script> <script src="/<%= htmlWebpackPlugin.files.chunks[htmlWebpackPlugin.options.route.name].entry %>"></script>
<!-- Translate title element --> <!-- Translate title element -->
<% if (!htmlWebpackPlugin.options.dynamicMetaTags) { %>
<script> <script>
var loc = window._locale || 'en'; var loc = window._locale || 'en';
if (typeof window._messages !== 'undefined' && loc !== 'en') { if (typeof window._messages !== 'undefined' && loc !== 'en') {
@ -74,5 +77,6 @@
} }
} }
</script> </script>
<% } %>
</body> </body>
</html> </html>

View file

@ -132,7 +132,8 @@ module.exports = {
return new HtmlWebpackPlugin(defaults({}, { return new HtmlWebpackPlugin(defaults({}, {
title: route.title, title: route.title,
filename: route.name + '.html', filename: route.name + '.html',
route: route route: route,
dynamicMetaTags: route.dynamicMetaTags
}, templateConfig)); }, templateConfig));
}) })
).concat([ ).concat([