mirror of
https://github.com/halo-dev/theme-earth.git
synced 2025-12-10 01:02:24 +08:00
feat: add setting option for post title position (#213)
Signed-off-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,4 +23,5 @@ node_modules
|
||||
|
||||
.gradle
|
||||
build
|
||||
dist
|
||||
templates/assets/dist
|
||||
dist
|
||||
@@ -110,6 +110,19 @@ spec:
|
||||
value: github
|
||||
- label: Tailwind CSS Typography
|
||||
value: tailwind
|
||||
- $formkit: select
|
||||
name: title_position
|
||||
label: 标题位置
|
||||
value: "content"
|
||||
options:
|
||||
- value: "content"
|
||||
label: "正文中"
|
||||
- value: "cover"
|
||||
label: "封面中"
|
||||
- $formkit: text
|
||||
name: cover_height
|
||||
label: 封面图高度
|
||||
value: "24rem"
|
||||
- $formkit: checkbox
|
||||
name: show_upvote_button
|
||||
label: 显示点赞按钮
|
||||
|
||||
5
templates/assets/dist/main.iife.js
vendored
5
templates/assets/dist/main.iife.js
vendored
File diff suppressed because one or more lines are too long
1
templates/assets/dist/style.css
vendored
1
templates/assets/dist/style.css
vendored
File diff suppressed because one or more lines are too long
@@ -7,9 +7,20 @@
|
||||
<link rel="stylesheet" th:href="@{/assets/styles/github-markdown.css?v={version}(version=${theme.spec.version})}" />
|
||||
</th:block>
|
||||
<th:block th:fragment="hero">
|
||||
<th:block
|
||||
th:replace="~{modules/hero :: hero(isHome = false, cover = ${singlePage.spec.cover}, title = ${singlePage.spec.title})}"
|
||||
/>
|
||||
<section th:unless="${#strings.isEmpty(singlePage.spec.cover)}">
|
||||
<div class="relative flex items-center" th:styleappend="|height:${theme.config.post.cover_height ?: '24rem'}|">
|
||||
<div
|
||||
class="before:z-1 relative size-full bg-cover bg-center bg-no-repeat before:absolute before:inset-0 before:bg-black/40"
|
||||
th:style="|background-image: url('${singlePage.spec.cover}')|"
|
||||
></div>
|
||||
<header
|
||||
class="pattern-header-text absolute top-1/3 mx-auto flex w-full flex-col items-center justify-center gap-3"
|
||||
th:if="${theme.config.post.title_position == 'cover'}"
|
||||
>
|
||||
<h1 class="text-center text-2xl text-white sm:text-5xl" th:text="${singlePage.spec.title}"></h1>
|
||||
</header>
|
||||
</div>
|
||||
</section>
|
||||
</th:block>
|
||||
<th:block th:fragment="content">
|
||||
<div class="rounded-xl bg-white p-4 dark:bg-slate-800">
|
||||
@@ -81,7 +92,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="my-3 text-2xl font-medium dark:text-slate-50" th:text="${singlePage.spec.title}"></h1>
|
||||
<h1
|
||||
th:if="${#strings.isEmpty(singlePage.spec.cover)} or ${theme.config.post.title_position == 'content'}"
|
||||
class="my-3 text-3xl font-medium dark:text-slate-50"
|
||||
th:text="${singlePage.spec.title}"
|
||||
></h1>
|
||||
|
||||
<article
|
||||
class="!max-w-none break-words"
|
||||
th:classappend="${theme.config.post.content_style == 'github' ? 'markdown-body' : 'tailwind-typography'}"
|
||||
|
||||
@@ -4,12 +4,27 @@
|
||||
th:replace="~{modules/layout :: html(title = ${post.spec.title} + ' - ' + ${site.title}, hero = ~{::hero}, content = ~{::content}, head = ~{::head}, footer = ~{::footer}, sidebar = ~{::sidebar}, contentClass = ${theme.config.layout.content_header} and ${not #strings.isEmpty(post.spec.cover)} ? '!-mt-20' : '')}"
|
||||
>
|
||||
<th:block th:fragment="head">
|
||||
<link rel="stylesheet" th:href="@{/assets/styles/github-markdown.css?v={version}(version=${theme.spec.version})}" />
|
||||
<link
|
||||
th:if="${theme.config.post.content_style == 'github'}"
|
||||
rel="stylesheet"
|
||||
th:href="@{/assets/styles/github-markdown.css?v={version}(version=${theme.spec.version})}"
|
||||
/>
|
||||
</th:block>
|
||||
<th:block th:fragment="hero">
|
||||
<th:block
|
||||
th:replace="~{modules/hero :: hero(isHome = false, cover = ${post.spec.cover}, title = ${post.spec.title})}"
|
||||
/>
|
||||
<section th:unless="${#strings.isEmpty(post.spec.cover)}">
|
||||
<div class="relative flex items-center" th:styleappend="|height:${theme.config.post.cover_height ?: '24rem'}|">
|
||||
<div
|
||||
class="before:z-1 relative size-full bg-cover bg-center bg-no-repeat before:absolute before:inset-0 before:bg-black/40"
|
||||
th:style="|background-image: url('${post.spec.cover}')|"
|
||||
></div>
|
||||
<header
|
||||
class="pattern-header-text absolute top-1/3 mx-auto flex w-full flex-col items-center justify-center gap-3"
|
||||
th:if="${theme.config.post.title_position == 'cover'}"
|
||||
>
|
||||
<h1 class="text-center text-2xl text-white sm:text-5xl" th:text="${post.spec.title}"></h1>
|
||||
</header>
|
||||
</div>
|
||||
</section>
|
||||
</th:block>
|
||||
<th:block th:fragment="footer">
|
||||
<script>
|
||||
@@ -128,8 +143,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="my-3 text-2xl font-medium dark:text-slate-50" th:text="${post.spec.title}"></h1>
|
||||
<div class="flex gap-2">
|
||||
<h1
|
||||
th:if="${#strings.isEmpty(post.spec.cover)} or ${theme.config.post.title_position == 'content'}"
|
||||
class="mt-3 text-3xl font-medium dark:text-slate-50"
|
||||
th:text="${post.spec.title}"
|
||||
></h1>
|
||||
<div class="mt-3 flex gap-2">
|
||||
<a
|
||||
th:each="tag : ${post.tags}"
|
||||
th:href="@{${tag.status.permalink}}"
|
||||
|
||||
Reference in New Issue
Block a user