-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugins.ts
More file actions
163 lines (149 loc) · 4.78 KB
/
Copy pathplugins.ts
File metadata and controls
163 lines (149 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// lume/core
import { merge } from "lume/core/utils/object.ts";
// lume/plugins
import basePath from "lume/plugins/base_path.ts";
import date, { Options as DateOptions } from "lume/plugins/date.ts";
import extractDate from "lume/plugins/extract_date.ts";
import favicon, { Options as FaviconOptions } from "lume/plugins/favicon.ts";
import feed, { Options as FeedOptions } from "lume/plugins/feed.ts";
import googleFonts from "lume/plugins/google_fonts.ts";
import metas from "lume/plugins/metas.ts";
import pagefind, { Options as PagefindOptions } from "lume/plugins/pagefind.ts";
import postcss from "lume/plugins/postcss.ts";
import prism, { Options as PrismOptions } from "lume/plugins/prism.ts";
import readingInfo from "lume/plugins/reading_info.ts";
import resolveUrls from "lume/plugins/resolve_urls.ts";
import sitemap from "lume/plugins/sitemap.ts";
import slugifyUrls from "lume/plugins/slugify_urls.ts";
/* Simple Blog uses Terser for comments JS we skip here, but may want for
rainbow mode JS when that lands, .use() commented out below as well */
// import terser from "lume/plugins/terser.ts";
// lumeland/markdown-plugins
import footnotes from "lume/markdown-plugins/footnotes.ts";
import image from "lume/markdown-plugins/image.ts";
import toc from "lume/markdown-plugins/toc.ts";
// https://github.com/mdit-plugins/mdit-plugins
// docs https://mdit-plugins.github.io/alert.html
import { alert } from "mdit/plugin-alert";
import "lume/types.ts";
export interface Options {
colors?: {
hue?: number;
complement?: number;
analogous?: number;
sathi?: number;
satmid?: number;
satlo?: number;
xlight?: number;
lighter?: number;
lightness?: number;
midrange?: number;
lowmid?: number;
darkness?: number;
darker?: number;
};
date?: Partial<DateOptions>;
favicon?: Partial<FaviconOptions>;
feed?: Partial<FeedOptions>;
fonts?: {
display?: string;
text?: string;
};
pagefind?: Partial<PagefindOptions>;
prism?: Partial<PrismOptions>;
}
export const defaults: Options = {
colors: {
/*
HSL hues
In CSS, an `<angle>` is periodic, `<hue>` is normalized to the range
[0deg, 360deg). It implicitly wraps around such that 480deg is the same
as 120deg, -120deg is the same as 240deg, -1turn is the same as 1turn,
and so on. Yet here we pass a number
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html
1-359 for each of the 3 hue values, to get simple type inference
https://www.typescriptlang.org/docs/handbook/type-inference.html
*/
hue: 172,
complement: 351,
analogous: 38,
// color mixing values
sathi: 94, // 80-100
satmid: 54, // 50-70
satlo: 20, // 10-30
xlight: 92, // 84-92
lighter: 83, // 76-84
lightness: 65, // 64-72
midrange: 54, // 48-64
lowmid: 36, // 28-36
darkness: 20, // 16-24
darker: 9, // 0-12
},
feed: {
output: ["/feed.xml", "/feed.json"],
query: "type=post",
info: {
title: "=metas.site",
description: "=metas.description",
},
items: {
title: "=title",
},
},
fonts: {
display: "https://fonts.google.com/share?selection.family=Bebas+Neue",
text:
"https://fonts.google.com/share?selection.family=Lexend:wght@100..900",
},
};
/** Configure the site */
export default function (userOptions?: Options) {
const options = merge(defaults, userOptions);
return (site: Lume.Site) => {
site.data("colorscheme", options.colors);
// .use(terser())
site.use(googleFonts({
cssFile: "styles.css",
placeholder: "/* google-fonts */",
fonts: options.fonts,
}))
.use(postcss())
.use(basePath())
.use(toc())
.use(prism(options.prism))
.use(readingInfo())
.use(date(options.date))
.use(slugifyUrls())
.use(metas())
.use(image())
.use(footnotes())
.use(resolveUrls())
.use(pagefind(options.pagefind))
.use(sitemap())
.use(feed(options.feed))
.use(extractDate())
.use(favicon(options.favicon))
.ignore("README.md")
.ignore("LICENSE.md")
.add("fonts")
.add([".css"])
.add("js")
.add("logo.svg")
.add("uploads")
.mergeKey("extra_head", "stringArray")
.preprocess([".md"], (pages) => {
for (const page of pages) {
if (!page.data.title) {
page.data.title = page.data.basename
.replaceAll(/-(?!\d)/g, ` `) // remove hyphens unless followed by 0-9
.replace(/\b\w/, (char) => char.toUpperCase()); // sentence case
} // for title case use /\b\w/g
page.data.excerpt ??= (page.data.content as string).split(
/<!--\s*more\s*-->/i,
)[0];
}
});
// Alert plugin
site.hooks.addMarkdownItPlugin(alert);
};
}