-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
utils.ts
61 lines (54 loc) 路 1.32 KB
/
utils.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
import lume from "../mod.ts";
import { toFileUrl } from "../deps/path.ts";
import { dim, red } from "../deps/colors.ts";
import { getConfigFile } from "../core/utils.ts";
import type { Site } from "../core.ts";
/** Create a site instance */
export async function createSite(root: string, config?: string): Promise<Site> {
const path = await getConfigFile(root, config);
if (path) {
console.log(`Loading config file ${dim(path)}`);
console.log();
const mod = await import(toFileUrl(path).href);
return mod.default;
}
return lume();
}
/** A list of the available optional plugins */
export const pluginNames = [
"attributes",
"base_path",
"code_highlight",
"date",
"esbuild",
"eta",
"imagick",
"inline",
"jsx",
"liquid",
"metas",
"modify_urls",
"netlify_cms",
"on_demand",
"parcel_css",
"postcss",
"prism",
"pug",
"relative_urls",
"resolve_urls",
"sass",
"slugify_urls",
"svgo",
"terser",
];
export function log(...lines: (string | undefined)[]) {
console.log("----------------------------------------");
lines.forEach((line) => line && console.log(line));
console.log("----------------------------------------");
}
export function promptConfigUpdate(data: unknown) {
log(
red("deno.jsonc needs to be manually updated:"),
JSON.stringify(data, null, 2),
);
}