-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
41 lines (38 loc) · 1.25 KB
/
mod.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
import { Publish } from "./lib/publish.ts";
import { Options } from "./lib/interfaces.ts";
import { merge, Site } from "./deps.ts";
const defaults: Options = {
extensions: [".md"],
publish: {
enable: Deno.env.get("PUBLISH") || "false",
platforms: {
twitter: {
api_key: Deno.env.get("TWITTER_API_KEY") || "",
api_key_secret: Deno.env.get("TWITTER_API_KEY_SECRET") || "",
access_token: Deno.env.get("TWITTER_ACCESS_TOKEN") || "",
access_token_secret: Deno.env.get("TWITTER_ACCESS_TOKEN_SECRET") || "",
},
telegram: {
channel_id: Deno.env.get("TELEGRAM_CHANNEL_ID") || "",
bot_api_key: Deno.env.get("TELEGRAM_BOT_API_KEY") || "",
},
},
vcs: {
github: {
token: Deno.env.get("GITHUB_TOKEN") || "",
repository: Deno.env.get("GITHUB_REPOSITORY") || "",
},
},
},
};
export function publish(userOptions?: Partial<Options>) {
const options = merge(defaults, userOptions);
return (site: Site) => {
const doPublish = options.publish.enable == "true";
if (doPublish) {
const publish = new Publish(options, site);
site.preprocess(options.extensions, publish.publish());
site.process(options.extensions, publish.publishCopy());
}
};
}