forked from cfug/flutter.cn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
move_docs.sh
executable file
·47 lines (39 loc) · 1.23 KB
/
move_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
#!/usr/bin/bash
DOCS=src/docs
if [ -d "$DOCS" ]; then
echo "$DOCS already exist, Skip moving."
exit 0
fi
if [ -f "$DOCS" ]; then
echo "$DOCS already exist, Skip moving."
exit 0
fi
cd src
mkdir docs
# Move all directories to /docs.
for folder in */; do
if [[ $folder != "docs/" && $folder != _* ]]; then
echo "Moving folder $folder to docs/$folder..."
mv "$folder" docs/
fi
done
# Move all markdown files to /docs.
mv ./*.md docs/
# Move out CN site directories.
mv docs/about ./
mv docs/community ./
mv docs/posts ./
# Move out CN site files.
mv docs/disclaimer.md ./
# Make a copy of assets.
rm docs/assets/images/shared/brand
rm docs/assets/js/vendor
cp -r docs/assets ./
ln -s ../../../../site-shared/src/_assets/image assets/images/shared/brand
ln -s ../../../site-shared/src/_assets/vendor assets/js/vendor
ln -s ../../../../../site-shared/src/_assets/image docs/assets/images/shared/brand
ln -s ../../../../site-shared/src/_assets/vendor docs/assets/js/vendor
cd ..
# Replace `site.url` to `site.main-url` in shared files.
# Note: The below `sed` command can only run successfully on Linux. Add `''` between `-i` and `'s` on macOS.
find site-shared -type f -not -path '*/\.*' -exec sed -i 's|site.url|site.main-url|g' {} \;