-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.ts
76 lines (70 loc) · 2.34 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
import date 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 from "lume/plugins/pagefind.ts";
import sitemap from "lume/plugins/sitemap.ts";
import feed from "lume/plugins/feed.ts";
import readingInfo from "https://deno.land/x/[email protected]/plugins/reading_info.ts";
import toc from "https://deno.land/x/[email protected]/toc.ts";
import image from "https://deno.land/x/[email protected]/image.ts";
import nunjucks from "lume/plugins/nunjucks.ts";
import esbuild from "lume/plugins/esbuild.ts";
import type { Site } from "lume/core.ts";
import type { CustomPage } from "src/types/core.ts";
export interface Options {
prism?: Partial<PrismOptions>;
}
/** Configure the site */
export default function (options: Options = {}) {
const createPagesExcerptDetail = (pages: [CustomPage]) => {
pages.forEach(page =>{
const attemptedSplit = (page.data.content as string).split(
/<!--\s*more\s*-->/i,
);
const isExcerptTruncated = attemptedSplit.length > 1;
page.data.excerpt = attemptedSplit[0];
page.data.isExcerptTruncated = isExcerptTruncated;
})
}
return (site: Site) => {
site.use(postcss())
.use(basePath())
.use(toc())
.use(prism(options.prism))
.use(readingInfo())
.use(date())
.use(metas())
.use(nunjucks())
.use(esbuild())
.use(image())
.use(resolveUrls())
.use(slugifyUrls())
.use(pagefind())
.use(terser())
.use(sitemap())
.use(feed({
output: ["/feed.xml", "/feed.json"],
query: "type=post",
info: {
title: "=metas.site",
description: "=metas.description",
},
items: {
title: "=title",
},
}))
.copy("fonts")
.copy([".jpg", ".jpeg", ".png", ".svg", ".pdf", ".gif"])
.preprocess([".md"], createPagesExcerptDetail);
// Basic CSS Design System
site.remoteFile(
"_includes/css/ds.css",
"https://unpkg.com/@lumeland/ds/ds.css",
);
};
}