Skip to content

Commit 934b23b

Browse files
committed
Fix documentation builder
1 parent d25fc49 commit 934b23b

File tree

5 files changed

+309
-9
lines changed

5 files changed

+309
-9
lines changed

docs/_config.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ social:
4343
# It will be displayed as the default author of the posts and the copyright owner in the Footer
4444
name: TheYOSH
4545
email: terrariumpi@theyosh.nl # change to your email address
46+
fediverse_handle: "@theyosh@mastodon.theyosh.nl" # change to your fediverse handle or leave empty
4647
links:
4748
# The first element serves as the copyright owner's link
4849
# - https://twitter.com/username # change to your twitter homepage
@@ -164,7 +165,7 @@ plugins:
164165
- jekyll-feed
165166
- jekyll-target-blank
166167
- jemoji
167-
# - jekyll-minifier
168+
- jekyll-minifier
168169
- jekyll-liquify
169170
- jekyll-redirect-from
170171

@@ -267,14 +268,14 @@ sass:
267268
# https://github.com/digitalsparky/jekyll-minifier
268269
# jekyll-minifier:
269270

270-
# compress_html:
271-
# clippings: all
272-
# comments: all
273-
# endings: all
274-
# profile: false
275-
# blanklines: false
276-
# ignore:
277-
# envs: [development]
271+
compress_html:
272+
clippings: all
273+
comments: all
274+
endings: all
275+
profile: false
276+
blanklines: false
277+
ignore:
278+
envs: [development]
278279

279280
exclude:
280281
- '*.gem'

docs/eslint.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import js from '@eslint/js';
3+
import globals from 'globals';
4+
5+
export default defineConfig([
6+
globalIgnores(['assets/*', 'node_modules/*', '_site/*']),
7+
js.configs.recommended,
8+
{
9+
rules: {
10+
semi: ['error', 'always'],
11+
quotes: ['error', 'single']
12+
},
13+
languageOptions: {
14+
globals: {
15+
...globals.browser,
16+
...globals.node
17+
}
18+
}
19+
},
20+
{
21+
files: ['_javascript/**/*.js'],
22+
languageOptions: {
23+
globals: {
24+
...globals.serviceworker,
25+
ClipboardJS: 'readonly',
26+
GLightbox: 'readonly',
27+
Theme: 'readonly',
28+
dayjs: 'readonly',
29+
mermaid: 'readonly',
30+
tocbot: 'readonly',
31+
swconf: 'readonly'
32+
}
33+
}
34+
}
35+
]);

docs/package.json

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"name": "jekyll-theme-chirpy",
3+
"version": "7.4.1",
4+
"description": "A minimal, responsive, and feature-rich Jekyll theme for technical writing.",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/cotes2020/jekyll-theme-chirpy.git"
8+
},
9+
"author": "Cotes Chung",
10+
"license": "MIT",
11+
"since": 2019,
12+
"bugs": {
13+
"url": "https://github.com/cotes2020/jekyll-theme-chirpy/issues"
14+
},
15+
"homepage": "https://github.com/cotes2020/jekyll-theme-chirpy/",
16+
"type": "module",
17+
"scripts": {
18+
"build": "concurrently npm:build:*",
19+
"build:css": "node purgecss.js",
20+
"build:js": "rollup -c --bundleConfigAsCjs --environment BUILD:production",
21+
"watch:js": "rollup -c --bundleConfigAsCjs -w",
22+
"lint:js": "eslint",
23+
"lint:scss": "stylelint _sass/**/*.scss",
24+
"lint:fix:scss": "npm run lint:scss -- --fix",
25+
"test": "npm run lint:js && npm run lint:scss",
26+
"prepare": "husky"
27+
},
28+
"dependencies": {
29+
"@popperjs/core": "^2.11.8",
30+
"bootstrap": "^5.3.8"
31+
},
32+
"devDependencies": {
33+
"@babel/core": "^7.28.4",
34+
"@babel/plugin-transform-class-properties": "^7.27.1",
35+
"@babel/plugin-transform-private-methods": "^7.27.1",
36+
"@babel/preset-env": "^7.28.3",
37+
"@commitlint/cli": "^20.1.0",
38+
"@commitlint/config-conventional": "^20.0.0",
39+
"@rollup/plugin-babel": "^6.1.0",
40+
"@rollup/plugin-node-resolve": "^16.0.3",
41+
"@rollup/plugin-terser": "^0.4.4",
42+
"@semantic-release/changelog": "^6.0.3",
43+
"@semantic-release/exec": "^7.1.0",
44+
"@semantic-release/git": "^10.0.1",
45+
"concurrently": "^9.2.1",
46+
"conventional-changelog-conventionalcommits": "^9.1.0",
47+
"eslint": "^9.38.0",
48+
"globals": "^16.4.0",
49+
"husky": "^9.1.7",
50+
"purgecss": "^7.0.2",
51+
"rollup": "^4.52.5",
52+
"semantic-release": "^25.0.1",
53+
"stylelint": "^16.25.0",
54+
"stylelint-config-standard-scss": "^16.0.0"
55+
},
56+
"prettier": {
57+
"trailingComma": "none"
58+
},
59+
"browserslist": [
60+
"last 2 versions",
61+
"> 0.2%",
62+
"not dead"
63+
],
64+
"commitlint": {
65+
"extends": [
66+
"@commitlint/config-conventional"
67+
],
68+
"rules": {
69+
"body-max-line-length": [
70+
0,
71+
"always"
72+
]
73+
}
74+
},
75+
"release": {
76+
"branches": [
77+
"production"
78+
],
79+
"plugins": [
80+
[
81+
"@semantic-release/commit-analyzer",
82+
{
83+
"preset": "conventionalcommits"
84+
}
85+
],
86+
[
87+
"@semantic-release/release-notes-generator",
88+
{
89+
"preset": "conventionalcommits",
90+
"presetConfig": {
91+
"types": [
92+
{
93+
"type": "feat",
94+
"section": "Features"
95+
},
96+
{
97+
"type": "fix",
98+
"section": "Bug Fixes"
99+
},
100+
{
101+
"type": "perf",
102+
"section": "Improvements"
103+
},
104+
{
105+
"type": "refactor",
106+
"section": "Changes",
107+
"hidden": true
108+
}
109+
]
110+
}
111+
}
112+
],
113+
[
114+
"@semantic-release/changelog",
115+
{
116+
"changelogFile": "docs/CHANGELOG.md",
117+
"changelogTitle": "# Changelog"
118+
}
119+
],
120+
[
121+
"@semantic-release/npm",
122+
{
123+
"npmPublish": false
124+
}
125+
],
126+
[
127+
"@semantic-release/exec",
128+
{
129+
"prepareCmd": "bash tools/release.sh --prepare",
130+
"publishCmd": "bash tools/release.sh"
131+
}
132+
],
133+
[
134+
"@semantic-release/git",
135+
{
136+
"assets": [
137+
"docs",
138+
"package.json",
139+
"*.gemspec"
140+
],
141+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
142+
}
143+
],
144+
"@semantic-release/github"
145+
]
146+
}
147+
}

docs/purgecss.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { promises as fs } from 'fs';
2+
import { PurgeCSS } from 'purgecss';
3+
4+
const DIST_PATH = '_sass/vendors';
5+
const output = `${DIST_PATH}/_bootstrap.scss`;
6+
7+
const config = {
8+
content: ['_includes/**/*.html', '_layouts/**/*.html', '_javascript/**/*.js'],
9+
css: ['node_modules/bootstrap/dist/css/bootstrap.min.css'],
10+
keyframes: true,
11+
variables: true,
12+
// The `safelist` should be changed appropriately for future development
13+
safelist: {
14+
standard: [/^collaps/, /^w-/, 'shadow', 'border', 'kbd'],
15+
greedy: [/^col-/, /tooltip/]
16+
}
17+
};
18+
19+
function main() {
20+
fs.rm(DIST_PATH, { recursive: true, force: true })
21+
.then(() => fs.mkdir(DIST_PATH))
22+
.then(() => new PurgeCSS().purge(config))
23+
.then((result) => {
24+
return fs.writeFile(output, result[0].css);
25+
})
26+
.catch((err) => {
27+
console.error('Error during PurgeCSS process:', err);
28+
});
29+
}
30+
31+
main();

docs/rollup.config.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import babel from '@rollup/plugin-babel';
2+
import terser from '@rollup/plugin-terser';
3+
import { nodeResolve } from '@rollup/plugin-node-resolve';
4+
import fs from 'fs';
5+
import pkg from './package.json';
6+
7+
const SRC_DEFAULT = '_javascript';
8+
const SRC_PWA = `${SRC_DEFAULT}/pwa`;
9+
const DIST = 'assets/js/dist';
10+
11+
const banner = `/*!
12+
* ${pkg.name} v${pkg.version} | © ${pkg.since} ${pkg.author} | ${pkg.license} Licensed | ${pkg.homepage}
13+
*/`;
14+
const frontmatter = '---\npermalink: /:basename\n---\n';
15+
const isProd = process.env.BUILD === 'production';
16+
17+
let hasWatched = false;
18+
19+
function cleanup() {
20+
fs.rmSync(DIST, { recursive: true, force: true });
21+
console.log(`> Directory "${DIST}" has been cleaned.`);
22+
}
23+
24+
function insertFrontmatter() {
25+
return {
26+
name: 'insert-frontmatter',
27+
generateBundle(_, bundle) {
28+
for (const chunkOrAsset of Object.values(bundle)) {
29+
if (chunkOrAsset.type === 'chunk') {
30+
chunkOrAsset.code = frontmatter + chunkOrAsset.code;
31+
}
32+
}
33+
}
34+
};
35+
}
36+
37+
function build(
38+
filename,
39+
{ src = SRC_DEFAULT, jekyll = false, outputName = null } = {}
40+
) {
41+
const input = `${src}/${filename}.js`;
42+
const shouldWatch = hasWatched ? false : true;
43+
44+
if (!hasWatched) {
45+
hasWatched = true;
46+
}
47+
48+
return {
49+
input,
50+
output: {
51+
file: `${DIST}/${filename}.min.js`,
52+
format: 'iife',
53+
...(outputName !== null && { name: outputName }),
54+
banner,
55+
sourcemap: !isProd && !jekyll
56+
},
57+
...(shouldWatch && { watch: { include: `${SRC_DEFAULT}/**/*.js` } }),
58+
plugins: [
59+
babel({
60+
babelHelpers: 'bundled',
61+
presets: ['@babel/env'],
62+
plugins: [
63+
'@babel/plugin-transform-class-properties',
64+
'@babel/plugin-transform-private-methods'
65+
]
66+
}),
67+
nodeResolve(),
68+
isProd && terser(),
69+
jekyll && insertFrontmatter()
70+
]
71+
};
72+
}
73+
74+
cleanup();
75+
76+
export default [
77+
build('commons'),
78+
build('home'),
79+
build('categories'),
80+
build('page'),
81+
build('post'),
82+
build('misc'),
83+
build('theme', { outputName: 'Theme' }),
84+
build('app', { src: SRC_PWA, jekyll: true }),
85+
build('sw', { src: SRC_PWA, jekyll: true })
86+
];

0 commit comments

Comments
 (0)