diff options
Diffstat (limited to '')
24 files changed, 424 insertions, 374 deletions
diff --git a/src/themes/serene/templates/_base.html b/src/themes/serene/templates/_base.html index 0bd7b3b..d1f2d48 100644 --- a/src/themes/serene/templates/_base.html +++ b/src/themes/serene/templates/_base.html @@ -1,3 +1,4 @@ +{% set color_scheme = config.extra.color_scheme if config.extra.color_scheme is defined else "auto" %} <!DOCTYPE html> <html lang="{% block lang %}{% endblock lang %}"> @@ -18,15 +19,15 @@ {% include "_head_extend.html" %} </head> -<body class="{% block page %}{% endblock page%}{% if config.extra.force_theme == "dark" %} dark{% endif %}"> - {% if not config.extra.force_theme %} +<body class="{% block page %}{% endblock page%}{% if color_scheme == "dark" %} dark{% endif %}"> + {% if color_scheme == "auto" %} <script> const theme = sessionStorage.getItem('theme'); - const match = window.matchMedia("(prefers-color-scheme: dark)").matches + const match = window.matchMedia("(prefers-color-scheme: dark)").matches; if ((theme && theme == 'dark') || (!theme && match)) { document.body.classList.add('dark'); const hl = document.querySelector('link#hl'); - if (hl) hl.href = '{{ get_url(path="hl-dark.css") }}'; + if (hl) hl.href = '{{ get_url(path="giallo-dark.css") }}'; } </script> {% endif %} diff --git a/src/themes/serene/templates/_components/collection.html b/src/themes/serene/templates/_components/collection.html new file mode 100644 index 0000000..70a1d31 --- /dev/null +++ b/src/themes/serene/templates/_components/collection.html @@ -0,0 +1,129 @@ +{# + This component is used inside markdown content, which is rendered as a Tera + template first and *then* processed as markdown (zola >= 0.23). Its HTML + output must therefore stay markdown-safe: no blank lines in the middle of + an HTML block, and no lines indented by 4+ spaces. + + Collection file schema: + layout = "card" | "row" | "tile" | "gallery" (default "card") + flow = "stack" | "inline" | "grid" (default: card/gallery -> "stack", row/tile -> "inline") + [[item]] + title / subtitle / content / icon / image / link / badge / tags / featured / rotate +#} + +{% component collection(file: string, section) -%} +{%- set data = load_data(path="content" ~ section.path ~ file, format="toml") -%} +{%- set layout = data.layout if data.layout is defined else "card" -%} +{%- if layout not in ["card", "row", "tile", "gallery"] -%} +{%- set layout = "card" -%} +{%- endif -%} +{%- if data.flow is defined and data.flow in ["stack", "inline", "grid"] -%} +{%- set flow = data.flow -%} +{%- elif layout == "row" or layout == "tile" -%} +{%- set flow = "inline" -%} +{%- else -%} +{%- set flow = "stack" -%} +{%- endif -%} +{%- if layout == "card" and flow == "inline" -%} +{%- set flow = "grid" -%} +{%- endif -%} +<div class="collection layout-{{ layout }} flow-{{ flow }}"> +{%- for item in data.item -%} +{%- set img_src = "" -%} +{%- if item.image is defined -%} +{%- if item.image is starting_with(pat="http") or item.image is starting_with(pat="/") or item.image is starting_with(pat="data:") -%} +{%- set img_src = item.image -%} +{%- else -%} +{%- set img_src = get_url(path=section.colocated_path ~ item.image) -%} +{%- endif -%} +{%- endif -%} +{%- set icon_src = "" -%} +{%- if item.icon is defined -%} +{%- if item.icon is starting_with(pat="http") or item.icon is starting_with(pat="/") or item.icon is starting_with(pat="data:") -%} +{%- set icon_src = item.icon -%} +{%- else -%} +{%- set icon_src = get_url(path=section.colocated_path ~ item.icon) -%} +{%- endif -%} +{%- endif -%} +{%- set external = item.link is defined and not item.link is starting_with(pat="/") -%} +{%- if layout == "card" -%} +<div class="item{% if item.featured %} featured{% endif %}"> +{%- if img_src -%}<div class="image"><img src="{{ img_src }}" alt="{{ item.title }}"></div>{%- endif -%} +<div class="body"> +<div class="meta"> +{%- if icon_src -%}<span class="icon"><img class="no-lightense" src="{{ icon_src }}" alt="" width="16" height="16"></span>{%- endif -%} +{%- if item.link -%} +<a class="title" href="{{ item.link }}"{% if external %} target="_blank" rel="noreferrer noopener"{% endif %}><span>{{ item.title }}</span></a> +{%- else -%} +<span class="title">{{ item.title }}</span> +{%- endif -%} +{%- if item.badge -%}<span class="badge">{{ item.badge }}</span>{%- endif -%} +</div> +{%- if item.subtitle -%} +<div class="subtitle">{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}</div> +{%- endif -%} +{%- if item.content -%} +<div class="content"> +{{ item.content | trim | markdown | trim | safe }} +</div> +{%- endif -%} +{%- if item.tags -%} +<div class="tags"> +{%- for tag in item.tags -%} +<span class="tag"><span>#</span>{{ tag }}</span> +{%- endfor -%} +</div> +{%- endif -%} +</div> +</div> +{%- elif layout == "row" -%} +<span class="item{% if item.featured %} featured{% endif %}"> +<span class="main"> +{%- if icon_src -%}<span class="icon"><img class="no-lightense" src="{{ icon_src }}" alt="" width="16" height="16"></span>{%- endif -%} +{%- if item.link -%} +<a class="title" href="{{ item.link }}"{% if external %} target="_blank" rel="noreferrer noopener"{% endif %}><span>{{ item.title }}</span></a> +{%- else -%} +<span class="title">{{ item.title }}</span> +{%- endif -%} +</span> +{%- if item.subtitle -%}<span class="subtitle">{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}</span>{%- endif -%} +{%- if item.badge -%}<span class="badge">{{ item.badge }}</span>{%- endif -%} +</span> +{%- elif layout == "tile" -%} +{%- if item.link -%} +<a class="item" href="{{ item.link }}"{% if external %} target="_blank" rel="noreferrer noopener"{% endif %}> +{%- else -%} +<span class="item"> +{%- endif -%} +<span class="text"> +<span class="title">{{ item.title }}</span> +{%- if item.subtitle -%}<span class="subtitle">{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}</span>{%- endif -%} +</span> +{%- if img_src -%} +<img class="no-lightense{% if item.rotate %} rotate{% endif %}" src="{{ img_src }}" alt="{{ item.title }}" width="48" height="48"> +{%- else -%} +<span class="placehold"></span> +{%- endif -%} +{%- if item.link -%}</a>{%- else -%}</span>{%- endif -%} +{%- elif layout == "gallery" -%} +<div class="item"> +{%- if img_src -%}<div class="image"><img src="{{ img_src }}" alt="{{ item.title }}"></div>{%- endif -%} +<div class="text"> +{%- if item.link -%} +<a class="title" href="{{ item.link }}"{% if external %} target="_blank" rel="noreferrer noopener"{% endif %}><span>{{ item.title }}</span></a> +{%- else -%} +<span class="title">{{ item.title }}</span> +{%- endif -%} +{%- if item.subtitle -%}<span class="subtitle">{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}</span>{%- endif -%} +{%- if item.content -%} +<div class="content"> +{{ item.content | trim | markdown | trim | safe }} +</div> +{%- endif -%} +{%- if item.badge -%}<span class="badge">{{ item.badge }}</span>{%- endif -%} +</div> +</div> +{%- endif -%} +{%- endfor -%} +</div> +{%- endcomponent collection %} diff --git a/src/themes/serene/templates/_components/prose.html b/src/themes/serene/templates/_components/prose.html new file mode 100644 index 0000000..c478a58 --- /dev/null +++ b/src/themes/serene/templates/_components/prose.html @@ -0,0 +1,72 @@ +{# + Components in this file are used inside markdown content, which is rendered + as a Tera template first and *then* processed as markdown (zola >= 0.23). + Their HTML output must therefore stay markdown-safe: no blank lines in the + middle of an HTML block, and no lines indented by 4+ spaces. +#} + +{% component back_link(path: string, config) %} +<header> + <nav> + <a id="back-link" href="{{ path }}">← {{ config.extra.back_link_text }}</a> + </nav> +</header> +{% endcomponent back_link %} + + +{% component quote(cite: string = "") -%} +{%- set icon = load_data(path="icon/quote.svg") -%} +<blockquote class="quote"> +<div class="icon" style="display: none;">{{ icon | trim | safe }}</div> +<div class="content"> +{{ body | markdown | trim | safe }} +</div> +{%- if cite -%} +{%- set from_text = "— " ~ cite -%} +<div class="from"> +{{ from_text | markdown | trim | safe }} +</div> +{%- endif -%} +</blockquote> +{%- endcomponent quote %} + + +{% component detail(title: string = "", default_open: bool = false) -%} +<details{% if default_open %} open{% endif %}> +<summary><span>{{ title }}</span></summary> +{{ body | markdown | trim | safe }} +</details> +{%- endcomponent detail %} + + +{% component figure(src: string, alt: string = "", caption: string = "", width: string = "", height: string = "", page = {}, section = {}) -%} +{%- if src is starting_with(pat="/") or src is starting_with(pat="http://") or src is starting_with(pat="https://") or src is starting_with(pat="//") or src is starting_with(pat="data:") -%} +{%- set image_src = src -%} +{%- elif page?.colocated_path -%} +{%- set image_src = get_url(path=page.colocated_path ~ src) -%} +{%- elif section?.colocated_path -%} +{%- set image_src = get_url(path=section.colocated_path ~ src) -%} +{%- else -%} +{%- set image_src = src -%} +{%- endif -%} +<figure> +<img src="{{ image_src }}"{% if alt %} alt="{{ alt }}"{% endif %}{% if height %} height="{{ height }}"{% endif %}{% if width %} width="{{ width }}"{% endif %}> +{%- if caption -%} +<figcaption>{{ caption | trim | markdown | trim | safe }}</figcaption> +{%- endif -%} +</figure> +{%- endcomponent figure %} + + +{% component mermaid() -%} +<pre class="mermaid"> +{{ body }} +</pre> +{%- endcomponent mermaid %} + + +{% component youtube(id: string, autoplay: bool = false) -%} +<div class="youtube"> +<iframe src="https://www.youtube.com/embed/{{ id }}{% if autoplay %}?autoplay=1&mute=1{% endif %}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> +</div> +{%- endcomponent youtube %} diff --git a/src/themes/serene/templates/_components/seo.html b/src/themes/serene/templates/_components/seo.html new file mode 100644 index 0000000..361d7d2 --- /dev/null +++ b/src/themes/serene/templates/_components/seo.html @@ -0,0 +1,39 @@ +{% component seo(title, desc, config, url = "", page_type = "website", image = "", colocated_path = "", published = "", updated = "", tags = [], lang = "") %} +{%- set og_image = "" -%} +{%- if image -%} + {%- if image is starting_with(pat="http://") or image is starting_with(pat="https://") or image is starting_with(pat="//") -%} + {%- set og_image = image -%} + {%- elif image is starting_with(pat="/") -%} + {%- set og_image = get_url(path=image) -%} + {%- elif colocated_path -%} + {%- set og_image = get_url(path=colocated_path ~ image) -%} + {%- else -%} + {%- set og_image = get_url(path=image) -%} + {%- endif -%} +{%- elif config.extra.og_image -%} + {%- if config.extra.og_image is starting_with(pat="http://") or config.extra.og_image is starting_with(pat="https://") or config.extra.og_image is starting_with(pat="//") -%} + {%- set og_image = config.extra.og_image -%} + {%- else -%} + {%- set og_image = get_url(path=config.extra.og_image) -%} + {%- endif -%} +{%- endif -%} +<meta name="description" content="{{ desc | striptags | trim }}"> +{% if url %}<link rel="canonical" href="{{ url | safe }}">{% endif %} +<meta property="og:site_name" content="{{ config.title }}"> +<meta property="og:type" content="{{ page_type }}"> +<meta property="og:title" content="{{ title }}"> +<meta property="og:description" content="{{ desc | striptags | trim }}"> +{% if url %}<meta property="og:url" content="{{ url | safe }}">{% endif %} +{% if lang %}<meta property="og:locale" content="{{ lang | replace(from="-", to="_") }}">{% endif %} +{% if og_image %}<meta property="og:image" content="{{ og_image | safe }}">{% endif %} +{% if page_type == "article" %} +{% if published %}<meta property="article:published_time" content="{{ published }}">{% endif %} +{% if updated %}<meta property="article:modified_time" content="{{ updated }}">{% endif %} +{% if tags %}{% for tag in tags %}<meta property="article:tag" content="{{ tag }}"> +{% endfor %}{% endif %} +{% endif %} +<meta name="twitter:card" content="{% if og_image %}summary_large_image{% else %}summary{% endif %}"> +<meta name="twitter:title" content="{{ title }}"> +<meta name="twitter:description" content="{{ desc | striptags | trim }}"> +{% if og_image %}<meta name="twitter:image" content="{{ og_image | safe }}">{% endif %} +{% endcomponent seo %} diff --git a/src/themes/serene/templates/_footer.html b/src/themes/serene/templates/_footer.html index e9c1dd1..78d62c8 100644 --- a/src/themes/serene/templates/_footer.html +++ b/src/themes/serene/templates/_footer.html @@ -1,5 +1,10 @@ -{% if config.extra.blog_section_path is defined %} -{% set blog_section_path = config.extra.blog_section_path %} +{% set show_rss = false %} +{% if section is defined and section.generate_feeds %} + {% set rss_path = section.path ~ config.feed_filenames[0] %} + {% set show_rss = true %} +{% elif config.generate_feeds %} + {% set rss_path = "/" ~ config.feed_filenames[0] %} + {% set show_rss = true %} {% endif %} <footer> <div class="left"> @@ -13,18 +18,11 @@ </div> <div class="right"> - {% if blog_section_path is defined and section.path is starting_with(blog_section_path) %} - {% if section.generate_feeds %} - {% set_global rss_path = blog_section_path ~ "/" ~ config.feed_filenames.0 %} - {% elif config.generate_feeds %} - {% set_global rss_path = "/" ~ config.feed_filenames.0 %} - {% endif %} - {% if section.generate_feeds or config.generate_feeds %} + {% if show_rss %} <a id="rss-btn" href="{{ get_url(path=rss_path) }}">RSS</a> {% endif %} - {% endif %} - {% if not config.extra.force_theme %} + {% if color_scheme == "auto" %} {% set moon_icon = load_data(path="icon/moon.svg") %} {% set sun_icon = load_data(path="icon/sun.svg") %} <button id="theme-toggle" aria-label="theme switch"> @@ -35,8 +33,7 @@ </div> </footer> -{% if blog_section_path is defined and section.path is starting_with(blog_section_path) %} -{% if section.generate_feeds or config.generate_feeds %} +{% if show_rss %} {% set link = get_url(path=rss_path) %} <dialog id="rss-mask"> <div> @@ -49,4 +46,3 @@ </div> </dialog> {% endif %} -{% endif %} diff --git a/src/themes/serene/templates/feed.xml b/src/themes/serene/templates/feed.xml index fe1f139..00aebe5 100644 --- a/src/themes/serene/templates/feed.xml +++ b/src/themes/serene/templates/feed.xml @@ -1,32 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ lang }}"> - <title>{% if section.title %}{{ section.title }}{% else %}{{ config.title }}{% endif %}</title> - {%- if section.description %} + <title>{% if section is defined and section.title %}{{ section.title }}{% else %}{{ config.title }}{% endif %}</title> + {%- if section is defined and section.description %} <subtitle>{{ section.description }}</subtitle> {%- elif config.description %} <subtitle>{{ config.description }}</subtitle> {%- endif %} - <link href="{{ feed_url | safe }}" rel="self" type="application/atom+xml"/> - <link href=" - {%- if section -%} - {{ section.permalink | escape_xml | safe }} - {%- else -%} - {{ config.base_url | escape_xml | safe }} - {%- endif -%} - "/> - <updated>{{ last_updated | date(format="%+") }}</updated> + <link rel="self" type="application/atom+xml" href="{{ feed_url | safe }}"/> + <link rel="alternate" type="text/html" href=" + {%- if section is defined -%} + {{ section.permalink | escape_xml | safe }} + {%- else -%} + {{ config.base_url | escape_xml | safe }} + {%- endif -%} + "/> + {% if last_updated is defined %} + <updated>{{ last_updated | date(format="%Y-%m-%dT%H:%M:%S%:z") }}</updated> + {% endif %} <id>{{ feed_url | safe }}</id> {%- for page in pages %} <entry xml:lang="{{ page.lang }}"> <title>{{ page.title }}</title> - <published>{{ page.date | date(format="%+") }}</published> - <updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated> - {%- if page.summary %} - <summary>{{ page.summary }}</summary> - {%- endif %} - <link href="{{ page.permalink | safe }}" type="text/html"/> + <published>{{ page.date | date(format="%Y-%m-%dT%H:%M:%S%:z") }}</published> + <updated>{{ (page.updated or page.date) | date(format="%Y-%m-%dT%H:%M:%S%:z") }}</updated> + <link rel="alternate" type="text/html" href="{{ page.permalink | safe }}"/> <id>{{ page.permalink | safe }}</id> - <content type="html">{{ page.content }}</content> + {% if page.summary %} + <summary>{{ page.summary }}</summary> + {% endif %} + <content type="html" xml:base="{{ page.permalink | escape_xml | safe }}">{{ page.content }}</content> </entry> {%- endfor %} -</feed>
\ No newline at end of file +</feed> diff --git a/src/themes/serene/templates/home.html b/src/themes/serene/templates/home.html index f899884..e074268 100644 --- a/src/themes/serene/templates/home.html +++ b/src/themes/serene/templates/home.html @@ -4,22 +4,28 @@ {% block lang %}{% if section.extra.lang %}{{ section.extra.lang }}{% else %}{{ section.lang }}{% endif %}{% endblock lang %} {% block title %}{{ config.title }}{% endblock title %} {% block desc %} - <meta name="description" content="{{ config.description }}"> + {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = section.lang %}{% endif -%} + {{ <seo config + title={config.title} + desc={config.description} + url={get_url(path="/")} + lang={og_lang} /> }} {% endblock desc %} {% block head %} -{% if config.markdown.highlight_theme == "css" %} - {% if config.extra.force_theme == "dark" %} - <link id="hl" rel="stylesheet" type="text/css" href="{{ get_url(path='hl-dark.css') }}" /> +{% if config.markdown.highlighting.style == "class" %} + {% if color_scheme == "dark" %} + <link id="hl" rel="stylesheet" type="text/css" href="{{ get_url(path='giallo-dark.css') }}" /> {% else %} - <link id="hl" rel="stylesheet" type="text/css" href="{{ get_url(path='hl-light.css') }}" /> + <link id="hl" rel="stylesheet" type="text/css" href="{{ get_url(path='giallo-light.css') }}" /> {% endif %} {% endif %} -{% if section.extra.math %} -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous"> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/copy-tex.min.js" integrity="sha384-HORx6nWi8j5/mYA+y57/9/CZc5z8HnEw4WUZWy5yOn9ToKBv1l58vJaufFAn9Zzi" crossorigin="anonymous"></script> +{% set enable_math = section.extra.math if section.extra.math is defined else (config.extra.math if config.extra.math is defined else false) %} +{% if enable_math %} +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.css" integrity="sha384-M59ezskvvpvT+a+C1x088YJ3DVmK+wZdX0UkVKalOI4Qi5Nwv0WrvpqHcfa2HQqB" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.js" integrity="sha384-7jGyG5zFwmEamqNWdCbpsPn+GTWEis3lnV7X/jXHyhFpJG7ExABLyMapabg8F4+p" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/copy-tex.min.js" integrity="sha384-Pe2JWbaShhSRT0SESJ9XLPeAsi4yrNi7r/CiH0Coq7giBjK5a6Ae7XcybE8rNlQP" crossorigin="anonymous"></script> <script> document.addEventListener("DOMContentLoaded", function () { renderMathInElement(document.body, { @@ -40,36 +46,40 @@ <div id="wrapper"> <main> <section id="info"> - {% if section.extra.avatar %} - <img src="{{ get_url(path=section.extra.avatar) }}" alt="avatar"> + {% if config.extra.avatar %} + <img src="{{ get_url(path=config.extra.avatar) }}" alt="avatar"> {% endif %} <div id="text"> <div> - <span id="name">{{ section.extra.name }}</span> - {% if section.extra.id %} - <span id="id">@{{ section.extra.id }}</span> + <span id="name">{{ config.extra.name }}</span> + {% if config.extra.handle %} + <span id="id">@{{ config.extra.handle }}</span> {% endif %} </div> - {% if section.extra.bio %} - <div id="bio"> {{ section.extra.bio }} </div> + {% if config.extra.bio %} + <div id="bio"> {{ config.extra.bio }} </div> {% endif %} </div> </section> <section id="links"> <div id="left"> - {% for section in config.extra.sections %} - <a {% if section.is_external %}href="{{ section.path }}" target="_blank" rel='noreferrer noopener'{% else %}href="{{ get_url(path=section.path) }}" class="instant"{% endif %}>{{ section.name }}</a> + {% for item in config.extra.nav %} + {% if item.path is starting_with(pat="/") and item.path is not starting_with(pat="//") %} + <a href="{{ get_url(path=item.path) }}" class="instant">{{ item.name }}</a> + {% else %} + <a href="{{ item.path }}" class="external" target="_blank" rel='noreferrer noopener'>{{ item.name }}</a> + {% endif %} {% endfor %} </div> <div id="right"> - {% for link in section.extra.links %} - <a href="{{ link.url }}" aria-label="{{ link.name }}" target="_blank" rel='noreferrer noopener'> + {% for link in config.extra.links %} + <a href="{{ link.url }}" aria-label="{{ link.name }}" target="_blank" rel='noreferrer noopener{% if link.rel_me%} me{% endif %}'> {% set icon_path = "icon/" ~ link.icon ~ ".svg" %} {% set icon = load_data(path=icon_path) %} {{ icon | safe }} </a> {% endfor %} - {% if not section.extra.footer and not config.extra.force_theme %} + {% if not section.extra.footer and color_scheme == "auto" %} {% set moon_icon = load_data(path="icon/moon.svg") %} {% set sun_icon = load_data(path="icon/sun.svg") %} <button id="theme-toggle" aria-label="theme switch"> @@ -83,16 +93,16 @@ {{ section.content | trim | safe }} </section> {% if section.extra.recent %} - {% set blog_section_path = config.extra.blog_section_path | trim_start_matches(pat="/") %} + {% set blog_section_path = config.extra.blog_section_path | trim_start(pat="/") %} {% set section_md_path = blog_section_path ~ "/_index.md" %} {% set blog_section = get_section(path=section_md_path) %} + {% set date_format = section.extra.date_format if section.extra.date_format is defined else (config.extra.date_format if config.extra.date_format is defined else "%b %-d, %Y") %} <section class="layout-list"> <div class="post-list"> - {% for post in blog_section.pages | slice(end=section.extra.recent_max) %} - <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink | safe }}"> + {% for post in blog_section.pages[:section.extra.recent_max] %} + <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}"> <span>{{ post.title }}</span> - <span class="line"></span> - <span class="date">{{ post.date | date(format=section.extra.date_format) }}</span> + <span class="date">{{ post.date | date(format=date_format) }}</span> </a> {% endfor %} </div> @@ -110,9 +120,10 @@ {% block script %} <script src="{{ get_url(path='js/lightense.min.js') }}"></script> -{% if section.extra.mermaid %} +{% set enable_mermaid = section.extra.mermaid if section.extra.mermaid is defined else (config.extra.mermaid if config.extra.mermaid is defined else false) %} +{% if enable_mermaid %} <script type="module"> - import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs'; + import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.17.2/dist/mermaid.esm.min.mjs'; mermaid.initialize({ startOnLoad: true }); </script> {% endif %} diff --git a/src/themes/serene/templates/macros/collection.html b/src/themes/serene/templates/macros/collection.html deleted file mode 100644 index 796eae1..0000000 --- a/src/themes/serene/templates/macros/collection.html +++ /dev/null @@ -1,153 +0,0 @@ -{% macro card(item) %} -<blockquote class="collection card{% if item.featured %} featured{% endif %}"> - <div class="meta"> - {% if item.icon %} - <div class="icon-wrapper"> - <img class="icon no-lightense" src="{{ item.icon }}" alt="icon" width="16" height="16"> - </div> - {% endif %} - {% if item.link %} - <a class="title" href="{{ item.link }}" target="_blank" rel="noreferrer noopener">{{ item.title }}</a> - {% else %} - <div class="title">{{ item.title }}</div> - {% endif %} - {% if item.date %} - <div class="date">{{ item.date }}</div> - {% endif %} - </div> - {% if item.subtitle %} - <div class="subtitle">{{ item.subtitle }}</div> - {% endif %} - <div class="content">{{ item.content | trim | markdown | safe }}</div> - {% if item.tags %} - <div class="tags"> - {% for tag in item.tags %} - <div><span>#</span>{{ tag }}</div> - {% endfor %} - </div> - {% endif %} -</blockquote> -{% endmacro %} - - -{% macro card_simple(item) %} -<blockquote class="collection card-simple{% if item.featured %} featured{% endif %}"> - <div class="meta"> - {% if item.icon %} - <div class="icon-wrapper"> - <img class="icon no-lightense" src="{{ item.icon }}" alt="icon" width="16" height="16"> - </div> - {% endif %} - {% if item.link %} - <a class="title" href="{{ item.link }}" target="_blank" rel="noreferrer noopener">{{ item.title }}</a> - {% else %} - <div class="title">{{ item.title }}</div> - {% endif %} - <div class="content">{{ item.content | trim | markdown | safe }}</div> - {% if item.date %} - <div class="date">{{ item.date }}</div> - {% endif %} - </div> - <div class="content-narrow">{{ item.content | trim | markdown | safe }}</div> -</blockquote> -{% endmacro %} - - -{% macro entry(item) %} -{% if item.link %} -<a href="{{ item.link }}" target="_blank" rel="noreferrer noopener" class="collection entry"> -{% else %} -<blockquote class="collection entry"> -{% endif %} - {% if item.icon %} - <div class="icon-wrapper"> - <img class="icon no-lightense" src="{{ item.icon }}" alt="icon" width="16" height="16" /> - </div> - {% endif %} - {% if item.title or item.subtitle %} - <div class="text"> - {% if item.title %} - <div class="title">{{ item.title }}</div> - {% endif %} - {% if item.subtitle %} - <div class="subtitle">{{ item.subtitle }}</div> - {% endif %} - </div> - {% endif %} -{% if item.link %} -</a> -{% else %} -</blockquote> -{% endif %} -{% endmacro %} - - -{% macro box(item) %} -<div class="collection-box-wrapper"> -{% if item.link %} -<a href="{{ item.link }}" target="_blank" rel="noreferrer noopener" class="collection box"> -{% else %} -<blockquote class="collection box"> -{% endif %} - <div class="text"> - <div class="title">{{ item.title }}</div> - {% if item.subtitle %} - <div class="subtitle">{{ item.subtitle }}</div> - {% endif %} - </div> - {% if item.img %} - <img class="no-lightense{% if item.rotate %} rotate{% endif %}" src="{{ item.img }}" alt="{{ item.title }}" width="48" height="48" /> - {% else %} - <div class="placehold"></div> - {% endif %} -{% if item.link %} -</a> -{% else %} -</blockquote> -{% endif %} -</div> -{% endmacro %} - - -{% macro art(item) %} -<blockquote class="collection art"> - <div class="img-wrapper"> - <img src="{{ item.img }}" alt="{{ item.title }}" height="175"> - </div> - <div class="text"> - {% if item.link %} - <a class="title" href="{{ item.link }}" target="_blank" rel="noreferrer noopener" >{{ item.title }}</a> - {% else %} - <div class="title">{{ item.title }}</div> - {% endif %} - {% if item.subtitle %} - <div class="subtitle">{{ item.subtitle }}</div> - {% endif %} - {% if item.content %} - <div class="content">{{ item.content }}</div> - {% endif %} - {% if item.footer %} - <div class="footer">{{ item.footer }}</div> - {% endif %} - </div> -</blockquote> -{% endmacro %} - - -{% macro art_simple(item) %} -<blockquote class="collection art-simple"> - <div class="img-wrapper"> - <img src="{{ item.img }}" alt="{{ item.title }}" height="175"> - </div> - <div class="text"> - {% if item.link %} - <a class="title" href="{{ item.link }}" target="_blank" rel="noreferrer noopener" >{{ item.title }}</a> - {% else %} - <div class="title">{{ item.title }}</div> - {% endif %} - {% if item.subtitle %} - <div class="subtitle">{{ item.subtitle }}</div> - {% endif %} - </div> -</blockquote> -{% endmacro %} diff --git a/src/themes/serene/templates/macros/prose.html b/src/themes/serene/templates/macros/prose.html deleted file mode 100644 index bd9a894..0000000 --- a/src/themes/serene/templates/macros/prose.html +++ /dev/null @@ -1,32 +0,0 @@ -{% macro back_link(path) %} -<header> - <nav> - <a href="{{ path }}">← {{ config.extra.back_link_text }}</a> - </nav> -</header> -{% endmacro %} - - -{% macro callout(name) %} -<blockquote class="callout {{ name }} {% if title %}has-title{% else %}no-title{% endif %}"> - {% set icon = load_data(path="icon/" ~ name ~ ".svg") %} - {% if title %} - <p class="title"> - <span class="icon"> - {{ icon | safe }} - </span> - <strong>{{ title }}</strong> - </p> - <div class="content"> - {{ body | markdown | safe }} - </div> - {% else %} - <div class="icon"> - {{ icon | safe }} - </div> - <div class="content"> - {{ body | markdown | safe }} - </div> - {% endif %} -</blockquote> -{% endmacro %} diff --git a/src/themes/serene/templates/post.html b/src/themes/serene/templates/post.html index 24fe0cd..07f9782 100644 --- a/src/themes/serene/templates/post.html +++ b/src/themes/serene/templates/post.html @@ -1,15 +1,13 @@ -{% import "macros/prose.html" as macros %} {% extends "_base.html" %} {% block page %}post{% endblock page %} {% block lang -%} -{%- set blog_section_path = config.extra.blog_section_path | trim_start_matches(pat="/") -%} -{%- set section_md_path = blog_section_path ~ "/_index.md" -%} -{%- set section = get_section(path=section_md_path, metadata_only=true) -%} +{%- set section = get_section(path=page.ancestors | last, metadata_only=true) -%} {%- if page.extra.lang %}{{page.extra.lang}}{% elif section.extra.lang %}{{section.extra.lang}}{% else %}{{page.lang}}{% endif -%} {%- endblock lang %} {% block title %}{{ page.title }}{% endblock title %} {% block desc %} + {%- set section = get_section(path=page.ancestors | last, metadata_only=true) -%} {% if page.summary %} {% set desc = page.summary %} {% elif page.description %} @@ -19,18 +17,30 @@ {% else %} {% set desc = config.description %} {% endif %} - <meta name="description" content="{{ desc }}"> + {%- if page.extra.lang %}{% set og_lang = page.extra.lang %}{% elif section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = page.lang %}{% endif -%} + {{ <seo config + title={page.title} + desc={desc} + url={page.permalink} + page_type="article" + image={page.extra?.og_image or ""} + colocated_path={page.colocated_path or ""} + published={page.date or ""} + updated={page.updated or ""} + tags={page.taxonomies?.tags or []} + lang={og_lang} /> }} {% endblock desc %} {% block head %} -{% if config.markdown.highlight_theme == "css" %} -<link id="hl" rel="stylesheet" type="text/css" href="/hl-{% if config.extra.force_theme == "dark" %}dark{% else %}light{% endif %}.css" /> +{% if config.markdown.highlighting.style == "class" %} +<link id="hl" rel="stylesheet" type="text/css" href="/giallo-{% if color_scheme == "dark" %}dark{% else %}light{% endif %}.css" /> {% endif %} -{% if page.extra.math %} -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous"> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/copy-tex.min.js" integrity="sha384-HORx6nWi8j5/mYA+y57/9/CZc5z8HnEw4WUZWy5yOn9ToKBv1l58vJaufFAn9Zzi" crossorigin="anonymous"></script> +{% set enable_math = page.extra.math if page.extra.math is defined else (section.extra.math if section.extra.math is defined else (config.extra.math if config.extra.math is defined else false)) %} +{% if enable_math %} +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.css" integrity="sha384-M59ezskvvpvT+a+C1x088YJ3DVmK+wZdX0UkVKalOI4Qi5Nwv0WrvpqHcfa2HQqB" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.js" integrity="sha384-7jGyG5zFwmEamqNWdCbpsPn+GTWEis3lnV7X/jXHyhFpJG7ExABLyMapabg8F4+p" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/copy-tex.min.js" integrity="sha384-Pe2JWbaShhSRT0SESJ9XLPeAsi4yrNi7r/CiH0Coq7giBjK5a6Ae7XcybE8rNlQP" crossorigin="anonymous"></script> <script> document.addEventListener("DOMContentLoaded", function () { renderMathInElement(document.body, { @@ -51,7 +61,7 @@ <div id="wrapper"> <div id="blank"></div> <aside> - {% if page.extra.toc is defined %}{% set show_toc = page.extra.toc %}{% else %}{% set show_toc = section.extra.toc %}{% endif %} + {% set show_toc = page.extra.toc if page.extra.toc is defined else (section.extra.toc if section.extra.toc is defined else (config.extra.toc if config.extra.toc is defined else false)) %} {% if show_toc and page.toc %} <nav> <ul> @@ -80,10 +90,10 @@ {% endif %} </aside> <main> - {{ macros::back_link(path = get_url(path=section.path)) }} + {{ <back_link path={get_url(path=section.path)} config /> }} <div> - {% if page.extra.copy is defined %}{% set allow_copy = page.extra.copy %}{% else %}{% set allow_copy = section.extra.copy %}{% endif %} + {% set allow_copy = page.extra.code_copy if page.extra.code_copy is defined else (section.extra.code_copy if section.extra.code_copy is defined else (config.extra.code_copy if config.extra.code_copy is defined else false)) %} {% if allow_copy %} {% set copy_icon = load_data(path="icon/copy.svg") %} {% set check_icon = load_data(path="icon/check.svg") %} @@ -91,31 +101,33 @@ {% endif %} <article class="prose"> <h1>{{ page.title }}</h1> + {% set date_format = section.extra.date_format if section.extra.date_format is defined else (config.extra.date_format if config.extra.date_format is defined else "%b %-d, %Y") %} <div id="post-info"> <div id="date"> - <span id="publish">{{ page.date | date(format=section.extra.date_format) }}</span> + <span id="publish">{{ page.date | date(format=date_format) }}</span> {% if page.updated and page.updated != page.date -%} - <span>Updated on <span id="updated">{{ page.updated | date(format=section.extra.date_format) }}</span></span> + <span>Updated on <span id="updated">{{ page.updated | date(format=date_format) }}</span></span> {% endif -%} </div> {% if page.taxonomies.tags is defined %} <div id="tags"> {% for tag in page.taxonomies.tags -%} - {% set tag_slugify = tag | slugify -%} - <a class="instant" href="{{ config.base_url ~ '/tags/' ~ tag_slugify | safe }}"><span>#</span>{{ tag }}</a> + <a class="instant" href="{{ get_taxonomy_url(kind="tags", term=tag) }}"><span>#</span>{{ tag }}</a> {%- endfor %} </div> {% endif %} </div> - {% if page.extra.outdate_alert is defined %}{% set show_outdate_alert = page.extra.outdate_alert %}{% else %}{% set show_outdate_alert = section.extra.outdate_alert %}{% endif %} - {% if page.extra.outdate_alert_days is defined %}{% set outdate_alert_days = page.extra.outdate_alert_days %}{% else %}{% set outdate_alert_days = section.extra.outdate_alert_days %}{% endif %} + {% set show_outdated_alert = page.extra.outdated_alert if page.extra.outdated_alert is defined else (section.extra.outdated_alert if section.extra.outdated_alert is defined else (config.extra.outdated_alert if config.extra.outdated_alert is defined else false)) %} + {% set outdated_alert_days = page.extra.outdated_alert_days if page.extra.outdated_alert_days is defined else (section.extra.outdated_alert_days if section.extra.outdated_alert_days is defined else (config.extra.outdated_alert_days if config.extra.outdated_alert_days is defined else 120)) %} - {% if show_outdate_alert -%} - <blockquote id="outdate_alert" class="callout caution hidden" data-days="{{ outdate_alert_days }}" - data-alert-text-before="{{ section.extra.outdate_alert_text_before }}" - data-alert-text-after="{{ section.extra.outdate_alert_text_after }}"> + {% if show_outdated_alert -%} + {% set outdated_alert_text_before = section.extra.outdated_alert_text_before if section.extra.outdated_alert_text_before is defined else (config.extra.outdated_alert_text_before if config.extra.outdated_alert_text_before is defined else "") %} + {% set outdated_alert_text_after = section.extra.outdated_alert_text_after if section.extra.outdated_alert_text_after is defined else (config.extra.outdated_alert_text_after if config.extra.outdated_alert_text_after is defined else "") %} + <blockquote id="outdate_alert" class="markdown-alert-caution hidden" data-days="{{ outdated_alert_days }}" + data-alert-text-before="{{ outdated_alert_text_before }}" + data-alert-text-after="{{ outdated_alert_text_after }}"> <div class="content"></div> </blockquote> {% endif %} @@ -123,12 +135,12 @@ {{ page.content | safe }} </article> - {% if page.extra.reaction is defined %}{% set show_reaction = page.extra.reaction %}{% else %}{% set show_reaction = config.extra.reaction %}{% endif %} + {% set show_reaction = page.extra.reaction if page.extra.reaction is defined else (section.extra.reaction if section.extra.reaction is defined else (config.extra.reaction if config.extra.reaction is defined else false)) %} {% if show_reaction %} <div class="reaction {{ config.extra.reaction_align }}" data-endpoint="{{ config.extra.reaction_endpoint }}"></div> {% endif %} - {% if page.extra.comment is defined %}{% set show_comment = page.extra.comment %}{% else %}{% set show_comment = section.extra.comment %}{% endif %} + {% set show_comment = page.extra.comment if page.extra.comment is defined else (section.extra.comment if section.extra.comment is defined else (config.extra.comment if config.extra.comment is defined else false)) %} {% if show_comment %} <div class="giscus"></div> {% include "_giscus_script.html" %} @@ -142,9 +154,10 @@ {% block script %} <script src="/js/lightense.min.js"></script> -{% if page.extra.mermaid %} +{% set enable_mermaid = page.extra.mermaid if page.extra.mermaid is defined else (section.extra.mermaid if section.extra.mermaid is defined else (config.extra.mermaid if config.extra.mermaid is defined else false)) %} +{% if enable_mermaid %} <script type="module"> - import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs'; + import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.17.2/dist/mermaid.esm.min.mjs'; mermaid.initialize({ startOnLoad: true }); </script> {% endif %} diff --git a/src/themes/serene/templates/blog.html b/src/themes/serene/templates/posts.html index 2519d28..9b3dec1 100644 --- a/src/themes/serene/templates/blog.html +++ b/src/themes/serene/templates/posts.html @@ -1,4 +1,3 @@ -{% import "macros/prose.html" as macros %} {% extends "_base.html" %} {% block page %}blog{% endblock page%} @@ -10,26 +9,35 @@ {% else %} {% set desc = config.description %} {% endif %} - <meta name="description" content="{{ desc }}"> + {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = section.lang %}{% endif -%} + {{ <seo config + title={section.title} + desc={desc} + url={section.permalink} + lang={og_lang} /> }} {% endblock desc %} {% block content %} <div id="wrapper"> - {{ macros::back_link(path = get_url(path="/")) }} + {{ <back_link path={get_url(path="/")} config /> }} {% include "_section_title.html" %} <main class="layout-list"> + {% set date_format = section.extra.date_format if section.extra.date_format is defined else (config.extra.date_format if config.extra.date_format is defined else "%b %-d, %Y") %} {% if section.extra.categorized %} - {% for category,posts in section.pages | sort(attribute="taxonomies.categories.0") | group_by(attribute="taxonomies.categories.0") %} + {% set categorized_posts = [post for post in section.pages if post.taxonomies?.categories] %} + {% set categories = [post.taxonomies.categories[0] for post in categorized_posts] | unique | sort %} + {% for category in categories %} + {% set posts = [post for post in categorized_posts if post.taxonomies.categories[0] == category] %} {% set category_name = category %} - {% if category is matching("^__[0-9]{2}__") %} - {% set category_name = category | split(pat="") | slice(start=7) | join(sep="") %} + {% if category is matching(pat="^__[0-9]{2}__") %} + {% set category_name = category[6:] %} {% endif %} <h2 class="category">{{ category_name }}</h2> <div class="post-list categorized"> {% for post in posts %} - <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink | safe }}"> + <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}"> <span>{{ post.title }}</span> - <span class="date">{{ post.date | date(format=section.extra.date_format) }}</span> + <span class="date">{{ post.date | date(format=date_format) }}</span> </a> {% endfor %} </div> @@ -37,9 +45,9 @@ {% else %} <div class="post-list"> {% for post in section.pages %} - <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink | safe }}"> + <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}"> <span>{{ post.title }}</span> - <span class="date">{{ post.date | date(format=section.extra.date_format) }}</span> + <span class="date">{{ post.date | date(format=date_format) }}</span> </a> {% endfor %} </div> diff --git a/src/themes/serene/templates/prose.html b/src/themes/serene/templates/prose.html index 661c408..114ff16 100644 --- a/src/themes/serene/templates/prose.html +++ b/src/themes/serene/templates/prose.html @@ -1,4 +1,3 @@ -{% import "macros/prose.html" as macros %} {% extends "_base.html" %} {% block page %}prose-page{% endblock page %} @@ -12,18 +11,24 @@ {% else %} {% set desc = config.description %} {% endif %} - <meta name="description" content="{{ desc }}"> + {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = section.lang %}{% endif -%} + {{ <seo config + title={section.title} + desc={desc} + url={section.permalink} + lang={og_lang} /> }} {% endblock desc %} {% block head %} -{% if config.markdown.highlight_theme == "css" %} -<link id="hl" rel="stylesheet" type="text/css" href="/hl-{% if config.extra.force_theme == "dark" %}dark{% else %}light{% endif %}.css" /> +{% if config.markdown.highlighting.style == "class" %} +<link id="hl" rel="stylesheet" type="text/css" href="/giallo-{% if color_scheme == "dark" %}dark{% else %}light{% endif %}.css" /> {% endif %} -{% if section.extra.math %} -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous"> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/copy-tex.min.js" integrity="sha384-HORx6nWi8j5/mYA+y57/9/CZc5z8HnEw4WUZWy5yOn9ToKBv1l58vJaufFAn9Zzi" crossorigin="anonymous"></script> +{% set enable_math = section.extra.math if section.extra.math is defined else (config.extra.math if config.extra.math is defined else false) %} +{% if enable_math %} +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.css" integrity="sha384-M59ezskvvpvT+a+C1x088YJ3DVmK+wZdX0UkVKalOI4Qi5Nwv0WrvpqHcfa2HQqB" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/katex.min.js" integrity="sha384-7jGyG5zFwmEamqNWdCbpsPn+GTWEis3lnV7X/jXHyhFpJG7ExABLyMapabg8F4+p" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.6/dist/contrib/copy-tex.min.js" integrity="sha384-Pe2JWbaShhSRT0SESJ9XLPeAsi4yrNi7r/CiH0Coq7giBjK5a6Ae7XcybE8rNlQP" crossorigin="anonymous"></script> <script> document.addEventListener("DOMContentLoaded", function () { renderMathInElement(document.body, { @@ -43,10 +48,11 @@ {% block content %} <div id="wrapper"> <main> - {{ macros::back_link(path = get_url(path="/")) }} + {{ <back_link path={get_url(path="/")} config /> }} {% include "_section_title.html" %} <div> - {% if section.extra.copy %} + {% set allow_copy = section.extra.code_copy if section.extra.code_copy is defined else (config.extra.code_copy if config.extra.code_copy is defined else false) %} + {% if allow_copy %} {% set copy_icon = load_data(path="icon/copy.svg") %} {% set check_icon = load_data(path="icon/check.svg") %} <div id="copy-cfg" style="display: none;" data-copy-icon="{{ copy_icon }}" data-check-icon="{{ check_icon }}"></div> @@ -55,12 +61,13 @@ {{ section.content | safe }} </article> - {% if section.extra.reaction is defined %}{% set show_reaction = section.extra.reaction %}{% else %}{% set show_reaction = config.extra.reaction %}{% endif %} + {% set show_reaction = section.extra.reaction if section.extra.reaction is defined else (config.extra.reaction if config.extra.reaction is defined else false) %} {% if show_reaction %} <div class="reaction {{ config.extra.reaction_align }}" data-endpoint="{{ config.extra.reaction_endpoint }}"></div> {% endif %} - {% if section.extra.comment %} + {% set show_comment = section.extra.comment if section.extra.comment is defined else (config.extra.comment if config.extra.comment is defined else false) %} + {% if show_comment %} <div class="giscus"></div> {% include "_giscus_script.html" %} {% endif %} @@ -73,9 +80,10 @@ {% block script %} <script src="/js/lightense.min.js"></script> -{% if section.extra.mermaid %} +{% set enable_mermaid = section.extra.mermaid if section.extra.mermaid is defined else (config.extra.mermaid if config.extra.mermaid is defined else false) %} +{% if enable_mermaid %} <script type="module"> - import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs'; + import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11.17.2/dist/mermaid.esm.min.mjs'; mermaid.initialize({ startOnLoad: true }); </script> {% endif %} diff --git a/src/themes/serene/templates/shortcodes/caution.html b/src/themes/serene/templates/shortcodes/caution.html deleted file mode 100644 index 7d1797f..0000000 --- a/src/themes/serene/templates/shortcodes/caution.html +++ /dev/null @@ -1,2 +0,0 @@ -{% import "macros/prose.html" as macros %} -{{ macros::callout(name="caution") }} diff --git a/src/themes/serene/templates/shortcodes/collection.html b/src/themes/serene/templates/shortcodes/collection.html deleted file mode 100644 index c217a0c..0000000 --- a/src/themes/serene/templates/shortcodes/collection.html +++ /dev/null @@ -1,23 +0,0 @@ -{% import 'macros/collection.html' as marcos -%} - -{% set data = load_data(path="content" ~ section.path ~ file, format="toml") %} - -<section class="collection-wrapper"> -{% for item in data.collection %} - {% if item.type == "card" %} - {{ marcos::card(item=item) }} - {% elif item.type == "card_simple" %} - {{ marcos::card_simple(item=item) }} - {% elif item.type == "entry" %} - {{ marcos::entry(item=item) }} - {% elif item.type == "box" %} - {{ marcos::box(item=item) }} - {% elif item.type == "art" %} - {{ marcos::art(item=item) }} - {% elif item.type == "art_simple" %} - {{ marcos::art_simple(item=item) }} - {% elif item.type == "br" %} - <br /> - {% endif %} -{% endfor %} -</section> diff --git a/src/themes/serene/templates/shortcodes/detail.html b/src/themes/serene/templates/shortcodes/detail.html deleted file mode 100644 index 0d34a74..0000000 --- a/src/themes/serene/templates/shortcodes/detail.html +++ /dev/null @@ -1,4 +0,0 @@ -<details {% if default_open %}open{% endif %}> - <summary><span>{{ title }}</span></summary> - {{ body | markdown | safe }} -</details> diff --git a/src/themes/serene/templates/shortcodes/figure.html b/src/themes/serene/templates/shortcodes/figure.html deleted file mode 100644 index 8a4123f..0000000 --- a/src/themes/serene/templates/shortcodes/figure.html +++ /dev/null @@ -1,8 +0,0 @@ -<figure> - <img src="{{ src }}" {% if alt %} alt="{{ alt }}"{% endif %}> - {% if via %} - <figcaption><a href="{{via}}">via</a></figcaption> - {% else %} - <figcaption>{{ caption }}</figcaption> - {% endif %} -</figure>
\ No newline at end of file diff --git a/src/themes/serene/templates/shortcodes/important.html b/src/themes/serene/templates/shortcodes/important.html deleted file mode 100644 index 451c141..0000000 --- a/src/themes/serene/templates/shortcodes/important.html +++ /dev/null @@ -1,2 +0,0 @@ -{% import "macros/prose.html" as macros %} -{{ macros::callout(name="important") }} diff --git a/src/themes/serene/templates/shortcodes/mermaid.html b/src/themes/serene/templates/shortcodes/mermaid.html deleted file mode 100644 index 3d3725d..0000000 --- a/src/themes/serene/templates/shortcodes/mermaid.html +++ /dev/null @@ -1,3 +0,0 @@ -<pre class="mermaid"> - {{ body }} -</pre>
\ No newline at end of file diff --git a/src/themes/serene/templates/shortcodes/note.html b/src/themes/serene/templates/shortcodes/note.html deleted file mode 100644 index b16657b..0000000 --- a/src/themes/serene/templates/shortcodes/note.html +++ /dev/null @@ -1,2 +0,0 @@ -{% import "macros/prose.html" as macros %} -{{ macros::callout(name="note") }} diff --git a/src/themes/serene/templates/shortcodes/quote.html b/src/themes/serene/templates/shortcodes/quote.html deleted file mode 100644 index c7e3c37..0000000 --- a/src/themes/serene/templates/shortcodes/quote.html +++ /dev/null @@ -1,10 +0,0 @@ -<blockquote class="quote"> - {% set icon = load_data(path="icon/quote.svg") %} - <div class="icon" style="display: none;">{{ icon | safe }}</div> - <div class="content">{{ body | markdown | safe }}</div> - {% if cite %} - <div class="from"> - {{ "— " ~ cite | markdown | safe }} - </div> - {% endif %} -</blockquote>
\ No newline at end of file diff --git a/src/themes/serene/templates/shortcodes/tip.html b/src/themes/serene/templates/shortcodes/tip.html deleted file mode 100644 index 8904437..0000000 --- a/src/themes/serene/templates/shortcodes/tip.html +++ /dev/null @@ -1,2 +0,0 @@ -{% import "macros/prose.html" as macros %} -{{ macros::callout(name="tip") }} diff --git a/src/themes/serene/templates/shortcodes/warning.html b/src/themes/serene/templates/shortcodes/warning.html deleted file mode 100644 index 0964b15..0000000 --- a/src/themes/serene/templates/shortcodes/warning.html +++ /dev/null @@ -1,2 +0,0 @@ -{% import "macros/prose.html" as macros %} -{{ macros::callout(name="warning") }} diff --git a/src/themes/serene/templates/tags/list.html b/src/themes/serene/templates/tags/list.html index bde1123..e2d48d7 100644 --- a/src/themes/serene/templates/tags/list.html +++ b/src/themes/serene/templates/tags/list.html @@ -1,26 +1,32 @@ -{% import "macros/prose.html" as macros %} {% extends "_base.html" %} {% block page %}tag-list{% endblock page%} {% block lang -%} -{% set blog_section_path = config.extra.blog_section_path | trim_start_matches(pat="/") %} +{% set blog_section_path = config.extra.blog_section_path | trim_start(pat="/") %} {% set section_md_path = blog_section_path ~ "/_index.md"%} {% set section = get_section(path=section_md_path, metadata_only=true) %} {%- if section.extra.lang %}{{ section.extra.lang }}{% else %}{{ lang }}{% endif -%} {%- endblock lang %} {% block title %}Tags{% endblock title %} {% block desc %} - <meta name="description" content="Tags"> + {%- set blog_section_path = config.extra.blog_section_path | trim_start(pat="/") -%} + {%- set section = get_section(path=blog_section_path ~ "/_index.md", metadata_only=true) -%} + {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = lang %}{% endif -%} + {{ <seo config + title="Tags" + desc="Tags" + url={current_url or ""} + lang={og_lang} /> }} {% endblock desc %} {% block content %} <div id="wrapper"> - {{ macros::back_link(path = get_url(path="/")) }} + {{ <back_link path={get_url(path="/")} config /> }} <main> <h1 class="title">Tags</h1> <div class="tags"> {% for tag in terms -%} - <a class="instant" href="{{ tag.permalink | safe }}"># {{ tag.name | lower }}</a> + <a class="instant" href="{{ tag.permalink }}"># {{ tag.name | lower }}</a> {% endfor %} </div> </main> diff --git a/src/themes/serene/templates/tags/single.html b/src/themes/serene/templates/tags/single.html index 1ce059a..ea9f360 100644 --- a/src/themes/serene/templates/tags/single.html +++ b/src/themes/serene/templates/tags/single.html @@ -1,30 +1,38 @@ -{% import "macros/prose.html" as macros %} {% extends "_base.html" %} {% block page %}tag-single{% endblock page %} {% block lang -%} -{% set blog_section_path = config.extra.blog_section_path | trim_start_matches(pat="/") %} +{% set blog_section_path = config.extra.blog_section_path | trim_start(pat="/") %} {% set section_md_path = blog_section_path ~ "/_index.md"%} {% set section = get_section(path=section_md_path, metadata_only=true) %} {%- if section.extra.lang %}{{ section.extra.lang }}{% else %}{{ lang }}{% endif -%} {%- endblock lang %} {% block title %}{{section.title}}{% endblock title %} {% block desc %} - <meta name="description" content="{{ term.name }}"> + {%- set blog_section_path = config.extra.blog_section_path | trim_start(pat="/") -%} + {%- set section = get_section(path=blog_section_path ~ "/_index.md", metadata_only=true) -%} + {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = lang %}{% endif -%} + {{ <seo config + title={section.title} + desc={term.name} + url={term.permalink} + lang={og_lang} /> }} {% endblock desc %} {% block content %} <div id="wrapper"> - {{ macros::back_link(path = get_url(path="/tags")) }} + {% set tags_taxonomy = get_taxonomy(kind="tags") %} + {{ <back_link path={tags_taxonomy.permalink} config /> }} <main class="layout-list"> <div class="title"> <span># {{ term.name }}</span> </div> <div class="post-list"> + {% set date_format = section.extra.date_format if section.extra.date_format is defined else (config.extra.date_format if config.extra.date_format is defined else "%b %-d, %Y") %} {% for post in term.pages %} - <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink | safe }}"> + <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}"> <span>{{ post.title }}</span> - <span class="date">{{ post.date | date(format=section.extra.date_format) }}</span> + <span class="date">{{ post.date | date(format=date_format) }}</span> </a> {% endfor %} </div> |
