From 7a31c83f472ce8ad88744f2d7626038f31b901b2 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Wed, 4 Oct 2017 09:58:21 +0800 Subject: [PATCH] Add breadcrumbs and article schema --- _includes/2017/article-schema.html | 34 +++++++++++ _includes/2017/foot.html | 2 - _includes/2017/head.html | 23 +++---- _includes/2017/meta-vars.html | 38 ++++++++++++ _includes/meta.html | 98 +++++++++--------------------- _includes/values/description.html | 4 ++ _includes/values/title.html | 10 ++- _layouts/2017/home.html | 8 +++ _layouts/2017/not_found.html | 9 +++ _layouts/2017/sheet.html | 9 +++ _layouts/default.html | 2 + 11 files changed, 150 insertions(+), 87 deletions(-) create mode 100644 _includes/2017/article-schema.html create mode 100644 _includes/2017/meta-vars.html diff --git a/_includes/2017/article-schema.html b/_includes/2017/article-schema.html new file mode 100644 index 000000000..f5722b00f --- /dev/null +++ b/_includes/2017/article-schema.html @@ -0,0 +1,34 @@ + + diff --git a/_includes/2017/foot.html b/_includes/2017/foot.html index 308b1d01b..e69de29bb 100644 --- a/_includes/2017/foot.html +++ b/_includes/2017/foot.html @@ -1,2 +0,0 @@ - - diff --git a/_includes/2017/head.html b/_includes/2017/head.html index 8d10c1743..e6f478d8f 100644 --- a/_includes/2017/head.html +++ b/_includes/2017/head.html @@ -1,17 +1,12 @@ - - - - {% include meta.html %} - {% include polyfills.html %} +{% include meta.html %} +{% include polyfills.html %} - - + + - - {% for lang in page.prism_languages %}{% endfor %} - + +{% for lang in page.prism_languages %}{% endfor %} + - - - - + + diff --git a/_includes/2017/meta-vars.html b/_includes/2017/meta-vars.html new file mode 100644 index 000000000..acde64900 --- /dev/null +++ b/_includes/2017/meta-vars.html @@ -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 %} diff --git a/_includes/meta.html b/_includes/meta.html index ffbac5410..200812590 100644 --- a/_includes/meta.html +++ b/_includes/meta.html @@ -1,65 +1,35 @@ +{% include 2017/meta-vars.html page=page %} + + -{%comment%}{%endcomment%} -{% assign base = '' %} -{% assign depth = page.url | split: '/' | size | minus: 1 %} - -{% 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%}{%endcomment%} -{% if page.full_title %} -{{ page.full_title }} - - - -{% elsif page.title %} -{% include values/title.html page=page %} - - - -{% else %} -{{ site.title }} - - - +{% if meta_title %} + {{ meta_title }} + + + {% endif %} -{%comment%}{%endcomment%} -{% if site.data.assets.preview_host %} -{% if page.type == 'home' %} - - -{% else %} - - -{% endif %} - - +{% if meta_image %} + + + + {% endif %} -{%comment%}{%endcomment%} -{% if page.description %} - - -{% else %} - - - +{% if meta_description %} + + + {% endif %} -{%comment%}{%endcomment%} {% if page.url != '/index.html' %} - - - - + + + + {% endif %} -{%comment%}{%endcomment%} {% if page.author %} {% for author in site.authors | where: "name", page.author %} @@ -69,39 +39,32 @@ {% endfor %} {% endif %} -{%comment%}{%endcomment%} {% if site.title %} - + {% endif %} -{%comment%}{%endcomment%} {% if site.facebook.app_id %} - + {% endif %} + {% if site.facebook.admin %} - + {% endif %} -{%comment%}{%endcomment%} {% if page.date %} - -{% endif %} -{% if page.image %} - - + {% endif %} -{%comment%}{%endcomment%} {% if page.category %} {% endif %} + {% if page.tags %} {% for tag in page.tags %} {% endfor %} {% endif %} -{%comment%}{%endcomment%} {% if site.data.google_analytics.enabled %} {% endif %} - - - +{% if depth %} + +{% endif %} -{%comment%}{%endcomment%} diff --git a/_includes/values/description.html b/_includes/values/description.html index 2a88b699f..92036d326 100644 --- a/_includes/values/description.html +++ b/_includes/values/description.html @@ -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 %} diff --git a/_includes/values/title.html b/_includes/values/title.html index ebd08d712..bfc2ea1c6 100644 --- a/_includes/values/title.html +++ b/_includes/values/title.html @@ -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 %} diff --git a/_layouts/2017/home.html b/_layouts/2017/home.html index 0ce1182e1..e074a12c5 100644 --- a/_layouts/2017/home.html +++ b/_layouts/2017/home.html @@ -1,3 +1,6 @@ + + + {% assign featured_pages = site.pages | where_exp: "page", "page.tags contains 'Featured'" %} @@ -6,6 +9,9 @@ | sort: "updated", "first" %} {% include 2017/head.html %} + + + {% 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 %} + + diff --git a/_layouts/2017/not_found.html b/_layouts/2017/not_found.html index 1a6e65753..3950b7229 100644 --- a/_layouts/2017/not_found.html +++ b/_layouts/2017/not_found.html @@ -1,4 +1,10 @@ + + + {% include 2017/head.html %} + + + {% include 2017/top-nav.html page=page noshare=true %}
@@ -15,3 +21,6 @@
{% include 2017/foot.html %} + + + diff --git a/_layouts/2017/sheet.html b/_layouts/2017/sheet.html index b9bbd8bbe..f2f98337f 100644 --- a/_layouts/2017/sheet.html +++ b/_layouts/2017/sheet.html @@ -1,4 +1,10 @@ + + + {% include 2017/head.html %} +{% include 2017/article-schema.html page=page %} + + {% 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 %} + + + diff --git a/_layouts/default.html b/_layouts/default.html index db3429f2c..6b4de0da5 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -4,6 +4,8 @@ type: article {% include head.html %} {% include site-header.html %} +{% include 2017/article-schema.html page=page %} +