-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
34 lines (30 loc) · 980 Bytes
/
Copy pathindex.ts
File metadata and controls
34 lines (30 loc) · 980 Bytes
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
import { Plugin } from "$fresh/server.ts";
import { PluginRenderContext } from "$fresh/src/server/types.ts";
export type FlowbitePluginOptions = {
additionalStylesheets?: string[];
additionalScripts?: string[];
plugins?: {
datepicker?: boolean;
};
};
export function FlowbitePlugin(options: FlowbitePluginOptions = {}): Plugin {
if (!options.additionalScripts) options.additionalScripts = [];
if (!options.additionalStylesheets) options.additionalStylesheets = [];
if (!options.plugins) options.plugins = { datepicker: true };
if (options.plugins.datepicker) options.additionalScripts.push("https://unpkg.com/flowbite@1.7.0/dist/datepicker.js");
return {
name: "flowbite",
entrypoints: { "main": import.meta.resolve("./plugin.ts") },
render(ctx: PluginRenderContext) {
ctx.render();
return {
scripts: [
{
entrypoint: "main",
state: options,
},
],
};
},
};
}