配置front matter

使用vscode snippet快捷生成front matter

参考博客:vs-code-workflows-for-hugomarkdown-snippets-not-working-in-vscode

在使用了obsidian后,加入一些插件如quickadd等,优化了文章撰写,但是obsidian不能在网页端登陆,虽然多个平台都有部署安装包,此外仅支持md文件使我不能继续使用下去。

后来沉思一下现有写文章流程,缺点是什么,发现是不能生成front matter,故东找西找,甚至一度又回归到obsidian后,终于发现vscode的snippet,正好几乎完美符合我的需求(不能自动呈现所有tags)。

目前我的写作流程是:

  1. 语雀上写好文章后导出md
  2. 用pic-go插件pic-migrate转换语雀图片并生成新md文件
  3. 在vscode上加入front matter
  4. 在vscode上上传至github
{
"hugo post template":{
"scope": "markdown", // Add comma separated ids of the languages where the snippet is applicable in the scope field.
"prefix": "post", // trigger the snippet
"body": [ // expanded and inserted where trigger
"---",
"title: ${TM_FILENAME/(.*)\\..+$/$1/}",
"date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND +0800",
"lastmod: ",
"summary: ",
"slug: $2", // url: www.keepjolly.com/tags/:slug/
"toc: ${3|true,false|}",
"rightToc: ${4|false,true|}",
"categories: ",
"- ${5|tech,learn,algorithm,error,create,other,life|}",
"tags: ",
"- ${6|ComputerVision,C++,LeetCode,Blog,Others,Install|}",
"original: true",
"author: Rurouni",
"website: www.keepjolly.com",
"---"
]
},
"update time":{
"scope": "markdown",
"prefix": "update",
"body": "$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND +0800"
}
}

完整可支持的front-matter,貌似也可以定制,自行百度吧

配置搜索功能

参考博客:修改algolia的设置hugo添加algolia搜索支持

配置config.toml

# Algolia 的搜索索引
[outputFormats.Algolia]
mediaType = "application/json"
baseName = "algolia"
isPlainText = true
notAlternative = true
# 摘要的字数限制 此处用于algolia检索
summaryLength = 70 # Hugo 的输出控制
[outputs]
page = ["HTML"]
home = ["HTML", "SectionsAtom", "SectionsRSS", "SearchIndex", "Algolia"]
section = ["HTML"]
taxonomy = ["HTML"]
term = ["HTML"] # 菜单配置
[menu]
## 菜单栏
[[menu.main]] # 多加入一个搜索栏
weight = 8
identifier = "search"
post = "search" ######################################
# Algolia search # 说明:需要开启 `Algolia` 在Hugo 的输出控制,且需要每
# 次将生成的 algolia.json 文件上传到
# Algolia enableAlgoliaSearch = true algoliaAppId = ""
algoliaApiKey = ""
algoliaIndexName = ""
# 说明:https://www.algolia.com/

algolia官网查找key



或者登录后访问网址,然后找到对应Application ID、ApiKey、IndexName,找不到可以自行在参考博客中查找。

覆盖index.algolia.json配置

然后在博客主目录/layouts下新建index.algolia.json来覆盖meme中的配置,此处内容参考dreamsafari的json

此处需多加一个参数summary,内容为content内容,或者$page.Summary(但是此处显示会无法转义字符,目前无法解决,以后应该也不会解决,等有缘人),否则会显示undefined

{{- range $i, $c := $chunked -}}
{{- $index = $index | append (dict "objectID" (print $page.File.UniqueID "_" $i) "order" $i "title" $page.Title "date" $page.Date "url" $page.Permalink "tags" $page.Params.tags "categories" $page.Params.Categories "summary" $c) -}}
{{- end -}}

修改algolia搜索配置

此处配置搜索选项,参考修改algolia的设置

自动上传algolia.json

详见github action处

配置about页及视频

视频

<video src="QmTz7jzWdGrTVKT7YwNwX9cEgfg4smNFHVxnaFDR82BrXt" poster="../images/Gypsy Heart.jpg" controls >
如需下载:<a href="https://gateway.pinata.cloud/ipfs/QmTz7jzWdGrTVKT7YwNwX9cEgfg4smNFHVxnaFDR82BrXt">MP4</a>
</video> config.toml
# 是否开启
enableVideoHost = true # 相对路径获取图片,用于poster属性 # 视频外链地址
videoHostURL = "https://gateway.pinata.cloud/ipfs/" # 用于src属性,使其链接干净
# !!必须src开头,否则无法识别到hash!!

为了使封面图poster与视频适配:

设置object-fit: 无效,被迫剪裁图片以适配视频。

音乐

如果想配置音乐

  1. 根目录下的layouts\shortcodes\创建music.html

该代码同时支持列表和单曲模式

<!-- 使用meting-js的方式  https://immmmm.com/hugo-shortcodes-music/ -->
<!-- require APlayer https://aplayer.js.org/#/zh-Hans/?id=%E5%85%A5%E9%97%A8 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
{{- if .IsNamedParams -}} <div id="player"></div> {{- if .Get "url" -}}
<script>
const ap1 = new APlayer({
container: document.getElementById('player'),
lrcType: 3,
audio: [{
name: '{{ .Get `name` }}',
artist: '{{ .Get `artist` }}',
url: '{{ .Get `url` }}',
cover: '{{ .Get `cover` }}',
lrc: '{{ .Get `lrc` }}',
theme: '#f44336'
}]
});
</script>
{{- else if .Get "auto" -}}
<script>
const ap = new APlayer({
container: document.getElementById('player'),
mini: false,
autoplay: false,
theme: '#FADFA3',
loop: 'all',
order: 'random',
preload: 'auto',
volume: 0.7,
mutex: true,
listFolded: false,
listMaxHeight: 90,
lrcType: 3,
audio: [
{
name: '{{ .Get `name1` }}',
artist: '{{ .Get `artist1` }}',
url: '{{ .Get `url1` }}',
cover: '{{ .Get `cover1` }}',
lrc: '{{ .Get `lrc1` }}',
theme: '#f44336'
},
{
name: '{{ .Get `name2` }}',
artist: '{{ .Get `artist2` }}',
url: '{{ .Get `url2` }}',
cover: '{{ .Get `cover2` }}',
lrc: '{{ .Get `lrc2` }}',
theme: '#46718b'
}
]
});
</script>
{{- end -}} {{- end -}}
  1. 在about/_index.md中修改代码
{{< music url="xxx.mp3"
name="Try" artist="Colbie Caillat" cover="../songs/Gypsy Heart song.jpg" lrc="xxx.lrc">}}
  1. 在assets\scss\custom_custom.scss中修改暗夜样式
// Aplayer
:root[data-theme="light"]{
.aplayer-pic{
background-color: #b7daff;
}
}
:root[data-theme="dark"]{
.aplayer {
background: #212121
} .aplayer.aplayer-withlist .aplayer-info {
border-bottom-color: #5c5c5c
} .aplayer.aplayer-fixed .aplayer-list {
border-color: #5c5c5c
} .aplayer .aplayer-body {
background-color: #212121
} .aplayer .aplayer-info {
border-top-color: #212121
} .aplayer .aplayer-info .aplayer-music .aplayer-title {
color: #fff
} .aplayer .aplayer-info .aplayer-music .aplayer-author {
color: #fff
} .aplayer .aplayer-info .aplayer-controller .aplayer-time {
color: #eee
} .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon path {
fill: #eee
} .aplayer .aplayer-list {
background-color: #212121
} .aplayer .aplayer-list::-webkit-scrollbar-thumb {
background-color: #999
} .aplayer .aplayer-list::-webkit-scrollbar-thumb:hover {
background-color: #bbb
} .aplayer .aplayer-list li {
color: #fff;
border-top-color: #666
} .aplayer .aplayer-list li:hover {
background: #4e4e4e
} .aplayer .aplayer-list li.aplayer-list-light {
background: #6c6c6c
} .aplayer .aplayer-list li .aplayer-list-index {
color: #ddd
} .aplayer .aplayer-list li .aplayer-list-author {
color: #ddd
} .aplayer .aplayer-lrc {
text-shadow: -1px -1px 0 #666
} .aplayer .aplayer-lrc:before {
background: -moz-linear-gradient(top, #212121 0%, rgba(33, 33, 33, 0) 100%);
background: -webkit-linear-gradient(top, #212121 0%, rgba(33, 33, 33, 0) 100%);
background: linear-gradient(to bottom, #212121 0%, rgba(33, 33, 33, 0) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#212121', endColorstr='#00212121', GradientType=0)
} .aplayer .aplayer-lrc:after {
background: -moz-linear-gradient(top, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
background: -webkit-linear-gradient(top, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
background: linear-gradient(to bottom, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00212121', endColorstr='#cc212121', GradientType=0)
} .aplayer .aplayer-lrc p {
color: #fff
} .aplayer .aplayer-miniswitcher {
background: #484848
} .aplayer .aplayer-miniswitcher .aplayer-icon path {
fill: #eee
}
}

配置视频介绍文字

  1. _index.md
<h2 class="try">Try</h2>
<!-- <p style="text-align:center" class="colbie">Colbie Caillat</p> -->
<p style="text-align:center">
<em>
You don't have to try so hard<br>
You don't have to, give it all away<br>
You just have to get up, get up, get up, get up<br>
You don't have to change a single thing</em>
</p>
  1. config.toml
# 网络字体链接
fontsLink = "https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700&family=Source+Code+Pro:ital,wght@0,400;0,700;1,400;1,700&family=Cinzel+Decorative:wght@700&display=swap"
  1. assets/scss/custom/_custom.scss
// about页
.try { // io-oi.me
margin-top: 50px;
text-align: center;
font-family: 'Cinzel Decorative', serif !important;
background-image: linear-gradient(90deg, #f37055 0, #ef4e7b 40%, #f37055 45%, #a166ab 50%, #f37055 55%, #ef4e7b 60%, #f37055 100%);
background-size: cover;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.colbie {
text-align: center;
font-family: 'Cinzel Decorative', serif !important;
background-image: linear-gradient(90deg, #f37055 0, #ef4e7b 40%, #f37055 45%, #a166ab 50%, #f37055 55%, #ef4e7b 60%, #f37055 100%);
background-size: cover;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
} // https://io-oi.me/tech/get-started-with-variable-fonts/
@font-face {
font-family: 'Amstelvar';
font-display: swap;
src: url('#{$baseRelURL}/fonts/Amstelvar-Italic-VF.woff2') format('woff2-variations'),
url('#{$baseRelURL}/fonts/Amstelvar-Italic-VF.woff2') format("woff2");
font-weight: 100 900;
font-stretch: 50% 125%;
font-style: italic;
} @font-face {
font-family: 'Amstelvar';
font-display: swap;
src: url('#{$baseRelURL}/fonts/Amstelvar-Roman-VF.woff2') format('woff2-variations'),
url('#{$baseRelURL}/fonts/Amstelvar-Roman-VF.woff2') format('woff2');
font-weight: 100 900;
font-stretch: 50% 125%;
font-style: normal;
} body {
font-family: 'Amstelvar', 'Noto Serif SC', serif;
} :root {
--text-wdth: 90;
--text-opsz: 40;
--text-YTLC: 460;
} body {
font-variation-settings:
'wdth' var(--text-wdth),
'opsz' var(--text-opsz),
'YTLC' var(--text-YTLC);
} .post-title {
font-family: 'glyph-correction', 'Amstelvar', 'Noto Serif SC', serif;
font-variation-settings:
'wght' 550,
'opsz' 60,
'YOPQ' 90;
} .list-item-time {
font-feature-settings: 'tnum';
} blockquote.quote {
position: relative;
margin: 2em auto !important;
padding-left: 3em;
color: inherit;
border: none;
p {
text-indent: 0 !important;
}
&::before {
position: absolute;
left: 0;
content: '“';
font-size: 3em;
font-weight: bold;
line-height: 1;
}
&.poetry {
display: table;
padding: 0;
&::before {
left: -1em;
}
p {
margin: 0 0 1em;
}
p:last-child {
margin: 0;
}
}
&.en {
p {
line-height: 1.618;
text-align: left;
hyphens: auto;
-webkit-hyphens: auto;
-moz-hyphens: auto;
}
}
&.italic {
p {
font-style: italic;
}
}
} @media (max-width: $maxWidth) {
blockquote.quote {
&.poetry {
padding-left: 3em;
&::before {
left: 0;
}
}
}
}

配置toc到页面右边

参考博客

原本想实现滚动动画的,技术力不够,等大佬

创建mytoc.html

<!-- 注意需要在页面的front-matter中toc:false并rightToc:true -->
{{ if (.Params.rightToc | default false ) }}
<div class="post-toc" id="post-toc">
<aside>
<header>
<h4>文章の字数: {{ .WordCount }}</h4>
</header>
{{ $emtLiPtrn := "(?s)<ul>\\s<li>\\s<ul>(.*)</li>\\s</ul>" }}
{{ $rplcEmtLi := "<ul>$1" }}
{{ .TableOfContents | replaceRE $emtLiPtrn $rplcEmtLi | safeHTML }}
<!-- https://github.com/gohugoio/hugo/issues/1778#issuecomment-483880269 -->
<!-- {{.TableOfContents}} -->
</aside>
<a href="#" id="toc-toggle"></a>
</div> {{ end }}

创建single.html

{{ define "main" }}
{{ partial "pages/post.html" . }}
<!-- 将主题的single复制后新加的内容 -->
<div class = "toc-wrapper">
{{ partial "mytoc.html" . }}
</div>
{{ end }}

修改_custom.scss样式

.post-toc {
position: fixed;
right: 5px;
max-width: 40%;
overflow: auto;
top: 5%;
width: 25vw;
bottom: 30px
} .toc-wrapper {
::-webkit-scrollbar {
width: 6px;
height: 8px;
} ::-webkit-scrollbar-thumb {
height: 40px;
background-color: #eee;
border-radius: 16px; &:hover {
background-color: #ddd;
}
}
}
@media only screen and (max-width: 1224px) {
.post-toc {
display: none;
}
}

hugp-MemE关键美化的更多相关文章

  1. KRPano资源分析工具使用说明(KRPano XML/JS解密 切片图批量下载 球面图还原 加密混淆JS还原美化)

    软件交流群:571171251(软件免费版本在群内提供) krpano技术交流群:551278936(软件免费版本在群内提供) 最新博客地址:blog.turenlong.com 限时下载地址:htt ...

  2. 滚动条美化实践(原生js,iscroll,nicescroll)

    近期需要改造项目中的滚动条,使原滚动条在三大浏览器下表现相同,分享一下自己的改造经历: 项目中的滚动条分布在网页的各个小窗口中,使用的是-webkit-scrollbar制作,在-webkit内核的浏 ...

  3. ElasticSearch关键概念

    Elasticsearch 添加索引 一个存储关联数据的地方 用来指向一个或者多个分片(shards)的逻辑命名空间(logical namespcase) 应用程序直接与索引通信 一个分片(shar ...

  4. 我的硬盘安装ArchLinux+xorg+gnome+美化

    整个安装需要联接网络!现在的xorg为6.8.1,gnome为2.8.0                看了大家为了使用gnome,出现了那么多问题!这里我就推荐一个发行版,再安装上gnome2.8. ...

  5. 美化VC界面(用户登录界面)

    源代码:下载 VC开发程序单调的界面相信大家都是深有感触,提到界面美化编程,人们都会说做界面不要用VC写,太难了.一句俗语:难者不会,会者不难.VC的美化界面编程并没有人们想像的那么难.这篇文章是我写 ...

  6. (数据科学学习手札55)利用ggthemr来美化ggplot2图像

    一.简介 R中的ggplot2是一个非常强大灵活的数据可视化包,熟悉其绘图规则后便可以自由地生成各种可视化图像,但其默认的色彩和样式在很多时候难免有些过于朴素,本文将要介绍的ggthemr包专门针对原 ...

  7. input美化问题

    对于前端来说,一个比较大的问题是,当HTML提供的最原始的控件长的很丑可是又没有相应的属性去更改,碰到这个问题时我们应该怎么办?比如radio的那个单选框我觉得好丑啊,怎么办呢?一个很好的思路就是把它 ...

  8. 纯CSS3美化radio和checkbox

    如题,主要通过CSS3来实现将radio和checkbox美化的效果.可是兼容性并非非常好,PC端仅仅支持chrome浏览器(IE和Firefox測试不行,其它没有很多其它測试).然后微信端和QQ端訪 ...

  9. 个人永久性免费-Excel催化剂功能第74波-批量排版格式利器,瞬间美化表格

    PPT和WORD的世界,充满着排版的美化操作,在Excel世界同样也需要对表格.图表的美化,此篇带你进入真正的制表专家行列,使用Excel催化剂的格式管理增强功能加上对美感的艺术造诣,对Excel表格 ...

  10. 浅谈Winform控件开发(一):使用GDI+美化基础窗口

    写在前面: 本系列随笔将作为我对于winform控件开发的心得总结,方便对一些读者在GDI+.winform等技术方面进行一个入门级的讲解,抛砖引玉. 别问为什么不用WPF,为什么不用QT.问就是懒, ...

随机推荐

  1. 最新版本 Stable Diffusion 开源AI绘画工具之部署篇

    目录 AI绘画 本地环境要求 下载 Stable Diffusion 运行启动 AI绘画 关于 AI 绘画最近有多火,既然你有缘能看到这篇文章,那么相信也不需要我过多赘述了吧? 随着 AI 绘画技术的 ...

  2. Flask快速入门day02(1、CBV使用及源码分析,2、模板用法,3、请求与响应的基本用法,4、session的使用及源码分析,5、闪现,6、请求扩展)

    目录 Flask框架 一.CBV分析 1.CBV编写视图类方法 二.CBV源码分析 1.CBV源码问题 2.补充问题 3.总结 三.模板 1.py文件 2.html页面 四.请求与响应 1.reque ...

  3. 二进制安装Kubernetes(k8s) v1.25.0 IPv4/IPv6双栈

    二进制安装Kubernetes(k8s) v1.25.0 IPv4/IPv6双栈 Kubernetes 开源不易,帮忙点个star,谢谢了 介绍 kubernetes(k8s)二进制高可用安装部署,支 ...

  4. flask-wtf使用

    Web应用程序的一个重要方面是为用户提供一个用户界面.HTML提供了一个 标签,用于设计一个接口.一个Form 元素,例如文本输入,单选框等可以适当地使用. 通过GET或POST方法将用户输入的数据以 ...

  5. pandas这dataframe结构

    认识DataFrame结构 DataFrame 一个表格型的数据结构,既有行标签(index),又有列标签(columns),它也被称异构数据表,所谓异构,指的是表格中每列的数据类型可以不同,比如可以 ...

  6. v-if与v-for的优先级

    在Vue2中 v-for的优先级要高于v-if 在Vue3中 v-if 的优先级要高于v-for

  7. 绝对强大的三大linux指令:ar, nm, objdump

    前言 如果普通编程不需要了解这些东西,如果想精确控制你的对象文件的格式或者你想查看一下文件对象里的内容以便作出某种判断,刚你可以看一下下面的工具:objdump, nm, ar.当然,本文不可能非常详 ...

  8. [C++项目] 通讯录管理系统

    文章目录 通讯录管理系统 1.系统需求 2.创建项目 2.1 创建项目 2.2添加文件 3.菜单功能 4.退出功能 5.添加联系人 5.1 设计联系人结构体 5.2 设计通讯录结构体 5.3 main ...

  9. SpringBoot 集成 SpringSecurity + MySQL + JWT 附源码,废话不多直接盘

    SpringBoot 集成 SpringSecurity + MySQL + JWT 无太多理论,直接盘 一般用于Web管理系统 可以先看 SpringBoot SpringSecurity 基于内存 ...

  10. 2022-01-18:将数组分成两个数组并最小化数组和的差。 给你一个长度为 2 * n 的整数数组。你需要将 nums 分成 两个 长度为 n 的数组,分别求出两个数组的和,并 最小化 两个数组和之

    2022-01-18:将数组分成两个数组并最小化数组和的差. 给你一个长度为 2 * n 的整数数组.你需要将 nums 分成 两个 长度为 n 的数组,分别求出两个数组的和,并 最小化 两个数组和之 ...