From 30ea88e8d8c201c3fcce409a54712de820610dff Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 30 May 2022 23:20:43 -0700 Subject: Add Favicons, Add Head Macro, 404 noindex, config.toml Resources, Whitespace Cleanup --- templates/404.html | 39 +++---- templates/base.html | 238 ++++++++++----------------------------- templates/categories/list.html | 26 ++--- templates/categories/single.html | 20 ++-- templates/contact.html | 4 +- templates/index.html | 111 ++++++++++-------- templates/macros/head.html | 198 ++++++++++++++++++++++++++++++++ templates/macros/macros.html | 43 +++---- templates/macros/page.html | 10 +- templates/macros/social.html | 67 ++++++----- templates/page.html | 65 +++++------ templates/pages.html | 8 +- templates/posts.html | 20 ++-- templates/tags/list.html | 26 ++--- templates/tags/single.html | 20 ++-- 15 files changed, 499 insertions(+), 396 deletions(-) create mode 100644 templates/macros/head.html (limited to 'templates') diff --git a/templates/404.html b/templates/404.html index 3b02be6..401d657 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,23 +1,24 @@ {% extends "base.html" %} -{# Title #} -{% block title %} - Sorry! Page not found. -{% endblock title %} -{% block current_url %} - {% if config.extra.seo | default(value=true) %} - - - {% endif %} -{% endblock current_url %} +{%- block seo %} + {{ super() }} + {%- set title = "404 Page not found" %} -{# Page heading #} + {%- if config.title %} + {%- set title_addition = title_separator ~ config.title %} + {%- else %} + {%- set title_addition = "" %} + {%- endif %} -{% block content %} -
-

404 Error

-

Sorry

-

The requested page does not exist or has been moved to another address.

-

Please go back to home.

-
-{% endblock content %} + {%- set description = config.description %} + + {{- macros_head::seo(title=title, title_addition=title_addition, description=description, is_404=true) }} +{%- endblock seo %} + +{%- block content %} +
+

Page not found :(

+

The page you are looking for doesn't exist or has been moved.

+

Try using the search, or go home.

+
+{%- endblock content %} diff --git a/templates/base.html b/templates/base.html index e811e33..237bf41 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,158 +1,32 @@ -{% import "macros/social.html" as social_macros %} +{%- import 'macros/head.html' as macros_head %} +{%- import "macros/social.html" as social_macros %} +{%- import "macros/page.html" as page_macros %} +{%- import "macros/macros.html" as macros %} - + - + - - {% block title %}{% if page.title %}{{ page.title }} | {% endif %}{{ config.title }}{% endblock title %} - - {% if is_404 %} - - {% else %} - - - - {% endif %} - {% if current_url %} - {% set page_url = current_url %} - {% else %} - {% set page_url = get_url(path="404.html") %} - {% endif %} - {% if current_path %} - {% set page_path = current_path %} - {% else %} - {% set page_path = "/404.html" %} - {% endif %} - - {% block description %} - {% if page.description %} - - - {% if config.extra.seo | default(value=true) %} - - - {% endif %} - - {% else %} - - - {% if config.extra.seo | default(value=true) %} - - - {% endif %} - - {% endif %} - {% endblock description %} - - {% if page.extra.keywords %} - - {% else %} - - {% endif %} - - - - - {% if config.extra.google %}{% endif %} - {% if config.extra.bing %}{% endif %} + {{- macros_head::resource() }} + {{- macros_head::stylesheet() }} + {%- block seo %} + {%- if config.extra.title_separator %} + {%- set title_separator = " " ~ config.extra.title_separator ~ " " -%} + {%- else %} + {%- set title_separator = " | " -%} + {%- endif %} + {%- endblock seo %} + {{- macros_head::favicons() }} - - - {% block css %}{% endblock css %} - - {% if config.extra.favicon %} - - {% endif %} - - - {% if config.generate_feed %}{% endif %} - - {% if config.extra.seo | default(value=true) %} - {% block ogp_head %} - {% if page.title %} - - - {% else %} - - - {% endif %} - - - - - - {% endblock ogp_head %} - - {% block current_url %} - - - {% endblock current_url %} - - {% if config.extra.social.twitter %} - - - {% endif %} - - {% if page.extra.thumbnail %} - - - - {% elif page.extra.static_thumbnail %} - {%if page.extra.static_thumbnail is matching("^http[s]?://") %} - - - - {% else %} - - - - {% endif %} - {% elif config.extra.default_og_image %} - - - - {% elif config.extra.banner %} - - - - {% else %} - - {% endif %} - {% endif %} - - {% if config.extra.fonts_load %} - {% for i in config.extra.fonts %} - {% if 'http' in i.url %} - - {% else %} - - {% endif %} - {% endfor %} - {% endif %} - - {% if config.build_search_index %} - - - {% endif %} - - {% if config.extra.katex_enabled %} - - - - {% if config.extra.katex_auto_render %} - - {% endif %} - {% endif %} -{% block extra_head %}{% endblock extra_head %} + {{- macros_head::math() }} -{% block header %} +{%- block header %}
- {% if config.extra.sitedesc %} - {% if config.description %} -
{{ config.description }}
- {% endif %} - {% endif %} + {%- if config.extra.sitedesc %} + {%- if config.description %} +
{{ config.description }}
+ {%- endif %} + {%- endif %}
-{% endblock header %} -
-{% block content %} -{% endblock content %} -
-{% block footer %} +{%- endblock header %} +
+ {%- block content %} + {%- endblock content %} +
+{%- block footer %} -{% endblock footer %} +{%- endblock footer %} diff --git a/templates/categories/list.html b/templates/categories/list.html index bce31fa..485d54d 100644 --- a/templates/categories/list.html +++ b/templates/categories/list.html @@ -1,16 +1,16 @@ {% extends "base.html" %} -{% block content %} -
-
-

{{ terms | length }} Categories

-

{% for term in terms -%}[{{ term.name }}]   {%- endfor %}

-
- {% for term in terms -%} -

{{ term.name }}

- {% for page in term.pages -%} +{%- block content %} +
+
+

{{ terms | length }} Categories

+

{%- for term in terms %}[{{ term.name }}]   {%- endfor %}

+
+ {%- for term in terms %} +

{{ term.name }}

+ {%- for page in term.pages %}

{{ page.title }} -

- {% endfor -%} - {% endfor -%} -
-{% endblock content %} + {%- endfor %} + {%- endfor %} +
+{%- endblock content %} diff --git a/templates/categories/single.html b/templates/categories/single.html index 641add7..0fe639d 100644 --- a/templates/categories/single.html +++ b/templates/categories/single.html @@ -1,13 +1,13 @@ {% extends "base.html" %} -{% block content %} -
-

{{ term.name }}

- {% for year, posts in term.pages | group_by(attribute="year") %} -

{{ year }}

- {% for page in posts %} +{%- block content %} +
+

{{ term.name }}

+ {%- for year, posts in term.pages | group_by(attribute="year") %} +

{{ year }}

+ {%- for page in posts %}

{{ page.title }} -

- {% endfor %} - {% endfor %} -
-{% endblock content %} + {%- endfor %} + {%- endfor %} +
+{%- endblock content %} diff --git a/templates/contact.html b/templates/contact.html index 6cdbc55..7304551 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block content %} +{%- block content %}

Want to get in touch? Fill out the form below to send me a message and I will get back to you as soon as possible!

@@ -22,4 +22,4 @@

-{% endblock content %} +{%- endblock content %} diff --git a/templates/index.html b/templates/index.html index abc29c0..c17ee63 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,57 +1,74 @@ -{% import "macros/page.html" as page_macros %} -{% import "macros/macros.html" as macros %} -{% extends "base.html" %} -{% block content %} -
- {% for page in paginator.pages %} +{%- extends "base.html" %} + +{%- block seo %} + {{- super() }} + + {%- if config.title %} + {%- set title = config.title %} + {%- else %} + {%- set title = "" %} + {%- endif %} + + {%- if config.extra.title_addition and title %} + {%- set title_addition = title_separator ~ config.extra.title_addition %} + {%- elif config.extra.title_addition %} + {%- set title_addition = config.extra.title_addition %} + {%- else %} + {%- set title_addition = "" %} + {%- endif %} + + {%- set description = config.description %} + + {{- macros_head::seo(title=title, title_addition=title_addition, description=description, is_home=true) }} +{%- endblock seo %} + +{%- block content %} +
+ {%- for page in paginator.pages %}
- {{ macros::title(page=page) }} + {{- macros::title(page=page) }}

- {% if page.summary -%} - {{ page.summary | markdown(inline=true) | safe }} - {% elif page.description %} - {{ page.description | safe }} - {% elif page.content %} - {{ page.content | safe | striptags | truncate(length=150) }} - {% elif page.extra.static_thumbnail %} - {% endif -%} + {%- if page.summary %} + {{ page.summary | markdown(inline=true) | safe }} + {%- elif page.description %} + {{ page.description | safe }} + {%- elif page.content %} + {{ page.content | safe | striptags | truncate(length=150) }} + {%- elif page.extra.static_thumbnail %} + {%- endif %} ...more

- {% endfor %} - {% if paginator.previous or paginator.next %} - - {% endif -%} -
- {% set section_item = get_section(path="_index.md") %} - {% if config.extra.recent | default(value=true) %} + {%- endfor %} + {%- if paginator.previous or paginator.next %} + + {%- endif %} +
+ {%- set section_item = get_section(path="_index.md") %} + {%- if config.extra.recent | default(value=true) %}

Recent Posts

- {% for page in section_item.pages | slice(end=config.extra.recent_items) %} - {{ page_macros::page_listing(page=page) }} - {% endfor %} + {%- for page in section_item.pages | slice(end=config.extra.recent_items) %} + {{- page_macros::page_listing(page=page) }} + {%- endfor %}
- {% endif %} -{% endblock content %} + {%- endif %} +{%- endblock content %} diff --git a/templates/macros/head.html b/templates/macros/head.html new file mode 100644 index 0000000..bea8f66 --- /dev/null +++ b/templates/macros/head.html @@ -0,0 +1,198 @@ +{%- macro stylesheet() %} + +{%- endmacro %} + + +{%- macro resource() %} +{%- if config.extra.fonts_load and config.extra.fonts %}{%- for i in config.extra.fonts %} + {%- if i.url is matching("^http[s]?://") %} + + {%- else %} + + {%- endif %} +{%- endfor %}{%- endif %} + +{%- if config.build_search_index %} + + +{%- endif %} + +{%- if config.generate_feed %} + +{%- endif %} + +{%- endmacro %} + + +{%- macro favicons() %} + {%- if config.extra.favicon_theme_color %} + + {%- endif %} + + {%- if config.extra.favicon_ms_color %} + + {%- endif %} + + {%- if config.extra.favicon_webmanifest %} + + {%- endif %} + + {%- if config.extra.favicon_mask and config.extra.favicon_mask_color %} + + {%- endif %} + + {%- if config.extra.favicon180 %} + + {%- endif %} + + {%- if config.extra.favicon32 %} + + {%- endif %} + + {%- if config.extra.favicon16 %} + + {%- endif %} +{%- endmacro %} + + +{#- type: website or article, generally setting article for blog articles -#} +{#- page_images: using for the blog single template page -#} +{#- page_section: the blog single template page have to pass the parameter -#} +{#- is_404: using for the 404.html template -#} +{%- macro seo( title="",title_addition="",description="",type="website",is_home=false,is_404=false,is_page=false,page_images="",page_section="",created_time="2021-05-01T08:08:00+08:00", updated_time="2021-05-01T08:08:08+08:00" ) %} +{%- if is_404 -%} + +{%- else -%} + + + +{%- endif -%} + +{%- if current_url %} + {%- set page_url = current_url %} +{%- else %} + {%- set page_url = get_url(path="404.html", trailing_slash=true) %} +{%- endif %} + {{ title ~ title_addition }} + +{%- if config.extra.author %} + +{%- endif %} +{%- if config.extra.facebook_publisher %} + +{%- endif %} + +{%- if config.extra.facebook_author %} + +{%- endif %} +{%- if page.description %} + +{%- else %} + +{%- endif %} + +{%- if page.extra.keywords %} + +{%- else %} + +{%- endif %} + +{#- Extra SEO START #} +{%- if config.extra.seo | default(value=true) %} +{%- if not is_404 %} + +{%- if config.extra.google %} + +{%- endif %} + +{%- if config.extra.bing %} + +{%- endif %} + + + +{%- if page.description %} + + +{%- else %} + + +{%- endif %} + +{%- if page.title %} + + +{%- else %} + + +{%- endif %} + + +{#- SEO MEDIA START #} +{%- if page.extra.thumbnail %} + + + + +{%- elif page.extra.static_thumbnail %} + + {%- if page.extra.static_thumbnail is matching("^http[s]?://") %} + + + {%- else %} + + + {%- endif %} + +{%- elif config.extra.banner %} + + + + +{%- else %} + + +{%- endif %} + +{%- if config.extra.open.audio %} + +{%- endif %} + +{%- if config.extra.open.locale %} + +{%- endif %} + +{%- if config.extra.open.videos %} + {%- for video in config.extra.open.videos %} + + {%- endfor %} +{%- endif %} + +{#- SEO MEDIA END #} + + + + + +{%- if config.extra.social.twitter %} + + +{%- endif %} + + + +{%- endif %} +{%- endif %} +{#- Extra SEO END #} +{%- endmacro %} + +{%- macro math() %} + {%- if config.extra.katex_enabled %} + + + + {%- if config.extra.katex_auto_render %} + + {%- endif %} + {%- endif %} +{%- endmacro %} diff --git a/templates/macros/macros.html b/templates/macros/macros.html index f343828..82e856a 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -1,28 +1,21 @@ -{% macro title(page) %} -

{{ page.title }}

-{{ page.date | date(format="%B %d, %Y") }} +{%- macro title(page) %} +

{{ page.title }}

+ {{ page.date | date(format="%B %d, %Y") }} + {%- if page.taxonomies.authors and config.taxonomies %} by + {%- for author in page.taxonomies.authors %} + {%- if author_flag %} and {% endif %} + {{ author }} + {%- set_global author_flag = true %} + {%- endfor %} + {%- elif config.extra.author and config.extra.author_show %} by {{ config.extra.author }} + {%- endif %} +{%- if page.taxonomies.categories %} [{% for cat in page.taxonomies.categories %}{{ cat }}{% endfor %}]{% endif %} +{%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #{{ tag }} {% endfor -%}{%- endif %} +{%- if config.extra.readtime %} - {{ page.reading_time }} {{ config.extra.readtime_string | default(value="min") }} {% endif %} + +{%- endmacro title %} -{% if page.taxonomies.authors and config.taxonomies %} by - {% for author in page.taxonomies.authors %} - {% if author_flag %} and {% endif %} - {{ author }} - {% set_global author_flag = true %} - {% endfor %} -{% elif config.extra.author and config.extra.author_show %} - by {{ config.extra.author }} -{% endif %} -{% if page.taxonomies.categories %} [{% for cat in page.taxonomies.categories %}{{ cat }}{% endfor %}]{% endif %}
-{% if page.taxonomies.tags %} - {% for tag in page.taxonomies.tags %} #{{ tag }} {% endfor %} -{% endif %} - -{% if config.extra.readtime | default(value=true) %} - - {{ page.reading_time }} min -{% endif %} -{% endmacro title %} - - -{% macro footer(page) %} +{%- macro footer(page) %}

Back to top

-{% endmacro footer %} +{%- endmacro footer %} diff --git a/templates/macros/page.html b/templates/macros/page.html index 0029e13..d5ef918 100644 --- a/templates/macros/page.html +++ b/templates/macros/page.html @@ -1,5 +1,5 @@ -{% macro page_listing(page) %} -
- {{ page.title }} -
-{% endmacro page_listing %} +{%- macro page_listing(page) %} +
+ {{ page.title }} +
+{%- endmacro page_listing %} diff --git a/templates/macros/social.html b/templates/macros/social.html index 6d45b9e..06f4a7c 100644 --- a/templates/macros/social.html +++ b/templates/macros/social.html @@ -1,26 +1,41 @@ -{% macro social_links(social_config) %} -{% set base_url = get_url(path="", lang=lang) %} - -{% if config.generate_feed %}{% if config.extra.social.feed %} {% endif %}{% endif %} - -{% if social_config.mail %} {% endif %} -{% if social_config.mastodon %} {% endif %} -{% if social_config.element %} {% endif %} -{% if social_config.matrix %} {% endif %} -{% if social_config.twitter %} {% endif %} -{% if social_config.facebook %} {% endif %} -{% if social_config.linkedin %} {% endif %} - -{% if social_config.gitlab %} {% endif %} -{% if social_config.github %} {% endif %} -{% if social_config.bitbucket %} {% endif %} -{% if social_config.python %} {% endif %} -{% if social_config.docker %} {% endif %} -{% if social_config.stack %} {% endif %} - -{% if social_config.instagram %} {% endif %} -{% if social_config.pinterest %} {% endif %} -{% if social_config.twitch %} {% endif %} -{% if social_config.youtube %} {% endif %} - -{% endmacro %} +{%- macro social_links(social_config) %} +{%- set base_url = get_url(path="", lang=lang) %} + + {%- if config.generate_feed %}{%- if config.extra.social.feed %} + {% endif %}{% endif %} + {%- if social_config.mail %} + {% endif %} + {%- if social_config.mastodon %} + {% endif %} + {%- if social_config.element %} + {% endif %} + {%- if social_config.matrix %} + {% endif %} + {%- if social_config.twitter %} + {% endif %} + {%- if social_config.facebook %} + {% endif %} + {%- if social_config.linkedin %} + {% endif %} + {%- if social_config.gitlab %} + {% endif %} + {%- if social_config.github %} + {% endif %} + {%- if social_config.bitbucket %} + {% endif %} + {%- if social_config.python %} + {% endif %} + {%- if social_config.docker %} + {% endif %} + {%- if social_config.stack %} + {% endif %} + {%- if social_config.instagram %} + {% endif %} + {%- if social_config.pinterest %} + {% endif %} + {%- if social_config.twitch %} + {% endif %} + {%- if social_config.youtube %} + {% endif %} + +{%- endmacro %} diff --git a/templates/page.html b/templates/page.html index f92574e..6ea50d6 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,40 +1,35 @@ {% extends "base.html" %} {% import "macros/macros.html" as macros %} -{{config.title}} - {{page.title}} -{% block content %} -
- {{ macros::title(page=page) }} +{%- block content %} +
+ {{- macros::title(page=page) }} {{ page.content | safe }} - {% block page_before_footer %} - {% endblock page_before_footer %} - {% block page_footer %} - {{ macros::footer(page=page) }} - {% endblock page_footer %} - {% block page_after_footer %} - {% endblock page_after_footer %} -
- {% block toc %} - {% if page.extra.toc %} - {% set toc = page.toc %} - {% endif %} - {% if toc %} -
-
-

Index

- {% for h in toc %} - - {% if h.children %} - {% for h2 in h.children %} - - {% endfor %} - {% endif %} - {% endfor %} + {%- block page_footer %} + {{- macros::footer(page=page) }} + {%- endblock page_footer %} +
+ {%- block toc %} + {%- if page.extra.toc %} + {%- set toc = page.toc %} + {%- endif %} + {%- if toc %} +
+
+

Index

+ {%- for h in toc %} + + {%- if h.children %} + {%- for h2 in h.children %} + + {%- endfor %} + {%- endif %} + {%- endfor %}
- {% endif %} - {% endblock toc %} -{% endblock content %} +
+ {%- endif %} + {%- endblock toc %} +{%- endblock content %} diff --git a/templates/pages.html b/templates/pages.html index 3d2ca80..a9147c7 100644 --- a/templates/pages.html +++ b/templates/pages.html @@ -1,4 +1,6 @@ {% extends "base.html" %} -{% block content %} -
{{ page.content | safe }}
-{% endblock content %} +{%- block content %} +
+ {{ page.content | safe }} +
+{%- endblock content %} diff --git a/templates/posts.html b/templates/posts.html index f093e8e..3d4184d 100644 --- a/templates/posts.html +++ b/templates/posts.html @@ -1,12 +1,12 @@ {% extends "base.html" %} -{% block content %} - {% set section_item = get_section(path="_index.md") %} -
- {% for year, posts in section_item.pages | group_by(attribute="year") %} +{%- block content %} +{%- set section_item = get_section(path="_index.md") %} +
+ {%- for year, posts in section_item.pages | group_by(attribute="year") %}

{{ year }}

- {% for post in posts %} -

{{ post.title }} - {{ post.date | date(format="%F") }}

- {% endfor %} - {% endfor %} -
-{% endblock content %} + {%- for post in posts %} +

{{ post.title }} - {{ post.date | date(format="%F") }}

+ {%- endfor %} + {%- endfor %} +
+{%- endblock content %} diff --git a/templates/tags/list.html b/templates/tags/list.html index 56575df..2dd3497 100644 --- a/templates/tags/list.html +++ b/templates/tags/list.html @@ -1,16 +1,16 @@ {% extends "base.html" %} -{% block content %} -
-
-

{{ terms | length }} Tags

-

{% for term in terms -%}#{{ term.name }}   {%- endfor %}

-
- {% for term in terms -%} +{%- block content %} +
+
+

{{ terms | length }} Tags

+

{%- for term in terms %}#{{ term.name }}   {%- endfor %}

+
+ {%- for term in terms %}

#{{ term.name }}

- {% for page in term.pages -%} -

{{ page.title }} -

- {% endfor -%} - {% endfor -%} -
-{% endblock content %} + {%- for page in term.pages %} +

{{ page.title }} -

+ {%- endfor %} + {%- endfor %} +
+{%- endblock content %} diff --git a/templates/tags/single.html b/templates/tags/single.html index 2bddb8e..d9d03eb 100644 --- a/templates/tags/single.html +++ b/templates/tags/single.html @@ -1,13 +1,13 @@ {% extends "base.html" %} -{% block content %} -
-

{{ term.name }}

- {% for year, posts in term.pages | group_by(attribute="year") %} +{%- block content %} +
+

{{ term.name }}

+ {%- for year, posts in term.pages | group_by(attribute="year") %}

{{ year }}

- {% for page in term.pages %} -

{{ page.title }} -

- {% endfor %} - {% endfor %} -
-{% endblock content %} + {%- for page in term.pages %} +

{{ page.title }} -

+ {%- endfor %} + {%- endfor %} +
+{%- endblock content %} -- cgit v1.3.1