forked from lumeland/theme-simple-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.ts
84 lines (77 loc) · 2.54 KB
/
plugins.ts
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
import date, { Options as DateOptions } from "lume/plugins/date.ts";
import postcss from "lume/plugins/postcss.ts";
import terser from "lume/plugins/terser.ts";
import prism, { Options as PrismOptions } from "lume/plugins/prism.ts";
import basePath from "lume/plugins/base_path.ts";
import slugifyUrls from "lume/plugins/slugify_urls.ts";
import resolveUrls from "lume/plugins/resolve_urls.ts";
import metas from "lume/plugins/metas.ts";
import pagefind, { Options as PagefindOptions } from "lume/plugins/pagefind.ts";
import sitemap from "lume/plugins/sitemap.ts";
import feed, { Options as FeedOptions } from "lume/plugins/feed.ts";
import readingInfo from "lume/plugins/reading_info.ts";
import { merge } from "lume/core/utils/object.ts";
import toc from "https://deno.land/x/[email protected]/toc.ts";
import image from "https://deno.land/x/[email protected]/image.ts";
import footnotes from "https://deno.land/x/[email protected]/footnotes.ts";
import { alert } from "npm:@mdit/[email protected]";
import "lume/types.ts";
export interface Options {
prism?: Partial<PrismOptions>;
date?: Partial<DateOptions>;
pagefind?: Partial<PagefindOptions>;
feed?: Partial<FeedOptions>;
}
export const defaults: Options = {
feed: {
output: ["/feed.xml", "/feed.json"],
query: "type=post",
info: {
title: "=metas.site",
description: "=metas.description",
},
items: {
title: "=title",
},
},
};
/** Configure the site */
export default function (userOptions?: Options) {
const options = merge(defaults, userOptions);
return (site: Lume.Site) => {
site.use(postcss())
.use(basePath())
.use(toc())
.use(prism(options.prism))
.use(readingInfo())
.use(date(options.date))
.use(metas())
.use(image())
.use(footnotes())
.use(resolveUrls())
.use(slugifyUrls())
.use(terser())
.use(pagefind(options.pagefind))
.use(sitemap())
.use(feed(options.feed))
.copy("fonts")
.copy("js")
.copy("favicon.png")
.copy("uploads")
.mergeKey("extra_head", "stringArray")
.preprocess([".md"], (pages) => {
for (const page of pages) {
page.data.excerpt ??= (page.data.content as string).split(
/<!--\s*more\s*-->/i,
)[0];
}
});
// Alert plugin
site.hooks.addMarkdownItPlugin(alert);
// Mastodon comment system
site.remoteFile(
"/js/comments.js",
"https://unpkg.com/@oom/[email protected]/src/comments.js",
);
};
}