Back

Hero Image Blur image

简介

一个现代化、优雅的 Hugo 主题,基于 Astro Theme Pure 移植而来。使用了 Alpine.js + UnoCSS 构建,支持现代化的网站开发体验。缘起

快速体验

git clone https://github.com/kkbt0/Somnia
cd Somnia
just
bash

参考 justfile 文件。如果你没有安装 just,也可以直接复制命令到命令行执行。

git clone https://github.com/kkbt0/Somnia
cd Somnia
hugo server -s exampleSite/ --disableFastRender
bash
  • 需要注意,本项目需要 Hugo >= v0.158.0 环境。
  • 如果需要使用 UnoCSS ,需要 pnpm install 安装依赖。
  • 如果需要使用 Pagefind 提供的搜索,需要安装 pagefind_extended。

配置参考 Somnia/exampleSite/config/_default 下文件,以及 Somnia/exampleSite/hugo.toml 文件。

自定义 CSS/JS

编写自定义的 CSS/JS 可以参考your_website/themes/Somnia/assets/js/custom.jsyour_website/themes/Somnia/assets/css/custom.css,在 your_website/assets/css/custom.cssyour_website/assets/js/custom.js 中编写代码。以覆盖原有的 custom 样式/脚本。

这在你需要不修改 Somnia 主题的情况下定制你的主题,或编写 shortcode 的时候会用到。

评论系统

Mastodon

实现了一个基于 Mastodon 嘟嘟的展示当做 Somnia 的评论系统。

配置文件中添加

[params.comment]
enable = true
provider = "Mastodon"
toml

然后在 markdown 中添加

---
title: Title
comments: true
fediverse: "https://mastodon.social/@name/xxxxxxxxx"
---
yaml

注意事项

  • Suwp.js 访问同源网页,需要链接指向的网页/xml等资源包含容器。或 _blank 。如 index.xml 页面直接跳转控制台会报错,并且回退后 Swup.js 无法正常运行。
Somnia
https://kkbt0.github.io/Somnia/posts/somnia/
Author 恐咖兵糖
Published at
Copyright CC BY-NC-SA 4.0