0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-11-24 18:09:26 -05:00
forgejo-docs/scripts/preview.sh

36 lines
1.1 KiB
Bash
Raw Normal View History

2023-08-19 18:20:00 -04:00
#!/usr/bin/env sh
current_branch=$(git branch --show-current)
repo_path=$(pwd)
# Clone the website repo, or make sure the current clone is up to date
if [ ! -e "./.preview" ];then
git clone https://codeberg.org/forgejo/website.git .preview
cd .preview
else
cd .preview
git checkout main
git pull
fi
# make sure the docs content of the website is up to date
git submodule update --remote
# install the website dependencies
pnpm install
# symlink the current docs branch from the website content repo
rm -rf ./src/content/docs/$current_branch
mkdir -p $(dirname ./src/content/docs/$current_branch) # in case of branch names with slashes
ln -s $repo_path/docs/ ./src/content/docs/$current_branch
rm -rf ./public/images/$current_branch
mkdir -p $(dirname ./src/content/images/$current_branch) # in case of branch names with slashes
ln -s $repo_path/images/ ./public/images/$current_branch
# once the dev server is running, open the current docs branch in the browser
2023-09-05 06:41:09 -04:00
sleep 3 && open http://localhost:4321/docs/$current_branch/ &
2023-08-19 18:20:00 -04:00
# start the dev server
pnpm run dev