Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
✨ Add independent Chinese style
Browse files Browse the repository at this point in the history
  • Loading branch information
canstand committed Nov 19, 2021
1 parent 78034d0 commit 8838703
Show file tree
Hide file tree
Showing 24 changed files with 577 additions and 129 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 4
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Bjørn Erik Pedersen
Copyright (c) 2021 Can Stand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# Compost Theme | Hugo

Compost is a simple theme for [Hugo](https://gohugo.io).
Compost is a simple, lightweight theme for [Hugo](https://gohugo.io). Mainly based on the [Congo](https://github.com/jpanther/congo), also refer to [hugo-starter-tailwind-basic](https://github.com/bep/hugo-starter- tailwind-basic) and so on.

It is based on the original [hugo-starter-tailwind-basic](https://github.com/bep/hugo-starter-tailwind-basic) and [Congo](https://github.com/jpanther/congo).
🌏[Demo site](https://canstand.github.io/compost/)

## Usage (As a Theme)
## Features
The main differences with [Congo](https://github.com/jpanther/congo):
- The text style is customized for the [Chinese language](https://canstand.github.io/compost/zh/posts/typography/) (automatically applied when lang is zh), which does not affect the entire site English.
- The Tailwind CSS JIT mode is not used. Therefore, you can directly use `hugo server -D` to test, the lack of which is that the build will take longer.

Import `github.com/canstand/compost` into your project, and then run:
## Usage

1. Set the theme in the Hugo project as `github.com/canstand/compost`:
```toml
theme = 'github.com/canstand/compost'
```

2. Install or upgrade dependencies:
```bash
hugo mod get -u
hugo mod npm pack
npm install
```

Then run your project as usual.

3. Then run your project as usual.
```bash
hugo server
```
31 changes: 31 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Hugo Compost 主题

Compost 是一个简单、轻量级的 [Hugo](https://gohugo.io) 主题。主要基于 [Congo](https://github.com/jpanther/congo) 改造,并参考了 [hugo-starter-tailwind-basic](https://github.com/bep/hugo-starter-tailwind-basic) 等。

🌏[演示站点](https://github.com/canstand/compost/zh)

## 特性
[Congo](https://github.com/jpanther/congo) 的主要区别:
* 针对简体中文语言定制了正文样式(lang 为 zh 时自动应用),不影响全站英文。
* 暂时没用 Tailwind CSS JIT 模式。因此可以直接用 `hugo server -D` 测试,缺占是 build 耗时会长一些。

## 使用

1. 在 Hugo 项目里指定主题为 `github.com/canstand/compost`
```toml
theme = 'github.com/canstand/compost'
```

2. 安装或升级依赖:

```bash
hugo mod get -u
hugo mod npm pack
npm install
```

3. 之后按正常开发与测试:

```bash
hugo server
```
6 changes: 6 additions & 0 deletions archetypes/posts/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: {{ replace .Name "-" " " | title }}
date: {{ .Date }}
draft: true
description: ""
---
183 changes: 182 additions & 1 deletion assets/css/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,191 @@
.prose .heading-anchor:focus,
.prose h2:hover > .heading-anchor,
.prose h3:hover > .heading-anchor,
.prose h4:hover > .heading-anchor {
.prose h4:hover > .heading-anchor,
.prose h5:hover > .heading-anchor,
.prose h6:hover > .heading-anchor {
@apply opacity-100;
}

.prose figure > * {
margin-inline-start: auto;
margin-inline-end: auto;
}
.prose figure > figcaption {
text-align: center;
}

.prose figure:lang(zh) {
margin-inline-start: 0;
margin-inline-end: 0;
margin-block-start: 16px;
margin-block-end: 16px;
}

.prose h1:lang(zh),
.prose h2:lang(zh),
.prose h3:lang(zh) {
margin-block-start: 24px;
letter-spacing: 0.05em;
font-weight: 600;
}

.prose h4:lang(zh),
.prose h5:lang(zh) {
margin-block-start: 24px;
margin-block-end: 12px;
font-weight: 600;
}

.prose h6:lang(zh) {
margin-block-start: 24px;
margin-block-end: 12px;
}

.prose h1:lang(zh) + h2,
.prose h2:lang(zh) + h3,
.prose h3:lang(zh) + h4,
.prose h4:lang(zh) + h5,
.prose h5:lang(zh) + h6 {
margin-block-start: 12px;
}

.prose h1:lang(zh) {
margin-block-end: 24px;
font-size: 32px;
line-height: 48px;
}

.prose h2:lang(zh) {
margin-block-end: 12px;
font-size: 24px;
line-height: 36px;
}

.prose h3:lang(zh) {
margin-block-end: 12px;
font-size: 20px;
line-height: 36px;
}

.prose h4:lang(zh) {
font-size: 18px;
font-weight: 600;
line-height: 24px;
}

.prose hr:lang(zh) {
width: 30%;
margin-block-start: 48px;
margin-block-end: 47px;
margin-inline-start: auto;
margin-inline-end: auto;
}

.prose p:lang(zh) {
margin-block-start: 12px;
margin-block-end: 24px;
text-align: justify;
}

.prose pre:lang(zh) {
margin-block-start: 12px;
margin-block-end: 12px;
}

.prose ul:lang(zh),
.prose ol:lang(zh),
.prose dl:lang(zh) {
margin-block-start: 12px;
margin-block-end: 24px;
}

.prose ul:lang(zh) > li,
.prose ol:lang(zh) > li,
.prose dl:lang(zh) > li {
margin-block-start: 0;
margin-block-end: 0;
}

.prose ul:lang(zh) ul,
.prose ul:lang(zh) ol,
.prose ol:lang(zh) ul,
.prose ol:lang(zh) ol {
margin-block-start: 0;
margin-block-end: 0;
}

.prose ol:lang(zh) > li,
.prose ul:lang(zh) > li {
padding-inline-start: 32px;
}

.prose ol:lang(zh) > li::before {
left: 4px;
}

.prose ul:lang(zh) > li::before {
top: 9px;
}

.prose table:lang(zh) {
box-sizing: border-box;
margin-block-start: 12px;
margin-block-end: 24px;
margin-inline-start: auto;
margin-inline-end: auto;
@apply border-neutral-300 dark:border-neutral-600;
}

.prose thead:lang(zh) th,
.prose tbody:lang(zh) td {
padding-block-start: 6px;
padding-block-end: 6px;
padding-inline-start: 8px;
padding-inline-end: 8px;
border-width: 1px;
border-collapse: collapse;
border-style: solid;
@apply border-neutral-300 dark:border-neutral-600;
}

.prose tbody:lang(zh) tr {
border-bottom-width: 0px;
border-collapse: collapse;
}

.prose tbody:lang(zh) tr:last-child {
border-bottom-width: 0px;
border-collapse: collapse;
}

.prose thead:lang(zh) tr:first-child {
border-top-width: 0px;
border-collapse: collapse;
}

.prose thead:lang(zh) th:last-child,
.prose tbody:lang(zh) td:first-child {
padding-inline-end: 8px;
}

.prose thead:lang(zh) th:first-child,
.prose tbody:lang(zh) td:last-child {
padding-inline-start: 8px;
}

.prose :lang(zh) code::before,
.prose :lang(zh) code::after {
content: none;
width: 4px;
}

.prose blockquote:lang(zh) {
quotes: "「" "」" "『" "』";
font-style: normal;
}


/* Prose escape hatch */
.no-prose > p {
@apply mt-0 last:mb-0;
Expand Down
4 changes: 4 additions & 0 deletions assets/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ body a,
body button {
@apply transition;
}

body:lang(zh) {
-webkit-font-smoothing: subpixel-antialiased;
}
31 changes: 31 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ defaultContentLanguage = "en"
title = "Compost"
enableEmoji = true

[languages]
[languages.en]
weight = 1
[languages.zh]
weight = 2
languageName = '简体中文'
hasCJKLanguage = true
[[languages.zh.menu.main]]
name = "首页"
pageRef = "/"
weight = 1

[[languages.zh.menu.main]]
name = "文章"
pageRef = "posts"
title = "文章列表"
weight = 10

[[languages.zh.menu.main]]
name = "标签"
pageRef = "tags"
title = "标签列表"
weight = 20

[[languages.zh.menu.main]]
name = "GitHub"
url = "https://github.com/canstand/compost"
weight = 30
[languages.zh.params.article]
dateFormat = "2006/01/02"

[module]
[[module.imports]]
# We include the theme by "../.." above, but we need one module import for Hugo to detect us as a Hugo Module.
Expand Down
19 changes: 14 additions & 5 deletions exampleSite/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ description: "This is a demo of the Compost theme for Hugo."
A simple, lightweight theme for Hugo built with Tailwind CSS.
{{< /lead >}}

Compost is a simple theme for [Hugo](https://gohugo.io). It is based on the original [hugo-starter-tailwind-basic](https://github.com/bep/hugo-starter-tailwind-basic) and [Congo](https://github.com/jpanther/congo).
Compost is a simple, lightweight theme for [Hugo](https://gohugo.io). Mainly based on the [Congo](https://github.com/jpanther/congo), also refer to [hugo-starter-tailwind-basic](https://github.com/bep/hugo-starter- tailwind-basic) and so on.

## Usage (As a theme)
## Features
The main differences with [Congo](https://github.com/jpanther/congo):
- The text style is customized for the simplified Chinese language (automatically applied when lang is zh), which does not affect the entire site English.
- The Tailwind CSS JIT mode is not used. Therefore, you can directly use `hugo server -D` to test, the lack of which is that the build will take longer.

Import `github.com/canstand/compost` into your project, and then run:
## Usage

1. Set the theme in the Hugo project as `github.com/canstand/compost`:
```toml
theme = 'github.com/canstand/compost'
```

2. Install or upgrade dependencies:
```bash
hugo mod get -u
hugo mod npm pack
npm install
```

Then run your project as usual.

3. Then run your project as usual.
```bash
hugo server
```
Loading

0 comments on commit 8838703

Please sign in to comment.