mirror of
https://github.com/halo-dev/theme-earth.git
synced 2025-10-14 14:30:50 +00:00
feat: preliminary completion of category archive page and sidebar
Signed-off-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
2
templates/assets/dist/style.css
vendored
2
templates/assets/dist/style.css
vendored
File diff suppressed because one or more lines are too long
46
templates/category.html
Normal file
46
templates/category.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:th="https://www.thymeleaf.org"
|
||||
th:replace="modules/layout :: html(~{::content})"
|
||||
>
|
||||
<th:block th:fragment="content">
|
||||
<th:block th:replace="modules/category-filter" />
|
||||
|
||||
<div
|
||||
id="post-list"
|
||||
th:with="postItems=${posts.items}"
|
||||
class="mt-6 grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3"
|
||||
>
|
||||
<th:block th:each="post : ${postItems}">
|
||||
<th:block th:replace="modules/post-card :: post-card(${post},true)" />
|
||||
</th:block>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex items-center justify-between">
|
||||
<a
|
||||
th:href="${posts.prevUrl}"
|
||||
class="whitespace-no-wrap group inline-flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-white px-4 py-1 text-sm font-medium leading-6 text-gray-600 shadow-sm hover:bg-gray-50 focus:shadow-none focus:outline-none"
|
||||
>
|
||||
<span
|
||||
data-icon="tabler:arrow-left"
|
||||
class="iconify text-lg transition-all group-hover:-translate-x-1"
|
||||
></span>
|
||||
<span>上一页</span>
|
||||
</a>
|
||||
<span
|
||||
class="text-sm text-gray-900"
|
||||
th:text="${posts.page} +' / '+ ${posts.total}"
|
||||
></span>
|
||||
<a
|
||||
th:href="${posts.nextUrl}"
|
||||
class="whitespace-no-wrap group inline-flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-white px-4 py-1 text-sm font-medium leading-6 text-gray-600 shadow-sm hover:bg-gray-50 focus:shadow-none focus:outline-none"
|
||||
>
|
||||
<span>下一页</span>
|
||||
<span
|
||||
data-icon="tabler:arrow-right"
|
||||
class="iconify text-lg transition-all group-hover:translate-x-1"
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
</th:block>
|
||||
</html>
|
@@ -4,33 +4,7 @@
|
||||
th:replace="modules/layout :: html(~{::content})"
|
||||
>
|
||||
<th:block th:fragment="content">
|
||||
<div
|
||||
id="filters"
|
||||
class="flex gap-x-2 overflow-x-auto overflow-y-hidden scroll-smooth"
|
||||
>
|
||||
<div
|
||||
class="flex cursor-pointer items-center rounded bg-gray-100 px-2 py-1 font-semibold text-gray-900 transition-all hover:shadow-sm"
|
||||
>
|
||||
<div class="flex flex-1 items-center truncate">
|
||||
<span class="truncate text-base"> 全部 </span>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:with="categories = ${categoryFinder.listAll()}">
|
||||
<div
|
||||
th:each="category : ${categories}"
|
||||
class="flex cursor-pointer items-center rounded px-2 py-1 font-semibold text-gray-500 transition-all hover:bg-gray-100 hover:text-gray-900 hover:shadow-sm"
|
||||
>
|
||||
<div class="flex flex-1 items-center truncate">
|
||||
<span class="truncate text-base">
|
||||
<a
|
||||
th:href="${category.status.permalink}"
|
||||
th:text="${category.spec.displayName}"
|
||||
></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
</div>
|
||||
<th:block th:replace="modules/category-filter" />
|
||||
|
||||
<div
|
||||
id="post-list"
|
||||
@@ -43,7 +17,8 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex items-center justify-between">
|
||||
<button
|
||||
<a
|
||||
th:href="${posts.prevUrl}"
|
||||
class="whitespace-no-wrap group inline-flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-white px-4 py-1 text-sm font-medium leading-6 text-gray-600 shadow-sm hover:bg-gray-50 focus:shadow-none focus:outline-none"
|
||||
>
|
||||
<span
|
||||
@@ -51,9 +26,13 @@
|
||||
class="iconify text-lg transition-all group-hover:-translate-x-1"
|
||||
></span>
|
||||
<span>上一页</span>
|
||||
</button>
|
||||
<span class="text-sm text-gray-900">1 / 20</span>
|
||||
<button
|
||||
</a>
|
||||
<span
|
||||
class="text-sm text-gray-900"
|
||||
th:text="${posts.page} +' / '+ ${posts.total}"
|
||||
></span>
|
||||
<a
|
||||
th:href="${posts.nextUrl}"
|
||||
class="whitespace-no-wrap group inline-flex items-center justify-center gap-1 rounded-md border border-gray-200 bg-white px-4 py-1 text-sm font-medium leading-6 text-gray-600 shadow-sm hover:bg-gray-50 focus:shadow-none focus:outline-none"
|
||||
>
|
||||
<span>下一页</span>
|
||||
@@ -61,7 +40,7 @@
|
||||
data-icon="tabler:arrow-right"
|
||||
class="iconify text-lg transition-all group-hover:translate-x-1"
|
||||
></span>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</th:block>
|
||||
</html>
|
||||
|
27
templates/modules/category-filter.html
Normal file
27
templates/modules/category-filter.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<div
|
||||
id="filters"
|
||||
class="flex gap-x-2 overflow-x-auto overflow-y-hidden scroll-smooth"
|
||||
>
|
||||
<a
|
||||
href="/"
|
||||
class="flex cursor-pointer items-center rounded px-2 py-1 font-semibold text-gray-500 transition-all hover:bg-gray-100 hover:text-gray-900 hover:shadow-sm"
|
||||
th:classappend="${category == null} ? '!text-gray-900 !bg-gray-100'"
|
||||
>
|
||||
<div class="flex flex-1 items-center truncate">
|
||||
<span class="truncate text-base"> 全部 </span>
|
||||
</div>
|
||||
</a>
|
||||
<th:block th:with="categories = ${categoryFinder.listAll()}">
|
||||
<a
|
||||
th:each="categoryItem : ${categories}"
|
||||
th:href="${categoryItem.status.permalink}"
|
||||
class="flex cursor-pointer items-center rounded px-2 py-1 font-semibold text-gray-500 transition-all hover:bg-gray-100 hover:text-gray-900 hover:shadow-sm"
|
||||
th:classappend="${category} and ${category.metadata.name == categoryItem.metadata.name} ? '!text-gray-900 !bg-gray-100'"
|
||||
>
|
||||
<div class="flex flex-1 items-center truncate">
|
||||
<span class="truncate text-base" th:text="${categoryItem.spec.displayName}">
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</th:block>
|
||||
</div>
|
22
templates/modules/category-tree.html
Normal file
22
templates/modules/category-tree.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<ul th:fragment="next (categories)" class="my-3 ml-3 space-y-1 border-l pl-2">
|
||||
<li th:fragment="single (categories)" th:each="category : ${categories}">
|
||||
<a
|
||||
th:href="${category.status.permalink}"
|
||||
th:title="${category.spec.displayName}"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
>
|
||||
<span class="text-sm opacity-80" th:text="${category.spec.displayName}">
|
||||
</span>
|
||||
<span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
th:text="${category.status.postCount}"
|
||||
>
|
||||
</span>
|
||||
</a>
|
||||
<th:block th:if="${not #lists.isEmpty(category.children)}">
|
||||
<th:block
|
||||
th:replace="modules/category-tree :: next (categories=${category.children})"
|
||||
></th:block>
|
||||
</th:block>
|
||||
</li>
|
||||
</ul>
|
@@ -4,10 +4,12 @@
|
||||
<div class="container mx-auto flex justify-between">
|
||||
<div class="flex items-center gap-6">
|
||||
<div>
|
||||
<img
|
||||
src="https://halo.run/upload/2022/03/logo.svg"
|
||||
class="h-14 w-14"
|
||||
/>
|
||||
<a href="/">
|
||||
<img
|
||||
src="https://halo.run/upload/2022/03/logo.svg"
|
||||
class="h-14 w-14"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="flex items-center gap-6 text-white">
|
||||
<li
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<body>
|
||||
<th:block th:replace="modules/header" />
|
||||
<section class="container mx-auto"></section>
|
||||
<section class="container mx-auto -mt-20 grid grid-cols-4 gap-6">
|
||||
<section class="container mx-auto mt-6 grid grid-cols-4 gap-6">
|
||||
<div class="col-span-4 sm:col-span-3">
|
||||
<th:block th:replace="${content}" />
|
||||
</div>
|
||||
|
@@ -2,7 +2,10 @@
|
||||
th:fragment="post-card(post,cover)"
|
||||
class="group flex cursor-pointer flex-col overflow-hidden rounded-xl bg-white shadow-md ring-black transition-all duration-500 hover:-translate-y-2 hover:shadow-lg hover:ring-2"
|
||||
>
|
||||
<div th:if="${cover}" class="aspect-w-16 aspect-h-9">
|
||||
<div
|
||||
th:if="${cover} and ${not #strings.isEmpty(post.spec.cover)}"
|
||||
class="aspect-w-16 aspect-h-9"
|
||||
>
|
||||
<img
|
||||
th:src="${post.spec.cover}"
|
||||
th:alt="${post.spec.title}"
|
||||
|
@@ -4,20 +4,19 @@
|
||||
>
|
||||
<div class="flex flex-col items-center justify-center gap-4">
|
||||
<div class="relative h-24 w-24">
|
||||
<img
|
||||
src="https://halo.run/logo"
|
||||
class="h-full w-full rounded-full"
|
||||
/><span
|
||||
<img src="https://halo.run/logo" class="h-full w-full rounded-full" />
|
||||
<span
|
||||
class="absolute right-0 bottom-0 flex h-7 w-7 items-center justify-center rounded-full border bg-white p-0.5"
|
||||
>
|
||||
🌚
|
||||
</span>
|
||||
</div>
|
||||
<div><h1 class="text-2xl font-medium">Halo</h1></div>
|
||||
<div><h1 class="text-2xl font-medium" th:text="${site.title}"></h1></div>
|
||||
<div>
|
||||
<p class="text-center text-sm text-gray-700">
|
||||
Natus eveniet et cum eum.
|
||||
</p>
|
||||
<p
|
||||
class="text-center text-sm text-gray-700"
|
||||
th:text="${site.subtitle}"
|
||||
></p>
|
||||
</div>
|
||||
<div class="grid grid-cols-4 gap-5">
|
||||
<div class="inline-flex flex-col items-center">
|
||||
@@ -101,64 +100,30 @@
|
||||
热门文章
|
||||
</h2>
|
||||
<div>
|
||||
<ul role="list" class="divide-y divide-gray-100">
|
||||
<li class="py-3">
|
||||
<ul
|
||||
role="list"
|
||||
class="divide-y divide-gray-100"
|
||||
th:with="posts = ${postFinder.list(1,10)}"
|
||||
>
|
||||
<li class="py-3" th:each="post : ${posts}">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h3 class="text-sm font-medium">non omnis id</h3>
|
||||
<p class="text-xs text-gray-500">2022-10-01 发布</p>
|
||||
<h3
|
||||
class="text-sm font-medium hover:text-gray-500 hover:underline"
|
||||
>
|
||||
<a
|
||||
th:text="${post.spec.title}"
|
||||
th:href="${post.status.permalink}"
|
||||
></a>
|
||||
</h3>
|
||||
<p
|
||||
class="text-xs tabular-nums text-gray-500"
|
||||
th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')+' 发布'}"
|
||||
></p>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-1 text-xs text-gray-600">
|
||||
<span data-icon="tabler:eye" class="iconify"></span>
|
||||
<span>5243</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h3 class="text-sm font-medium">unde velit necessitatibus</h3>
|
||||
<p class="text-xs text-gray-500">2022-10-01 发布</p>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-1 text-xs text-gray-600">
|
||||
<span data-icon="tabler:eye" class="iconify"></span>
|
||||
<span>5243</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h3 class="text-sm font-medium">eos voluptatum velit</h3>
|
||||
<p class="text-xs text-gray-500">2022-10-01 发布</p>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-1 text-xs text-gray-600">
|
||||
<span data-icon="tabler:eye" class="iconify"></span>
|
||||
<span>5243</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h3 class="text-sm font-medium">culpa nam exercitationem</h3>
|
||||
<p class="text-xs text-gray-500">2022-10-01 发布</p>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-1 text-xs text-gray-600">
|
||||
<span data-icon="tabler:eye" class="iconify"></span>
|
||||
<span>5243</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h3 class="text-sm font-medium">est optio facere</h3>
|
||||
<p class="text-xs text-gray-500">2022-10-01 发布</p>
|
||||
</div>
|
||||
<div class="inline-flex items-center gap-1 text-xs text-gray-600">
|
||||
<span data-icon="tabler:eye" class="iconify"></span>
|
||||
<span>5243</span>
|
||||
<span th:text="${post.stats.visit}" class="tabular-nums"> </span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@@ -274,113 +239,11 @@
|
||||
<span data-icon="tabler:category" class="iconify text-lg"></span>
|
||||
分类目录
|
||||
</h2>
|
||||
<div class="mt-2">
|
||||
<div class="mt-2" th:with="categories = ${categoryFinder.listAsTree()}">
|
||||
<ul class="space-y-1">
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">Halo</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>
|
||||
20
|
||||
</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">MeterSphere</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>
|
||||
21
|
||||
</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">DataEase</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>
|
||||
22
|
||||
</span></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">assumenda</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>
|
||||
20
|
||||
</span></a
|
||||
>
|
||||
<ul class="my-3 ml-3 space-y-1 border-l pl-2">
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">minima</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>14</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">minima</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>18</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">hic</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>9</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">mollitia</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>14</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="#"
|
||||
class="group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-gray-100"
|
||||
><span class="text-sm opacity-80">facere</span
|
||||
><span
|
||||
class="rounded bg-gray-100 py-0.5 px-1 text-xs opacity-70 group-hover:bg-white"
|
||||
>7</span
|
||||
></a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li
|
||||
th:replace="modules/category-tree :: single(categories=${categories})"
|
||||
/>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user