Refactor and modularize
This commit is contained in:
30
_includes/structuredData.njk
Normal file
30
_includes/structuredData.njk
Normal file
@ -0,0 +1,30 @@
|
||||
{% if title %}
|
||||
<!-- Structured Data -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org/",
|
||||
"@type": "Article",
|
||||
"headline": "{{ title }}",
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "{{ metadata.author.name }}"
|
||||
},
|
||||
"datePublished": "{{ date }}",
|
||||
"description": "{% if synopsis %}{{ synopsis}}{% endif %}",
|
||||
"image": "{% if imageURL %}{{ imageURL | htmlBaseUrl(metadata.url) }}{% else %}{{ metadata.defaultPostImageURL | htmlBaseUrl(metadata.url) }}{% endif %}",
|
||||
"url": "{{ page.url | htmlBaseUrl(metadata.url) }}",
|
||||
"articleBody": "{{ content | striptags }}"
|
||||
}
|
||||
</script>
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:title" content="{{ title }}" />
|
||||
<meta property="og:description" content="{{ synopsis}}" />
|
||||
<meta property="og:url" content="{{ page.url | htmlBaseUrl(metadata.url) }}" />
|
||||
<meta property="og:image" content="{% if imageURL %}{{ imageURL | htmlBaseUrl(metadata.url) }}{% else %}{{ metadata.defaultPostImageURL | htmlBaseUrl(metadata.url) }}{% endif %}" />
|
||||
<!-- Twitter card -->
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="{{ title }}" />
|
||||
<meta name="twitter:description" content="{{ synopsis}}" />
|
||||
<meta name="twitter:image" content="{% if imageURL %}{{ imageURL | htmlBaseUrl(metadata.url) }}{% else %}{{ metadata.defaultPostImageURL | htmlBaseUrl(metadata.url) }}{% endif %}" />
|
||||
{% endif %}
|
Reference in New Issue
Block a user