Allow enabling KaTeX per page/section (fixes #89)

This commit is contained in:
daudix
2024-09-29 02:48:21 +03:00
parent 6b19540347
commit b98775d61c
4 changed files with 16 additions and 12 deletions

View File

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Allow enabling KaTeX per page/section.
- Improve the logic of inclusion feeds in `<head>`.
- Restly the heading anchors. - Restly the heading anchors.
## Fixed ## Fixed

View File

@ -127,7 +127,8 @@ show_read_time = true
show_share_button = true show_share_button = true
# Whether to enable the KaTeX library for rendering LaTeX. # Whether to enable the KaTeX library for rendering LaTeX.
# Note: This will make your page significantly heavier. # Note: This will make your page significantly heavier.
katex = true # Instead, consider enabling it per page/section.
# katex = true
# Display outlines around all elements for debugging purposes # Display outlines around all elements for debugging purposes
# debug_layout = true # debug_layout = true

View File

@ -1,6 +1,7 @@
+++ +++
title = "Demo Page" title = "Demo Page"
[extra] [extra]
katex = true
archive = "This page is in fact not archived. It is only here to demonstrate the archival statement." archive = "This page is in fact not archived. It is only here to demonstrate the archival statement."
trigger = "This page contains blackjack and hookers, and bad jokes such as this one." trigger = "This page contains blackjack and hookers, and bad jokes such as this one."
disclaimer = """ disclaimer = """

View File

@ -10,15 +10,6 @@
<title>{% include "partials/title.html" %}</title> <title>{% include "partials/title.html" %}</title>
<link rel="canonical" href="{{ current_url | default(value='/') | safe }}" /> <link rel="canonical" href="{{ current_url | default(value='/') | safe }}" />
{%- if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %}
{%- if config.markdown.highlight_themes_css | length > 0 %}
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme-light.css') }}" media="(prefers-color-scheme: light)" />
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme-dark.css') }}" media="(prefers-color-scheme: dark)" />
{%- else %}
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme.css') }}" />
{%- endif %}
{%- endif %}
{%- if config.extra.comments %} {%- if config.extra.comments %}
<link rel="me" href="https://{{ config.extra.comments.host }}/@{{ config.extra.comments.user }}" /> <link rel="me" href="https://{{ config.extra.comments.host }}/@{{ config.extra.comments.user }}" />
{%- endif %} {%- endif %}
@ -45,7 +36,7 @@
{%- set styles = styles | concat(with=["fonts.css"]) %} {%- set styles = styles | concat(with=["fonts.css"]) %}
{%- endif %} {%- endif %}
{%- if config.extra.katex %} {%- if page.extra.katex or section.extra.katex or config.extra.katex %}
{%- set styles = styles | concat(with=["katex.css"]) %} {%- set styles = styles | concat(with=["katex.css"]) %}
{%- endif %} {%- endif %}
@ -63,6 +54,15 @@
<link type="text/css" rel="stylesheet" href="{{ get_url(path=style) | safe }}" /> <link type="text/css" rel="stylesheet" href="{{ get_url(path=style) | safe }}" />
{%- endfor %} {%- endfor %}
{%- if config.markdown.highlight_code and config.markdown.highlight_theme == "css" %}
{%- if config.markdown.highlight_themes_css | length > 0 %}
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme-light.css') }}" media="(prefers-color-scheme: light)" />
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme-dark.css') }}" media="(prefers-color-scheme: dark)" />
{%- else %}
<link type="text/css" rel="stylesheet" href="{{ get_url(path='syntax-theme.css') }}" />
{%- endif %}
{%- endif %}
{%- if config.extra.show_copy_button %} {%- if config.extra.show_copy_button %}
{%- include "partials/copy_button.html" %} {%- include "partials/copy_button.html" %}
{%- endif %} {%- endif %}
@ -73,7 +73,7 @@
{%- set scripts = scripts | concat(with=["count.js"]) %} {%- set scripts = scripts | concat(with=["count.js"]) %}
{%- endif %} {%- endif %}
{%- if config.extra.katex %} {%- if page.extra.katex or section.extra.katex or config.extra.katex %}
{%- set scripts = scripts | concat(with=["katex.min.js", "auto-render.min.js"]) %} {%- set scripts = scripts | concat(with=["katex.min.js", "auto-render.min.js"]) %}
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {