mirror of
https://codeberg.org/forgejo/docs.git
synced 2024-11-21 17:36:59 -05:00
tooling: add live preview script
This commit is contained in:
parent
a3c639ff49
commit
1de27e8949
4 changed files with 44 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
node_modules
|
node_modules
|
||||||
|
.preview
|
||||||
|
|
|
@ -57,6 +57,13 @@ website will not be available.
|
||||||
If a commit is meant to be backported to a stable branch, it must be
|
If a commit is meant to be backported to a stable branch, it must be
|
||||||
labelled with `backport/v1.20`, `backport/v1.19`, etc.
|
labelled with `backport/v1.20`, `backport/v1.19`, etc.
|
||||||
|
|
||||||
|
### Previewing changes
|
||||||
|
|
||||||
|
Run `pnpm run preview` to clone the [website repo](https://codeberg.org/forgejo/forgejo)
|
||||||
|
and launch a local development server. The current docs branch will be opened in the browser.
|
||||||
|
|
||||||
|
Modifications can be made to the docs while the dev server is running, and the preview will live-reload.
|
||||||
|
|
||||||
### Links
|
### Links
|
||||||
|
|
||||||
All internal links within the documentation content should be relative to each page's path
|
All internal links within the documentation content should be relative to each page's path
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"license": "CC-BY-SA-4.0",
|
"license": "CC-BY-SA-4.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"preview": "./scripts/preview.sh",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"lint:remark": "remark . --quiet --frail",
|
"lint:remark": "remark . --quiet --frail",
|
||||||
"lint:prettier": "prettier --check .",
|
"lint:prettier": "prettier --check .",
|
||||||
|
|
35
scripts/preview.sh
Executable file
35
scripts/preview.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/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
|
||||||
|
sleep 3 && open http://localhost:3000/docs/$current_branch/ &
|
||||||
|
|
||||||
|
# start the dev server
|
||||||
|
pnpm run dev
|
Loading…
Reference in a new issue