next-theme / hexo-theme-next

🎉 Elegant and powerful theme for Hexo.
https://theme-next.js.org
Other
2.31k stars 411 forks source link

enable hide page title #787

Closed flashlab closed 1 month ago

flashlab commented 1 month ago

Issue Checklist

Expected behavior

As to post type, we can set header: false in front matter to disable headers. This patch will make effect on page, such as about, tags, categories pages.

Actual behavior

Steps to reproduce the behavior

Use tags as an instance:

title: "tags"
date: 2015-04-19 22:49:59
type: "tags"
comments: false
header: false   <----
---

Other Information

From 9ec43711b97940caaef6e716d11acde1f3abd9d4 Mon Sep 17 00:00:00 2001
From: flashlab <zhengjuefei25@163.com>
Date: Sat, 13 Apr 2024 16:03:25 +0800
Subject: [PATCH] fix: enable hide page title

---
 layout/page.njk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/layout/page.njk b/layout/page.njk
index 9bf5cf1..c36808d 100644
--- a/layout/page.njk
+++ b/layout/page.njk
@@ -23,7 +23,9 @@
     {### PAGE BLOCK ###}
     {##################}
     <div class="post-block" lang="{{ page.lang }}">
-      {%- include '_partials/page/page-header.njk' -%}
+      {%- if page.header !== false %}
+        {%- include '_partials/page/page-header.njk' -%}
+      {%- endif %}
       {#################}
       {### PAGE BODY ###}
       {#################}
--
2.20.1
welcome[bot] commented 1 month ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!

stevenjoezhang commented 1 month ago

Added in https://github.com/next-theme/hexo-theme-next/commit/ca0e6f0a0e0c5f4054528b5001c38956ed67a2aa Thanks for your suggestion!