Add breadcrumbs and article schema

This commit is contained in:
Rico Sta. Cruz 2017-10-04 09:58:21 +08:00
parent c2ce93cca6
commit 7a31c83f47
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
11 changed files with 150 additions and 87 deletions

View File

@ -0,0 +1,34 @@
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://google.com/article"
},
"headline": {{ meta_title | jsonify }},
"image": [ {{ meta_image | jsonify }} ],
"description": {{ meta_description | jsonify }}
}
</script>
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "{{ site.url }}/#{{ page.category | downcase | replace: ' ', '-' }}",
"name": "{{ page.category }}"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": {{ page_url | jsonify }},
"name": {{ page.title | jsonify }}
}
}]
}
</script>

View File

@ -1,2 +0,0 @@
</body>
</html>

View File

@ -1,17 +1,12 @@
<!doctype html>
<html lang='en' class='no-js {{ page.html_class }}'>
<head>
{% include meta.html %}
{% include polyfills.html %}
{% include meta.html %}
{% include polyfills.html %}
<!-- script -->
<script src='{{base}}/assets/packed/app.js?t={{ timestamp }}'></script>
<!-- script -->
<script src='{{base}}/assets/packed/app.js?t={{ timestamp }}'></script>
<!-- 3rd-party libs -->
{% for lang in page.prism_languages %}<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>{% endfor %}
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Cousine'>
<!-- 3rd-party libs -->
{% for lang in page.prism_languages %}<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>{% endfor %}
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Cousine'>
<!-- 2017 layout -->
<link href='{{base}}/assets/2017/style.css?t={{ timestamp }}' rel='stylesheet'>
</head>
<body>
<!-- 2017 layout -->
<link href='{{base}}/assets/2017/style.css?t={{ timestamp }}' rel='stylesheet'>

View File

@ -0,0 +1,38 @@
{% comment %}
This partial assigns these variables:
meta_image: "https://assets.devhints.io/previews/react.jpg"
meta_description: "A comprehensive cheatsheet for React."
meta_title: "React cheatsheet"
depth: "1"
base: "./"
timestamp: "293048189123"
page_url: "https://devhints.io/react"
It emits some blank lines because Jekyll, lol.
{% endcomment %}
{% if depth <= 1 %}{% assign base = '.' %}
{% elsif depth == 2 %}{% assign base = '..' %}
{% elsif depth == 3 %}{% assign base = '../..' %}
{% elsif depth == 4 %}{% assign base = '../../..' %}{% endif %}
{% assign timestamp = site.time | date: "%Y%m%d%H%M%S" %}
{% if site.data.assets.preview_host %}
{% capture meta_image %}{{ site.data.assets.preview_host }}{{ include.page.url | remove: '.html' }}.jpg?t={{ timestamp }}{% endcapture %}
{% endif %}
{% capture meta_title %}{% include values/title.html page=include.page %}{% endcapture %}
{% assign meta_title = meta_title | strip_newlines %}
{% capture meta_description %}{% include values/description.html page=include.page %}{% endcapture %}
{% assign meta_description = meta_description | strip_newlines %}
{% assign base = '' %}
{% assign depth = page.url | split: '/' | size | minus: 1 %}
{% capture page_url %}{{ site.url }}{{ page.url | remove: '.html' }}{% endcapture %}

View File

@ -1,65 +1,35 @@
{% include 2017/meta-vars.html page=page %}
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
{%comment%}<!-- set the base -->{%endcomment%}
{% assign base = '' %}
{% assign depth = page.url | split: '/' | size | minus: 1 %}
<meta property='page:depth' content='{{depth}}'>
{% if depth <= 1 %}{% assign base = '.' %}
{% elsif depth == 2 %}{% assign base = '..' %}
{% elsif depth == 3 %}{% assign base = '../..' %}
{% elsif depth == 4 %}{% assign base = '../../..' %}{% endif %}
{% assign timestamp = site.time | date: "%Y%m%d%H%M%S" %}
{%comment%}<!-- title -->{%endcomment%}
{% if page.full_title %}
<title>{{ page.full_title }}</title>
<meta content='{{ page.full_title }}' property='og:title'>
<meta content='{{ page.full_title }}' property='twitter:title'>
<meta content='article' property='og:type'>
{% elsif page.title %}
<title>{% include values/title.html page=page %}</title>
<meta content='{% include values/title.html page=page %}' property='og:title'>
<meta content='{% include values/title.html page=page %}' property='twitter:title'>
<meta content='{{ page.og_type | default: "article" }}' property='og:type'>
{% else %}
<title>{{ site.title }}</title>
<meta content='{{ site.title }}' property='og:title'>
<meta content='{{ site.title }}' property='twitter:title'>
<meta content='{{ page.og_type | default: "website" }}' property='og:type'>
{% if meta_title %}
<title>{{ meta_title }}</title>
<meta content='{{ meta_title }}' property='og:title'>
<meta content='{{ meta_title }}' property='twitter:title'>
<meta content='{{ page.og_type | default: "article" }}' property='og:type'>
{% endif %}
{%comment%}<!-- image -->{%endcomment%}
{% if site.data.assets.preview_host %}
{% if page.type == 'home' %}
<meta content='{{ site.data.assets.preview_host }}/index.jpg?t={{ timestamp }}' property='og:image'>
<meta content='{{ site.data.assets.preview_host }}/index.jpg?t={{ timestamp }}' property='twitter:image'>
{% else %}
<meta content='{{ site.data.assets.preview_host }}{{ page.url | remove: '.html' }}.jpg?t={{ timestamp }}' property='og:image'>
<meta content='{{ site.data.assets.preview_host }}{{ page.url | remove: '.html' }}.jpg?t={{ timestamp }}' property='twitter:image'>
{% endif %}
<meta content='900' property='og:image:width'>
<meta content='471' property='og:image:height'>
{% if meta_image %}
<meta content='{{ meta_image | escape }}' property='og:image'>
<meta content='{{ meta_image | escape }}' property='twitter:image'>
<meta content='900' property='og:image:width'>
<meta content='471' property='og:image:height'>
{% endif %}
{%comment%}<!-- description -->{%endcomment%}
{% if page.description %}
<meta content="{{ page.description }}" name="description">
<meta content="{{ page.description }}" property="og:description">
{% else %}
<meta content="{% include values/description.html page=page %}" name="description">
<meta content="{% include values/description.html page=page %}" property="og:description">
<meta content="{% include values/description.html page=page %}" property="twitter:description">
{% if meta_description %}
<meta content="{{ meta_description | escape }}" name="description">
<meta content="{{ meta_description | escape }}" property="og:description">
<meta content="{{ meta_description | escape }}" property="twitter:description">
{% endif %}
{%comment%}<!-- canonical URL -->{%endcomment%}
{% if page.url != '/index.html' %}
<link rel="canonical" href="{{ site.url }}{{ page.url | remove: '.html' }}">
<meta name="og:url" content="{{ site.url }}{{ page.url | remove: '.html' }}">
<link rel="prefetch" href="{{ site.url }}">
<link rel="prerender" href="{{ site.url }}">
<link rel="canonical" href="{{ site.url }}{{ page.url | remove: '.html' }}">
<meta name="og:url" content="{{ site.url }}{{ page.url | remove: '.html' }}">
<link rel="prefetch" href="{{ site.url }}">
<link rel="prerender" href="{{ site.url }}">
{% endif %}
{%comment%}<!-- author -->{%endcomment%}
{% if page.author %}
{% for author in site.authors | where: "name", page.author %}
<meta content='{{ author.name }}' name='author'>
@ -69,39 +39,32 @@
{% endfor %}
{% endif %}
{%comment%}<!-- site name -->{%endcomment%}
{% if site.title %}
<meta content='{{ site.title }}' property='og:site_name'>
<meta content='{{ site.title }}' property='og:site_name'>
{% endif %}
{%comment%}<!-- facebook -->{%endcomment%}
{% if site.facebook.app_id %}
<meta content='{{ site.facebook.app_id }}' property='fb:app_id'>
<meta content='{{ site.facebook.app_id }}' property='fb:app_id'>
{% endif %}
{% if site.facebook.admin %}
<meta content='{{ site.facebook.admin }}' property='fb:admins'>
<meta content='{{ site.facebook.admin }}' property='fb:admins'>
{% endif %}
{%comment%}<!-- page meta -->{%endcomment%}
{% if page.date %}
<meta content='{{ page.date | date: "%Y-%m-%d" }}' property='article:published_date'>
{% endif %}
{% if page.image %}
<meta content='{{ page.image }}' property='og:image'>
<meta content='{{ page.image }}' name='twitter:image'>
<meta content='{{ page.date | date: "%Y-%m-%d" }}' property='article:published_date'>
{% endif %}
{%comment%}<!-- tags -->{%endcomment%}
{% if page.category %}
<meta content='{{ page.category }}' property='article:section'>
{% endif %}
{% if page.tags %}
{% for tag in page.tags %}
<meta content='{{ tag }}' property='article:tag'>
{% endfor %}
{% endif %}
{%comment%}<!-- google analytics -->{%endcomment%}
{% if site.data.google_analytics.enabled %}
<script async src='https://www.googletagmanager.com/gtag/js?id={{ site.data.google_analytics.id }}'></script>
<script>
@ -113,9 +76,8 @@ gtag('config','{{ site.data.google_analytics.id }}');
</script>
{% endif %}
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
{% if depth %}
<meta property='page:depth' content='{{depth}}'>
{% endif %}
{%comment%}<!-- fouc -->{%endcomment%}
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>

View File

@ -1,7 +1,11 @@
{%
if page.intro
%}{{ page.intro | markdownify | strip_html }}{%
elsif page.description
%}{{ page.description }}{%
elsif page.type == 'article'
%}A comprehensive cheatsheet for {{ page.title }}.{%
else
%}A comprehensive cheatsheet for {{ page.title }}.{%
endif
%}

View File

@ -1,7 +1,11 @@
{%
if page.type == 'article'
%}{{ page.title }} cheatsheet {%
else
if page.full_title
%}{{ page.full_title }}{%
elsif page.type == 'article'
%}{{ page.title }} cheatsheet{%
elsif page.title
%}{{ page.title }}{%
else
%}{{ site.title }}{%
endif
%}

View File

@ -1,3 +1,6 @@
<!doctype html>
<html lang='en'><head>
{% assign featured_pages = site.pages
| where_exp: "page", "page.tags contains 'Featured'"
%}
@ -6,6 +9,9 @@
| sort: "updated", "first"
%}
{% include 2017/head.html %}
</head><body>
{% include 2017/top-nav.html page=page is_home=true noedit=true noback=true %}
{% if site.data.carbon.enabled %}
@ -74,3 +80,5 @@
{% include 2017/announcements-list.html %}
{% include 2017/foot.html %}
</body>
</html>

View File

@ -1,4 +1,10 @@
<!doctype html>
<html lang='en'><head>
{% include 2017/head.html %}
</head><body>
{% include 2017/top-nav.html page=page noshare=true %}
<div class='body-area -slim'>
@ -15,3 +21,6 @@
</div>
{% include 2017/foot.html %}
</body>
</html>

View File

@ -1,4 +1,10 @@
<!doctype html>
<html lang='en'><head>
{% include 2017/head.html %}
{% include 2017/article-schema.html page=page %}
</head><body>
{% include 2017/top-nav.html page=page %}
@ -44,3 +50,6 @@
{% include 2017/search-footer.html %}
{% include 2017/related-posts.html page=page %}
{% include 2017/foot.html %}
</body>
</html>

View File

@ -4,6 +4,8 @@ type: article
{% include head.html %}
{% include site-header.html %}
{% include 2017/article-schema.html page=page %}
<div class='post-list -single -cheatsheet'>
<div class='post-item'>
<div class='post-headline -cheatsheet'>