feature(archives): Build a archives page draft

This commit is contained in:
周中平 2021-12-28 17:47:49 +08:00
parent 32abe6f33c
commit 04806b3555
No known key found for this signature in database
GPG Key ID: B1DF9DD42D8E00DC
10 changed files with 193 additions and 106 deletions

View File

@ -1,3 +0,0 @@
{
"compile-hero.disable-compile-files-on-did-save-code": false
}

View File

@ -1,48 +1,20 @@
<#include "module/macro.ftl">
<@layout title="归档 - ${blog_title!}">
<h1>归档</h1>
<ul>
<main>
<#include "module/header.ftl">
<div class="archives">
<#list archives as archive>
<h2>${archive.year?c}</h2>
<#list archive.posts as post>
<li>
<div class="year">${archive.year?c}</div>
<div class="list">
<#list archive.posts?sort_by("createTime")?reverse as post>
<div class="title">
<a href="${post.fullPath!}">${post.title!}</a>
</li>
<div class="time"><span class="date">${post.createTime?string('MM-dd')}</span></div>
</div>
</#list>
</div>
</#list>
</ul>
<h1>分页</h1>
<#if posts.totalPages gt 1>
<ul>
<@paginationTag method="archives" page="${posts.number}" total="${posts.totalPages}" display="3">
<#if pagination.hasPrev>
<li>
<a href="${pagination.prevPageFullPath!}">
上一页
</a>
</li>
</#if>
<#list pagination.rainbowPages as number>
<li>
<#if number.isCurrent>
<span class="current">第 ${number.page!} 页</span>
<#else>
<a href="${number.fullPath!}">第 ${number.page!} 页</a>
</#if>
</li>
</#list>
<#if pagination.hasNext>
<li>
<a href="${pagination.nextPageFullPath!}">
下一页
</a>
</li>
</#if>
</@paginationTag>
</ul>
<#else>
<span>当前只有一页</span>
</#if>
</div>
<#include "module/pagination.ftl">
</main>
</@layout>

View File

@ -1,30 +1,7 @@
<#include "module/macro.ftl">
<@layout title="${blog_title!}">
<main>
<div class="header">
<div class="title">
<a href="${blog_url!}"><span>无尽光芒</span></a>
</div>
<div class="description">
<p>${settings.sub_title!'the site subtitle'}</p>
<div class="socials">
<#if settings.github??>
<a href="${settings.github}" title="github" target="_blank"><i class="ri-github-line"></i></a>
</#if>
<#if settings.wechat??>
<a href="${settings.wechat}" title="wechat" target="_blank"><i class="ri-wechat-line"></i></a>
</#if>
<#if settings.bilibili??>
<a href="${settings.bilibili}" title="bilibili" target="_blank"><i class="ri-bilibili-line"></i></a>
</#if>
<#if settings.mail??>
<a href="mailto:${settings.mail}" title="mail" target="_blank"><i class="ri-mail-line"></i></a>
</#if>
<a href="/rss.xml" type="application/rss+xml" title="rss" target="_blank"><i class="ri-rss-line"></i></a>
</div>
</div>
</div>
<#include "module/header.ftl">
<#list posts.content as post>
<div class="post">
<h1><a href='${post.fullPath!}'>${post.title!}</a></h1>
@ -48,21 +25,6 @@
</div>
</#list>
<div class="pagenav">
<#if posts.totalPages gt 1>
<@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
<#if pagination.hasPrev>
<a href="${pagination.prevPageFullPath!}" class="pre">
返回上页
</a>
</#if>
<#if pagination.hasNext>
<a href="${pagination.nextPageFullPath!}" class="next">
更多文章
</a>
</#if>
</@paginationTag>
</#if>
</div>
<#include "module/pagination.ftl">
</main>
</@layout>

23
module/header.ftl Normal file
View File

@ -0,0 +1,23 @@
<div class="header">
<div class="title">
<a href="${blog_url!}"><span>无尽光芒</span></a>
</div>
<div class="description">
<p>${settings.sub_title!'the site subtitle'}</p>
<div class="socials">
<#if settings.github??>
<a href="${settings.github}" title="github" target="_blank"><i class="ri-github-line"></i></a>
</#if>
<#if settings.wechat??>
<a href="${settings.wechat}" title="wechat" target="_blank"><i class="ri-wechat-line"></i></a>
</#if>
<#if settings.bilibili??>
<a href="${settings.bilibili}" title="bilibili" target="_blank"><i class="ri-bilibili-line"></i></a>
</#if>
<#if settings.mail??>
<a href="mailto:${settings.mail}" title="mail" target="_blank"><i class="ri-mail-line"></i></a>
</#if>
<a href="/rss.xml" type="application/rss+xml" title="rss" target="_blank"><i class="ri-rss-line"></i></a>
</div>
</div>
</div>

View File

@ -16,7 +16,7 @@
<link rel="stylesheet" href="${theme_base!}/source/css/redemption.css"/>
</head>
<body class="animate__animated animate__fadeInDown">
<#-- <#include "menu.ftl"> -->
<#include "menu.ftl">
<#-- 主体 -->
<#nested >

16
module/pagination.ftl Normal file
View File

@ -0,0 +1,16 @@
<#if posts.totalPages gt 1>
<@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
<div class="pagenav">
<#if pagination.hasPrev>
<a href="${pagination.prevPageFullPath!}" class="pre">
返回上页
</a>
</#if>
<#if pagination.hasNext>
<a href="${pagination.nextPageFullPath!}" class="next">
更多文章
</a>
</#if>
</div>
</@paginationTag>
</#if>

View File

@ -65,35 +65,35 @@ main .post {
width: 45rem;
padding-top: 1rem;
}
main .post h1 a {
main .post > h1 a {
letter-spacing: 0.0625rem;
font-size: 1.375rem;
line-height: 1.75rem;
}
main .post p {
main .post > p {
line-height: 1.5rem;
text-indent: 2rem;
}
main .post .info {
main .post > .info {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
flex-direction: row;
padding: 0.5rem 0 2rem 0;
}
main .post .info span {
main .post > .info span {
font-weight: 400;
font-size: 0.75rem;
}
main .post .info a {
main .post > .info a {
font-size: 0.75rem;
}
main .post .info .date,
main .post .info .tag {
main .post > .info .date,
main .post > .info .tag {
margin: 0 0.5rem;
}
main .post .info .date i,
main .post .info .tag i {
main .post > .info .date i,
main .post > .info .tag i {
position: relative;
top: 0.05rem;
}
@ -102,10 +102,46 @@ main .pagenav {
justify-content: space-between;
padding: 2rem 0 5rem 0;
}
main .pagenav a {
main .pagenav > a {
text-decoration: none;
margin: 0 2rem;
}
main .archives {
width: 45rem;
padding-top: 1rem;
font-size: 0.875rem;
}
main .archives > li {
list-style-type: none;
padding: 0;
}
main .archives > .year {
font-size: 1.4rem;
font-weight: 600;
line-height: 2.2rem;
letter-spacing: 0.1rem;
padding: 0.625rem 0;
}
main .archives > .list {
margin-bottom: 3rem;
line-height: 1.75rem;
}
main .archives > .list .title {
padding-bottom: 0.3rem;
}
main .archives > .list .title a {
display: inline-block;
width: 85%;
color: #1f1f1f;
}
main .archives > .list .title .time {
float: right;
color: #c5c5c5;
font-size: 0.875rem;
}
main .archives > .list .title a:hover {
color: #1f1f1f;
}
footer {
padding: 2rem 0;

View File

@ -1,4 +1,5 @@
@charset "UTF-8";
// 全局 HTML 配置
html {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
@ -9,6 +10,7 @@ html {
font-variant-numeric: tabular-nums;
-webkit-font-smoothing: antialiased;
}
// 滚动条
html::-webkit-scrollbar {
width: 10px;
@ -79,7 +81,8 @@ main {
.post{
width: 45rem;
padding-top: 1rem;
}
.post > {
h1 {
a {
letter-spacing: 0.0625rem;
@ -126,18 +129,67 @@ main {
display: flex;
justify-content: space-between;
padding: 2rem 0 5rem 0;
}
.pagenav > {
a {
text-decoration: none;
margin: 0 2rem;
}
}
.archives{
width: 45rem;
padding-top: 1rem;
font-size: 0.875rem;
}
.archives > {
li {
list-style-type: none;
padding: 0;
}
.year {
font-size: 1.4rem;
font-weight: 600;
line-height: 2.2rem;
letter-spacing: 0.1rem;
padding: 0.625rem 0;
}
.list {
margin-bottom: 3rem;
line-height: 1.75rem;
.title{
padding-bottom: 0.3rem;
a {
display: inline-block;
width: 85%;
color: #1f1f1f;
}
.time {
float: right;
color: #c5c5c5;
font-size: 0.875rem;
}
a:hover {
color: #1f1f1f;
}
}
}
}
}
footer {
padding: 2rem 0;
.copyright {
font-size: 0.8rem;
a {
margin: 0 0.125rem;

View File

@ -70,6 +70,15 @@ main .pagenav a {
main .pagenav a:hover {
color: rgba(0, 0, 0, 0.65);
}
main .archives > .list .title a {
color: black;
}
main .archives > .list .title a:hover {
color: rgba(0, 0, 0, 0.65);
}
main .archives > .list .title .time {
color: #c5c5c5;
}
footer .copyright a {
color: rgba(0, 0, 0, 0.25);

View File

@ -63,7 +63,7 @@ body {
main {
background: #ffffff;
box-shadow: 0 0.375rem 1rem -0.5rem rgba(0, 0, 0, 0.08);
// 首页
.post {
h1 {
a {
@ -96,7 +96,7 @@ main {
}
}
}
// 文章分页
.pagenav {
border-bottom: 1px solid #f2f2f2;
@ -108,6 +108,24 @@ main {
}
}
}
// 归档页面
.archives > {
.list {
.title{
a {
color: rgb(0, 0, 0);
&:hover {
color: rgb(0, 0, 0, 0.65);
}
}
.time {
color: #c5c5c5;
}
}
}
}
}
// 脚注
@ -123,3 +141,5 @@ footer {
}
}
}
//