forked from mulder-jamstack/mulder-jamstack.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscully.mulder.config.ts
78 lines (73 loc) · 2.33 KB
/
scully.mulder.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
74
75
76
77
78
import {
HandledRoute,
logWarn,
registerPlugin,
routeSplit,
ScullyConfig,
setPluginConfig,
} from "@scullyio/scully";
import "prismjs/components/prism-java.js";
import "prismjs/components/prism-visual-basic.js";
import "prismjs/components/prism-yaml.js";
import { getTocPlugin, TocConfig } from "./scully/plugins/toc";
const _posts = require("./src/dynamicRoutes.json");
function dynamicMDRoutingPlugin(
route?: string,
_config = {}
): Promise<HandledRoute[]> {
const { createPath } = routeSplit(route as string);
const l: HandledRoute[] = [];
_posts
.filter((el: any) => {
const r = el.path?.split("/");
const r1 = r?.splice(2);
const computedroute = createPath(...(r1 as string[]));
return computedroute === el.path;
})
.forEach((el: any) => {
l.push({
route: el.path
});
});
logWarn(l);
return Promise.resolve(l);
}
const validator = async (_conf: any) => [];
registerPlugin("router", "dynamicMD", dynamicMDRoutingPlugin, validator);
setPluginConfig("md", { enableSyntaxHighlighting: true });
const tocOptions: TocConfig = {
blogAreaSelector: "#blog-content", // where to search for TOC headings
insertSelector: "#toc", // where to insert the TOC
level: ["h1", "h2", "h3", "h4"], // what heading levels to include
trailingSlash: true, // add trailing slash before the anker ('#')
scrollIntoViewOnClick: true, // add event to each link that scrolls into view on click:
// onclick="document.getElementById('target-id').scrollIntoView()"
};
const TocPlugin = getTocPlugin();
setPluginConfig(TocPlugin, tocOptions);
export const config: ScullyConfig = {
projectRoot: "./src",
projectName: "mulder",
outDir: "./dist/static",
routes: {
// tslint:disable-next-line:prettier
'/d/:cat/:slug': {
type: "dynamicMD",
},
// tslint:disable-next-line:prettier
'/s/:slug': {
type: "contentFolder",
postRenderers: ["toc"],
slug: {
folder: "./content/static",
},
},
"/blog/:slug": {
type: "contentFolder",
postRenderers: ["toc"],
slug: {
folder: "./content/blog",
},
},
},
};