diff --git a/overrides/main.html b/overrides/main.html new file mode 100644 index 00000000..f8ba1699 --- /dev/null +++ b/overrides/main.html @@ -0,0 +1,84 @@ +{% extends "base.html" %} +{% block extrahead %} + {% set ns = namespace(title="", content="", readtime_s="", icon_href="https://guide.pycord.dev/img/logo.png") %} + {% set ns.title = page.meta.title if page.meta and page.meta.title else page.title|striptags %} + {% set ns.content = page.meta.description if page.meta and page.meta.description else config.site_description %} + {% if page.url %} + {% set chars = page.content|striptags|length %} + {% if chars > 300 %} + {% set minutes = (chars / 1590)|round|int %} + {% if minutes < 1 %} + {% set minutes = 1 %} + {% endif %} + {% set ns.readtime_s = lang.t("readtime.one") if minutes == 1 else lang.t("readtime.other")|replace("#", minutes|string) %} + {# Drop the leading

, header-link pilcrows and collapse whitespace #} + {% set body = page.content|trim %} + {% if body[:3] == "", 1)|list)[-1] %} + {% endif %} + {% set stripped = body|striptags|replace("¶", "")|split|list|join(" ") %} + {% if stripped|length > 250 %} + {# Cut on a word boundary #} + {% set ns.content = (stripped[:248]|split|list)[:-1]|join(" ") ~ "…" %} + {% else %} + {% set ns.content = stripped %} + {% endif %} + {% endif %} + {% endif %} + +{% endblock %}