From b95dffa5cd7c32a443ab2c46d63252bc828409ec Mon Sep 17 00:00:00 2001
From: squidfunk <martin.donath@squidfunk.com>
Date: Mon, 2 Jan 2023 11:27:41 +0100
Subject: [PATCH] Removed level 1 headline hack in content partial

---
 material/partials/content.html | 3 ++-
 src/partials/content.html      | 5 +++--
 src/partials/toc.html          | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/material/partials/content.html b/material/partials/content.html
index ff9eedfa0..d756b647e 100644
--- a/material/partials/content.html
+++ b/material/partials/content.html
@@ -5,7 +5,8 @@
   {% include "partials/tags.html" %}
 {% endif %}
 {% include "partials/actions.html" %}
-{% if "\x3ch1" not in page.content %}
+{% set first = page.toc | first %}
+{% if first and first.level != 1 %}
   <h1>{{ page.title | d(config.site_name, true)}}</h1>
 {% endif %}
 {{ page.content }}
diff --git a/src/partials/content.html b/src/partials/content.html
index 6ec8b42d9..6930a1ed1 100644
--- a/src/partials/content.html
+++ b/src/partials/content.html
@@ -29,10 +29,11 @@
 {% include "partials/actions.html" %}
 
 <!--
-  Hack: check whether the content contains a h1 headline. If it doesn't, the
+  Check whether the content starts with a level 1 headline. If it doesn't, the
   page title (or respectively site name) is used as the main headline.
 -->
-{% if "\x3ch1" not in page.content %}
+{% set first = page.toc | first %}
+{% if first and first.level != 1 %}
   <h1>{{ page.title | d(config.site_name, true)}}</h1>
 {% endif %}
 
diff --git a/src/partials/toc.html b/src/partials/toc.html
index de8c7b146..cb50b257b 100644
--- a/src/partials/toc.html
+++ b/src/partials/toc.html
@@ -31,7 +31,7 @@
   {% set toc = page.toc %}
 
   <!--
-    Hack: check whether the content contains a h1 headline. If it does, the
+    Check whether the content starts with a level 1 headline. If it does, the
     top-level anchor must be skipped, since it would be redundant to the link
     to the current page that is located just above the anchor. Therefore we
     directly continue with the children of the anchor.
-- 
GitLab