From df3a7039889207cf65c21bfbb71ee8115058e307 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 1 Dec 2021 21:48:57 +0800 Subject: [PATCH] Refactor HTML structure --- _includes/disqus.html | 4 + _includes/panel.html | 59 --------- _includes/search-results.html | 8 -- _includes/toc.html | 10 ++ _includes/trending-tags.html | 14 +++ _includes/update-list.html | 16 +++ _layouts/default.html | 2 +- _layouts/page.html | 49 +++++--- _layouts/post.html | 217 ++++++++++++++-------------------- 9 files changed, 170 insertions(+), 209 deletions(-) delete mode 100644 _includes/panel.html create mode 100644 _includes/toc.html diff --git a/_includes/disqus.html b/_includes/disqus.html index 65af8b5..c4746de 100644 --- a/_includes/disqus.html +++ b/_includes/disqus.html @@ -2,6 +2,8 @@ The Disqus lazy loading. --> +{% if site.disqus.comments and page.comments %} +

Comments powered by Disqus. @@ -52,3 +54,5 @@ } + +{% endif %} diff --git a/_includes/panel.html b/_includes/panel.html deleted file mode 100644 index 98b859c..0000000 --- a/_includes/panel.html +++ /dev/null @@ -1,59 +0,0 @@ - - -{% include lang.html %} - -

- -
- - {% include update-list.html %} - - {% if update_list.size > 0 %} - -
- {{- site.data.locales[lang].panel.lastmod -}} -
    - - {% for item in update_list %} - {% assign index = item | split: "::" | last | plus: 0 %} - {% assign post = site.posts[index] %} - {% assign url = post.url | relative_url %} -
  • {{ post.title }}
  • - {% endfor %} - -
-
- - {% endif %} - - {% include trending-tags.html %} - - {% if trending_tags.size > 0 %} -
- {{- site.data.locales[lang].panel.trending_tags -}} -
- - {% for tag_name in trending_tags %} - {% assign url = tag_name | slugify | url_encode | prepend: "/tags/" | append: "/" %} - - {% endfor %} - -
-
- {% endif %} -
- - {% if include.toc %} - - -
- - {{- site.data.locales[lang].panel.toc -}} - - -
- {% endif %} - -
diff --git a/_includes/search-results.html b/_includes/search-results.html index 166ed5f..d19e3bd 100644 --- a/_includes/search-results.html +++ b/_includes/search-results.html @@ -4,15 +4,7 @@
-

{{ site.data.locales[lang].panel.trending_tags }}

- {% include trending-tags.html %} - - {% for tag in trending_tags %} - {% capture url %}/tags/{{ tag | slugify | url_encode }}/{% endcapture %} - - {% endfor %} -
diff --git a/_includes/toc.html b/_includes/toc.html new file mode 100644 index 0000000..e9da07e --- /dev/null +++ b/_includes/toc.html @@ -0,0 +1,10 @@ +{% if site.toc and page.toc %} + + +
+

+ {{- site.data.locales[lang].panel.toc -}} +

+ +
+{% endif %} diff --git a/_includes/trending-tags.html b/_includes/trending-tags.html index 05f9c84..a5ff0c0 100644 --- a/_includes/trending-tags.html +++ b/_includes/trending-tags.html @@ -34,3 +34,17 @@ {% endif %} {% endfor %} {% endfor %} + +{% if trending_tags.size > 0 %} +
+

{{- site.data.locales[lang].panel.trending_tags -}}

+
+ + {% for tag_name in trending_tags %} + {% assign url = tag_name | slugify | url_encode | prepend: "/tags/" | append: "/" %} + + {% endfor %} + +
+
+{% endif %} diff --git a/_includes/update-list.html b/_includes/update-list.html index 8dbf984..4f4201b 100644 --- a/_includes/update-list.html +++ b/_includes/update-list.html @@ -22,3 +22,19 @@ {% for entry in all_list limit:MAX_SIZE %} {% assign update_list = update_list | push: entry %} {% endfor %} + +{% if update_list.size > 0 %} + +
+

{{- site.data.locales[lang].panel.lastmod -}}

+
    + {% for item in update_list %} + {% assign index = item | split: "::" | last | plus: 0 %} + {% assign post = site.posts[index] %} + {% assign url = post.url | relative_url %} +
  • {{ post.title }}
  • + {% endfor %} +
+
+ +{% endif %} diff --git a/_layouts/default.html b/_layouts/default.html index a3c9104..4bcede5 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -30,7 +30,7 @@ layout: compress
- {% include refactor-content.html content=content %} + {{ content }} {% include footer.html %} diff --git a/_layouts/page.html b/_layouts/page.html index 7afb697..8298b4a 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -1,11 +1,14 @@ --- layout: default -# The page layout --- -
-
-
+{% include lang.html %} + +
+ + +
+
{% if page.dynamic_title %}

{% if page.collection == 'tabs' %} @@ -16,26 +19,40 @@ layout: default {% endif %}

- {{ content }} + {% include refactor-content.html content=content %}
{% else %} - {{ content }} + {% include refactor-content.html content=content %} {% endif %} -
-
+
+
- {% include panel.html %} + +
+ +
+ {% include update-list.html %} + {% include trending-tags.html %} +
+ + {% for _include in layout.pannel_includes %} + {% assign _include_path = _include | append: '.html' %} + {% include {{ _include_path }} %} + {% endfor %} +
-{% if site.disqus.comments and page.comments %} + +{% if layout.tail_includes %}
-
- - {% include disqus.html %} - -
-
+
+ {% for _include in layout.tail_includes %} + {% assign _include_path = _include | append: '.html' %} + {% include {{ _include_path }} %} + {% endfor %} +
+
{% endif %} diff --git a/_layouts/post.html b/_layouts/post.html index 961f0de..8e78eb9 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,143 +1,110 @@ --- -layout: default -# The posts' layout +layout: page +pannel_includes: + - toc +tail_includes: + - related-posts + - post-nav + - disqus --- {% include lang.html %} -
+

{{ page.title }}

-
+ - - {% assign enable_toc = false %} - - {% if site.toc and page.toc %} - {% if content contains ' + + {% if page.last_modified_at %} + + {{ site.data.locales[lang].post.updated }} + {% include timeago.html date=page.last_modified_at class="lastmod" tooltip=true %} + {% endif %} + + + {% include read-time.html content=content prompt=true %} + + + {% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %} + + + + {{ site.data.locales[lang].post.pageview_measure }} + {% endif %} + +
+ +
+ +
+ + {% if page.image.src %} + {{ page.image.alt | default: {% endif %} - {% include panel.html toc=enable_toc %} + {{ content }} -
+
-
-
-
+
- {% include related-posts.html %} + + {% if page.categories.size > 0 %} + + {% endif %} - {% include post-nav.html %} + + {% if page.tags.size > 0 %} + + {% endif %} - {% if site.disqus.comments and page.comments %} - {% include disqus.html %} - {% endif %} +
+
-
+ {% if site.data.locales[lang].copyright.license.template %} -
+ {% capture _replacement %} + + {{ site.data.locales[lang].copyright.license.name }} + + {% endcapture %} -
+ {{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }} + + {% endif %} +
+ + {% include post-sharing.html %} + +
+ +