-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.html.ts
More file actions
38 lines (32 loc) · 840 Bytes
/
Copy pathblock.html.ts
File metadata and controls
38 lines (32 loc) · 840 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
35
36
37
38
import { brightMagenta } from "./deps.ts"
import { _replace } from "./shared.ts"
import { presets } from "./templates/tailwind.ts"
import {
block_exist,
create_block_file,
create_dir,
insert_content,
stdOut,
} from "./actions.ts"
export const fns = {
create_dir,
create_block_file,
insert_content,
block_exist,
stdOut,
}
// eslint-disable-next-line max-lines-per-function
export function create_html_block(name: string, insert = true) {
const { templates: t } = presets["tailwind"]
fns.create_dir("blocks")
if (fns.block_exist(name)) {
fns.stdOut(brightMagenta("Already Created Block: " + name))
return
}
fns.create_block_file(
`blocks/${name}.html`,
_replace(t, "html.view", { name }),
)
if (!insert) return
fns.insert_content(`{% include "blocks/${name}.html" %}`, "index.html")
}