-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_config.ts
73 lines (63 loc) · 2.05 KB
/
_config.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
import imagick from "lume/plugins/imagick.ts";
import lume from "lume/mod.ts";
import base_path from "lume/plugins/base_path.ts";
import date from "lume/plugins/date.ts";
import metas from "lume/plugins/metas.ts";
import netlify_cms from "lume/plugins/netlify_cms.ts";
import pagefind from "lume/plugins/pagefind.ts";
import postcss from "lume/plugins/postcss.ts";
import sitemap from "lume/plugins/sitemap.ts";
import svgo from "lume/plugins/svgo.ts";
import footnote from "npm:markdown-it-footnote";
// PostCSS Plugins
import cssnano from "npm:cssnano@^5";
import { Page, SiteEvent } from "https://deno.land/x/[email protected]/core.ts";
const markdown = {
plugins: [footnote],
};
const search = { returnPageData: true };
const site = lume({
src: "./src",
location: new URL("https://weeknotes.open-innovations.org"),
}, { markdown, search });
site.filter('removeNunjucks', (value) => { return value.replace(/\{\{ ?.*? ?\}\} ?/g,""); });
site.use(base_path());
site.use(metas());
site.use(date());
if (Deno.env.get("ENABLE_NETLIFY") !== undefined) site.use(netlify_cms());
site.use(pagefind());
site.use(postcss({
plugins: [
cssnano({ preset: "default" }),
],
keepDefaultPlugins: true,
}));
site.use(sitemap());
site.use(imagick());
site.use(svgo());
["CNAME", ".nojekyll"].forEach((f) => site.copy(f));
/**
* Before the render happens, work out the most recent weeknote,
* then store the description in latest description for all pages
*/
site.preprocessAll([".html"], (pages) => {
const latestPage = pages.filter((page) =>
page.data.tags?.includes("weeknote") &&
page.data.draft !== true
)
.sort((a, b) => a.data.week_ending > b.data.week_ending ? 1 : -1)
.pop();
if (!latestPage) return;
pages.forEach((page) =>
page.data.latestDescription = latestPage.data.description
);
});
site.addEventListener("beforeBuild", () => {
console.log("The build is about to start");
console.time("dataLoad");
});
site.addEventListener("beforeRender", () => {
console.timeEnd("dataLoad");
console.log("All pages and data loaded");
})
export default site;