forked from classvsoftware/example-chrome-extension
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-component.sh
46 lines (33 loc) · 1.07 KB
/
generate-component.sh
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
set -e
if [ -z "$1" ]
then
echo "Provide a name"
exit 1
fi
# TARGET="<!-- DBX_TARGET -->"
# HEADERTPL="<li><a class=\"dropdown-item\" href=\"\/components\/$1\/$1.html\"><div>$1<\/div><small class=\"text-gray-500\">$1<\/small><\/a><\/li>$TARGET"
# sed -i "s/$TARGET/$HEADERTPL/" components/header/header.html
sed -i "" "s/]/{\"id\":\"$1\",\"title\":\"$1\",\"subtitle\":\"$1\",\"description\":\"$1\",\"showInDropdown\":true},]/" pages.js
mkdir components/$1
cat <<EOF >components/$1/$1.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="/scripts/vendor/shared.js"></script>
<link href="/styles/shared.css" rel="stylesheet" />
<link href="$1.css" rel="stylesheet" />
<script src="$1.js" type="module" defer></script>
</head>
<body>
<div id="content"></div>
</body>
</html>
EOF
cat <<EOF >components/$1/$1.css
EOF
cat <<EOF >components/$1/$1.js
import { initializeComponent } from "/scripts/shared.js";
initializeComponent();
EOF