Skip to content

Commit 2e34dbc

Browse files
committed
feat: Add adapt-website script
1 parent 8d5adda commit 2e34dbc

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"scripts": {
66
"dev": "astro dev",
77
"dev:docs": "cd docs/ && retype watch",
8-
"build": "astro build",
8+
"build": "yarn clean && astro build",
9+
"build:adapt": "./scripts/adapt-website",
910
"build:docs": "cd docs/ && yarn build",
10-
"build:all": "yarn clean && yarn build && yarn build-docs && ./scripts/setup-docs.sh",
11+
"build:all": "yarn build && yarn build-docs && ./scripts/setup-docs.sh && yarn build:adapt",
1112
"clean": "rm -rf ./build"
1213
},
1314
"devDependencies": {

scripts/adapt-website.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
# Website and Docs adaptation
4+
5+
echo "${cyan}[$0] ${green}Starting website/docs adaptation..."
6+
echo
7+
8+
echo "${cyan}[$0] ${green}Removing '.nojekyll' file"
9+
rm -rf ./build/docs/.nojekyll
10+
11+
## Try to unzip and modify the 'sitemap.xml.gz' file.
12+
if ! type gunzip; then
13+
## If command 'gunzip' don't exist. Just remove the file.
14+
echo "${cyan}[$0] ${green}<gunzip> command not found! Removing 'sitemap.xml.gz' file"
15+
rm -rf ./build/docs/sitemap.xml.gz
16+
else
17+
echo "${cyan}[$0] ${green}Unzipping 'sitemap.xml.gz' file"
18+
gunzip ./build/docs/sitemap.xml.gz
19+
echo "${cyan}[$0] ${green}Replacing '.id/' with '.id/docs/'"
20+
echo "${cyan}[$0] ${green}Moving 'sitemap.xml.gz' file to './build/sitemap-1.xml'"
21+
sed 's#.id/#.id/docs/#' ./build/docs/sitemap.xml > ./build/sitemap-1.xml
22+
23+
echo "${cyan}[$0] ${green}Adding 'https://hawapi.theproject.id/sitemap-1.xml' to './build/docs/robots.txt'"
24+
echo 'Sitemap: https://hawapi.theproject.id/sitemap-1.xml' >> ./build/docs/robots.txt
25+
fi
26+
27+
echo "${cyan}[$0] ${green}Moving 'robots.txt' to './build/robots.txt'"
28+
sed 's/sitemap.xml.gz/sitemap-0.xml/' ./build/docs/robots.txt > ./build/robots.txt
29+
rm -rf ./build/docs/robots.txt
30+
rm -rf ./build/sitemap-index.xml

0 commit comments

Comments
 (0)