diff options
Diffstat (limited to 'templates/macros')
| -rw-r--r-- | templates/macros/head.html | 198 | ||||
| -rw-r--r-- | templates/macros/macros.html | 43 | ||||
| -rw-r--r-- | templates/macros/page.html | 10 | ||||
| -rw-r--r-- | templates/macros/social.html | 67 |
4 files changed, 262 insertions, 56 deletions
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() %} + <link rel="stylesheet" href="{{ get_url(path=config.extra.stylesheet, trailing_slash=false, cachebust=true) | safe }}"> +{%- 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]?://") %} + <link rel="preload" as="style" href="{{ i.url | safe }}"> + {%- else %} + <link rel="preload" as="font" href="{{ get_url(path=i.url, trailing_slash=false, cachebust=true) }}"> + {%- endif %} +{%- endfor %}{%- endif %} + +{%- if config.build_search_index %} + <script defer type="text/javascript" src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"></script> + <script defer type="text/javascript" src="{{ get_url(path=config.extra.js_search, trailing_slash=false, cachebust=true) | safe }}"></script> +{%- endif %} + +{%- if config.generate_feed %} + <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ get_url(path=config.extra.rss_atom_feed, trailing_slash=false) }}"> +{%- endif %} + +{%- endmacro %} + + +{%- macro favicons() %} + {%- if config.extra.favicon_theme_color %} + <meta name="theme-color" content="{{ config.extra.favicon_theme_color }}"> + {%- endif %} + + {%- if config.extra.favicon_ms_color %} + <meta name="msapplication-TileColor" content="{{ config.extra.favicon_ms_color }}"> + {%- endif %} + + {%- if config.extra.favicon_webmanifest %} + <link rel="manifest" href="{{ get_url(path=config.extra.favicon_webmanifest, trailing_slash=false) | safe }}"> + {%- endif %} + + {%- if config.extra.favicon_mask and config.extra.favicon_mask_color %} + <link rel="mask-icon" href="{{ get_url(path=config.extra.favicon_mask, trailing_slash=false) | safe }}" color="{{ config.extra.favicon_mask_color }}"> + {%- endif %} + + {%- if config.extra.favicon180 %} + <link rel="apple-touch-icon" sizes="180x180" href="{{ get_url(path=config.extra.favicon180, trailing_slash=false) | safe }}" /> + {%- endif %} + + {%- if config.extra.favicon32 %} + <link rel="icon" type="image/png" sizes="32x32" href="{{ get_url(path=config.extra.favicon32, trailing_slash=false) | safe }}" /> + {%- endif %} + + {%- if config.extra.favicon16 %} + <link rel="icon" type="image/png" sizes="16x16" href="{{ get_url(path=config.extra.favicon16, trailing_slash=false) | safe }}" /> + {%- 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 -%} + <meta name="robots" content="noindex, follow"> +{%- else -%} + <meta name="robots" content="index, follow"> + <meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> + <meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> +{%- endif -%} + +{%- if current_url %} + {%- set page_url = current_url %} +{%- else %} + {%- set page_url = get_url(path="404.html", trailing_slash=true) %} +{%- endif %} + <title>{{ title ~ title_addition }}</title> + +{%- if config.extra.author %} + <meta name="author" content="{{ config.extra.author }}"> +{%- endif %} +{%- if config.extra.facebook_publisher %} + <meta property="article:publisher" content="https://www.facebook.com/{{ config.extra.facebook_publisher }}"> +{%- endif %} + <meta name="copyright" content="{{ title }}"> +{%- if config.extra.facebook_author %} + <meta property="article:author" content="https://www.facebook.com/{{ config.extra.facebook_author }}"> +{%- endif %} +{%- if page.description %} + <meta name="description" content="{{ page.description }}" /> +{%- else %} + <meta name="description" content="{{ config.description }}" /> +{%- endif %} + <link rel="canonical" href="{{ page_url | safe }}"> +{%- if page.extra.keywords %} + <meta name="keywords" content="{{ page.extra.keywords }}, {{ config.extra.keywords }}"> +{%- else %} + <meta name="keywords" content="{{ config.extra.keywords }}"> +{%- endif %} + +{#- Extra SEO START #} +{%- if config.extra.seo | default(value=true) %} +{%- if not is_404 %} + +{%- if config.extra.google %} + <meta name="google-site-verification" content="{{ config.extra.google | safe }}"> +{%- endif %} + +{%- if config.extra.bing %} + <meta name="msvalidate.01" content="{{ config.extra.bing | safe}}"> +{%- endif %} + <meta property="og:url" content="{{ page_url | safe }}"> + <meta name="twitter:url" content="{{ page_url | safe }}"> + +{%- if page.description %} + <meta property="og:description" content="{{ page.description }}"> + <meta name="twitter:description" content="{{ page.description }}"> +{%- else %} + <meta property="og:description" content="{{ config.description }}"> + <meta name="twitter:description" content="{{ config.description}}"> +{%- endif %} + +{%- if page.title %} + <meta property="og:title" content="{{ page.title }} | {{ title }}"> + <meta name="twitter:title" content="{{ page.title }} | {{ title }}"> +{%- else %} + <meta property="og:title" content="{{ title }}"> + <meta name="twitter:title" content="{{ title }}"> +{%- endif %} + + +{#- SEO MEDIA START #} +{%- if page.extra.thumbnail %} + <meta name="twitter:card" content="summary_large_image"> + <meta name="twitter:image" content="{{ get_url(path=page.path ~ page.extra.thumbnail, trailing_slash=false) }}"> + <meta property="og:image" content="{{ get_url(path=page.path ~ page.extra.thumbnail, trailing_slash=false) }}"> + +{%- elif page.extra.static_thumbnail %} + <meta name="twitter:card" content="summary_large_image"> + {%- if page.extra.static_thumbnail is matching("^http[s]?://") %} + <meta name="twitter:image" content="{{ page.extra.static_thumbnail }}"> + <meta property="og:image" content="{{ page.extra.static_thumbnail }}"> + {%- else %} + <meta name="twitter:image" content="{{ get_url(path=page.extra.static_thumbnail, trailing_slash=false) }}"> + <meta property="og:image" content="{{ get_url(path=page.extra.static_thumbnail, trailing_slash=false) }}"> + {%- endif %} + +{%- elif config.extra.banner %} + <meta name="twitter:card" content="summary_large_image"> + <meta name="twitter:image" content="{{ get_url(path=config.extra.banner, trailing_slash=false) }}"> + <meta property="og:image" content="{{ get_url(path=config.extra.banner, trailing_slash=false) }}"> + +{%- else %} + <meta name="twitter:card" content="summary"> + +{%- endif %} + +{%- if config.extra.open.audio %} + <meta property="og:audio" content="{{ config.extra.open.audio }}"> +{%- endif %} + +{%- if config.extra.open.locale %} + <meta property="og:locale" content="{{ config.extra.open.locale }}"> +{%- endif %} + +{%- if config.extra.open.videos %} + {%- for video in config.extra.open.videos %} + <meta property="og:video" content="{{ get_url(path=video) }}"> + {%- endfor %} +{%- endif %} + +{#- SEO MEDIA END #} + <meta property="og:site_name" content="{{ title }}"> + <meta property="og:locale" content="en_US"> + <meta property="og:type" content="website"> + <meta property="og:updated_time" content="{{ now() }}"> + +{%- if config.extra.social.twitter %} + <meta name="twitter:site" content="@{{ config.extra.twitter }}"> + <meta name="twitter:creator" content="@{{ config.extra.twitter }}"> +{%- endif %} + + + +{%- endif %} +{%- endif %} +{#- Extra SEO END #} +{%- endmacro %} + +{%- macro math() %} + {%- if config.extra.katex_enabled %} + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous"> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script> + {%- if config.extra.katex_auto_render %} + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script> + {%- 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) %} -<h1><a href="{{ page.permalink | safe }}">{{ page.title }}</a></h1> -<span>{{ page.date | date(format="%B %d, %Y") }} +{%- macro title(page) %} + <h1><a href="{{ page.permalink | safe }}">{{ page.title }}</a></h1> + <span>{{ 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 %} + <a href="{{ get_taxonomy_url(kind='authors', name=author) | safe }}">{{ author }}</a> + {%- 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 %}<a href="{{ get_taxonomy_url(kind="categories", name=cat) | safe }}">{{ cat }}</a>{% endfor %}]{% endif %} +{%- if page.taxonomies.tags %} {%- for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind="tags", name=tag) | safe }}">{{ tag }}</a> {% endfor -%}{%- endif %} +{%- if config.extra.readtime %} - {{ page.reading_time }} {{ config.extra.readtime_string | default(value="min") }} {% endif %} + </span> +{%- endmacro title %} -{% if page.taxonomies.authors and config.taxonomies %} by - {% for author in page.taxonomies.authors %} - {% if author_flag %} and {% endif %} - <a href="{{ get_taxonomy_url(kind='authors', name=author) | safe }}">{{ author }}</a> - {% 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 %}<a href="{{ get_taxonomy_url(kind="categories", name=cat) | safe }}">{{ cat }}</a>{% endfor %}]{% endif %}</span> -{% if page.taxonomies.tags %} - <span>{% for tag in page.taxonomies.tags %} #<a href="{{ get_taxonomy_url(kind="tags", name=tag) | safe }}">{{ tag }}</a> {% endfor %}</span> -{% endif %} - -{% if config.extra.readtime | default(value=true) %} - - {{ page.reading_time }} min -{% endif %} -{% endmacro title %} - - -{% macro footer(page) %} +{%- macro footer(page) %} <h3><a href="#">Back to top</a></h3> -{% 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) %} - <div class="toc-item"> - <a href="{{ page.permalink | safe}}" title="{{ page.title }}">{{ page.title }}</a> - </div> -{% endmacro page_listing %} +{%- macro page_listing(page) %} + <div class="toc-item"> + <a href="{{ page.permalink | safe}}" title="{{ page.title }}">{{ page.title }}</a> + </div> +{%- 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) %} -<span> -{% if config.generate_feed %}{% if config.extra.social.feed %} <a href="{{ get_url(path="atom.xml") }}" target="_blank"><span class="svg rss" title="Rss"></span></a>{% endif %}{% endif %} - -{% if social_config.mail %} <a href="mailto:{{ social_config.mail }}" target="_blank"><span class="svg mail" title="Mail"></span></a>{% endif %} -{% if social_config.mastodon %} <a href="{{ social_config.mastodon }}/" target="_blank"><span class="svg mastodon" title="Mastodon"></span></a>{% endif %} -{% if social_config.element %} <a href="https://{{ social_config.element }}/" target="_blank"><span class="svg element" title="Element"></span></a>{% endif %} -{% if social_config.matrix %} <a href="https://{{ social_config.matrix }}/" target="_blank"><span class="svg matrix" title="Matrix"></span></a>{% endif %} -{% if social_config.twitter %} <a href="https://twitter.com/{{ social_config.twitter }}/" target="_blank"><span class="svg twitter" title="Twitter"></span></a>{% endif %} -{% if social_config.facebook %} <a href="https://www.facebook.com/{{ social_config.facebook }}/" target="_blank"><span class="svg facebook" title="Facebook"></span></a>{% endif %} -{% if social_config.linkedin %} <a href="https://www.linkedin.com/in/{{ social_config.linkedin }}/" target="_blank"><span class="svg linkedin" title="LinkedIn"></span></a>{% endif %} - -{% if social_config.gitlab %} <a href="https://gitlab.com/{{ social_config.gitlab }}/" target="_blank"><span class="svg gitlab" title="Gitlab"></span></a>{% endif %} -{% if social_config.github %} <a href="https://github.com/{{ social_config.github }}/" target="_blank"><span class="svg github" title="Github"></span></a>{% endif %} -{% if social_config.bitbucket %} <a href="https://bitbucket.org/{{ social_config.bitbucket }}/" target="_blank"><span class="svg bitbucket" title="Bitbucket"></span></a>{% endif %} -{% if social_config.python %} <a href="https://pypi.org/user/{{ social_config.python }}/" target="_blank"><span class="svg python" title="Python"></span></a>{% endif %} -{% if social_config.docker %} <a href="https://hub.docker.com/u/{{ social_config.docker }}/" target="_blank"><span class="svg docker" title="Docker"></span></a>{% endif %} -{% if social_config.stack %} <a href="https://stackoverflow.com/users/{{ social_config.stack }}/" target="_blank"><span class="svg stack" title="Stack"></span></a>{% endif %} - -{% if social_config.instagram %} <a href="https://www.instagram.com/{{ social_config.instagram }}/" target="_blank"><span class="svg instagram" title="Instagram"></span></a>{% endif %} -{% if social_config.pinterest %} <a href="https://www.pinterest.com/{{ social_config.pinterest }}/" target="_blank"><span class="svg pinterest" title="Pinterest"></span></a>{% endif %} -{% if social_config.twitch %} <a href="https://www.twitch.tv/{{ social_config.twitch }}/" target="_blank"><span class="svg twitch" title="Twitch"></span></a>{% endif %} -{% if social_config.youtube %} <a href="https://www.youtube.com/channel/{{ social_config.youtube }}/" target="_blank"><span class="svg youtube" title="YouTube"></span></a>{% endif %} -</span> -{% endmacro %} +{%- macro social_links(social_config) %} +{%- set base_url = get_url(path="", lang=lang) %} + <span> + {%- if config.generate_feed %}{%- if config.extra.social.feed %} + <a href="{{ get_url(path="atom.xml") }}" target="_blank"><span class="svg rss" title="Rss"></span></a>{% endif %}{% endif %} + {%- if social_config.mail %} + <a href="mailto:{{ social_config.mail }}" target="_blank"><span class="svg mail" title="Mail"></span></a>{% endif %} + {%- if social_config.mastodon %} + <a href="{{ social_config.mastodon }}/" target="_blank"><span class="svg mastodon" title="Mastodon"></span></a>{% endif %} + {%- if social_config.element %} + <a href="https://{{ social_config.element }}/" target="_blank"><span class="svg element" title="Element"></span></a>{% endif %} + {%- if social_config.matrix %} + <a href="https://{{ social_config.matrix }}/" target="_blank"><span class="svg matrix" title="Matrix"></span></a>{% endif %} + {%- if social_config.twitter %} + <a href="https://twitter.com/{{ social_config.twitter }}/" target="_blank"><span class="svg twitter" title="Twitter"></span></a>{% endif %} + {%- if social_config.facebook %} + <a href="https://www.facebook.com/{{ social_config.facebook }}/" target="_blank"><span class="svg facebook" title="Facebook"></span></a>{% endif %} + {%- if social_config.linkedin %} + <a href="https://www.linkedin.com/in/{{ social_config.linkedin }}/" target="_blank"><span class="svg linkedin" title="LinkedIn"></span></a>{% endif %} + {%- if social_config.gitlab %} + <a href="https://gitlab.com/{{ social_config.gitlab }}/" target="_blank"><span class="svg gitlab" title="Gitlab"></span></a>{% endif %} + {%- if social_config.github %} + <a href="https://github.com/{{ social_config.github }}/" target="_blank"><span class="svg github" title="Github"></span></a>{% endif %} + {%- if social_config.bitbucket %} + <a href="https://bitbucket.org/{{ social_config.bitbucket }}/" target="_blank"><span class="svg bitbucket" title="Bitbucket"></span></a>{% endif %} + {%- if social_config.python %} + <a href="https://pypi.org/user/{{ social_config.python }}/" target="_blank"><span class="svg python" title="Python"></span></a>{% endif %} + {%- if social_config.docker %} + <a href="https://hub.docker.com/u/{{ social_config.docker }}/" target="_blank"><span class="svg docker" title="Docker"></span></a>{% endif %} + {%- if social_config.stack %} + <a href="https://stackoverflow.com/users/{{ social_config.stack }}/" target="_blank"><span class="svg stack" title="Stack"></span></a>{% endif %} + {%- if social_config.instagram %} + <a href="https://www.instagram.com/{{ social_config.instagram }}/" target="_blank"><span class="svg instagram" title="Instagram"></span></a>{% endif %} + {%- if social_config.pinterest %} + <a href="https://www.pinterest.com/{{ social_config.pinterest }}/" target="_blank"><span class="svg pinterest" title="Pinterest"></span></a>{% endif %} + {%- if social_config.twitch %} + <a href="https://www.twitch.tv/{{ social_config.twitch }}/" target="_blank"><span class="svg twitch" title="Twitch"></span></a>{% endif %} + {%- if social_config.youtube %} + <a href="https://www.youtube.com/channel/{{ social_config.youtube }}/" target="_blank"><span class="svg youtube" title="YouTube"></span></a>{% endif %} + </span> +{%- endmacro %} |
