主题地址:https://github.com/MaLuns/hexo-theme-async
文章页面
删除other articles
原页面如下:
但是工作室认为并不需要此模块,需要对其进行去除。
找到主题文件下的layout/post.ejs
文件,搜索articles
,找到如下代码,添加两行代码:
<!-- 添加的第一行代码 -->
<% if (theme.article.other) { %>
<div class="row">
<div class="col-lg-12">
<!-- title -->
<h5 class="trm-mb-40 trm-title-with-divider">
<%- __('title.other_articles') %>
<span data-number="02"></span>
</h5>
</div>
<% if(page.prev){ %>
<%- partial('./_partial/post-card',{ post: page.prev }) %>
<%}%>
<% if(page.next){ %>
<%- partial('./_partial/post-card',{ post: page.next }) %>
<%}%>
</div>
<!-- 添加的第二行代码 -->
<% } %>
在主题的配置文件中,添加:
article:
other: false
如果other
为true
,则开启其他文章,若为false
,则为不开启。
添加作者
在原主题中,博客的作者就是网站的作者,不可修改。但本博客是工作室运营,有区分作者的需求。
找到主题文件下的layout/post.ejs
文件,搜索theme.user.name
,做出如下修改:
<div class="trm-card trm-label trm-label-light text-center"><i class="far fa-user trm-icon"></i><br>
<!-- 原来的代码 -->
<!-- <%= theme.user.name %> -->
<!-- 修改后的代码 -->
<% if (!theme.article.author) { %>
<%= theme.user.name %>
<% } else { %>
<%= page.author %>
<% } %>
</div>
然后在文章的markdown
文件里写author
参数即可显示:
---
title: 主题魔改
date: 2022-05-11 22:54:43
author: 王建文
---
在主题的配置文件中添加参数:
article:
author: true
当author
为true
时,作者使用博客内的author
,当为false
是使用的是整个项目的作者。