You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webpack-plugin/example/views/helpers/meta.njk

30 lines
982 B

{# handle meta in templates #}
{% macro meta(page, site) %}
{% if (page.meta) %}
{% set hasCannocial = false %}
{% for key, content in page.meta %}
<meta name="{{ key }}" content="{{ content }}" />
{# check for index in robots if set page has canonical #}
{% if (key === 'robots' and content.indexOf('index') !== -1 and content.indexOf('noindex') === -1) %}
{% set hasCannocial = true %}
{% endif %}
{% endfor %}
{# check if page has canonical #}
{% if (hasCannocial) %}
{% set http = 'http' %}
{% if (site.https) %}
{% set http = site.https %}
{% endif %}
<link href="{{ http }}://{{ site.domain }}{{ page.path }}" rel="canonical">
<link rel="alternate" href="{{ http }}://{{ site.domain }}{{ page.path }}" hreflang="{{ site.language }}">
{% endif %}
{% endif %}
{% endmacro %}