hexo博客格式控制


layout:
- draft
title: hexo博客格式控制
date: 2023-09-24 19:14:18
tags:

本文针对Next主题,不确保对于其它主题有效(但从修改模式来看,是有效的)

Next默认是会显示全文的,这样显然很不方便,因此需要一些方法去只显示前面一部分。
修改配置


首先需要在Next主题的_config.yml中把设置打开:(默认安装时就打开了)

Automatically excerpt description in homepage as preamble text.

excerpt_description: true

1
2

之后有两种方法
方法一:写概述

在文章的front-matter中添加description,其中description中的内容就会被显示在首页上,其余一律不显示。

1
2
3
4
5
6
7
8
9
10
11
---
title: 让首页显示部分内容
date: 2020-02-23 22:55:10
description: 这是显示在首页的概述,正文内容均会被隐藏。
---

1
2
3
4
5

比较不方便的是还得写一下概述,很多时候会懒得写概述,于是就需要第二种方法了。
方法二:文章截断

在需要截断的地方加入:

1

首页就会显示这条以上的所有内容,隐藏接下来的所有内容。
例如本文会显示到修改配置上面。

这个明显就方便很多,但当然有利有弊,比如开头都是废话首页看着就不是很好看,因此我一般会先选择方法二,如果感觉文章前面的写的不太好再用方法一。

开启目录

Hexo博客NexT主题中是有目录的,只是在默认情况下没有开启,需要我们来手动开启。

文章目录样式文件custom.styl文件位于themes/next/source/css/_custom

1
2
//文章目录默认展开
.post-toc .nav .nav-child { display: block; }
1
2
3
.post-toc ol {  
font-size : 13px;
}

修改主题配置文件

主题配置文件位于themes/next/_config.yml
每行目录超长自动换行

1
2
3
toc:
enable: true
wrap: true

配置时钟

https://github.com/theme-next/theme-next-calendar

  1. 安装插件
    npm install theme-next/theme-next-calendar

  2. 在next主题配置文件_config.yml配置
    路径为 xxxxxxxxxxxxxxx\node_modules\hexo-theme-next_config.yml

    1
    2
    3
    4
    5
    6
    7
    8
    CloudCalendar:
    enable: true
    language: zh-CN
    single: true
    root: /calendar/
    calendarCdn: //cdn.jsdelivr.net/gh/theme-next/theme-next-calendar/calendar.min.js
    langCdn: //cdn.jsdelivr.net/gh/theme-next/theme-next-calendar/languages.min.js
    #disableSidebar: false