-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-docs.sh
executable file
·51 lines (40 loc) · 1.44 KB
/
build-docs.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
47
48
49
50
51
#!/bin/bash
# Build the component manifest file (lists all components with demo directories)
# Write a HTML file that redirects users from fetch.dogecoin.org/<component> to <component>/demo
DIST_COMPONENTS_BASE_DIR="dist"
# Find all component demo directories.
DEMO_DIRS=$(find src/components -type d -name "demo")
for demo_dir in $DEMO_DIRS
do
# Get the parent directory of the demo, which is the component directory
component_dir="$(dirname "$demo_dir")"
# Get the basename of the component directory
component_dirname=$(basename "$component_dir")
echo "DEMO Dir: $component_dirname"
# Define the filename for the component's index.html in the dist directory
filename="${DIST_COMPONENTS_BASE_DIR}/${component_dirname}/index.html"
# Write the HTML content to the file
cat << 'EOF' > "$filename"
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
if (!window.location.pathname.endsWith('/demo/')) {
window.location.href = window.location.pathname + '/demo/';
}
</script>
</head>
<body>
<!-- Content here -->
</body>
</html>
EOF
# Append component name to COMPONENTS_JSON
COMPONENTS_JSON+="\"$component_dirname\": {},"
done
# Remove trailing comma from COMPONENTS_JSON
COMPONENTS_JSON=${COMPONENTS_JSON%,}
# Create the final JSON object
COMPONENTS_JSON="{\"components\": {$COMPONENTS_JSON}}"
# Write the JSON object to manifest.json
echo "$COMPONENTS_JSON" > "${DIST_COMPONENTS_BASE_DIR}/manifest.json"