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
990 B

{# handle meta in templates #}
{% macro meta(page, site) %}
2 years ago
{% if (page.meta) %}
{% set hasCannocial = false %}
2 years ago
{% 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 %}
2 years ago
{% 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 %}
2 years ago
2 years ago
{% endif %}
{% endmacro %}