diff options
| author | Dave Tang <davetingpongtang@gmail.com> | 2026-06-23 15:23:59 +0900 |
|---|---|---|
| committer | Dave Tang <davetingpongtang@gmail.com> | 2026-06-23 15:23:59 +0900 |
| commit | 0c3d06d3f2a7caf6640d83db361f6de444d717dc (patch) | |
| tree | 16e5b833f7b398270dc6bdc1e9b88c4cfcf7e0e0 /scripts | |
| parent | e28c074e15dd093f3acd7a3cce10afae149003cd (diff) | |
Copy-to-Clipboard Button
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/setup.sh | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/setup.sh b/scripts/setup.sh index d3d188e..ab24775 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -3,10 +3,11 @@ # # Run this script from your Apache document root: # cd /path/to/docroot -# bash setup-docsify.sh [--with-prism] +# bash setup-docsify.sh [--with-prism] [--with-copy-code] # # Options: -# --with-prism Also download Prism and enable syntax highlighting in index.html +# --with-prism Also download Prism and enable syntax highlighting in index.html +# --with-copy-code Also download the docsify-copy-code plugin (copy button on code blocks) set -euo pipefail @@ -14,11 +15,13 @@ set -euo pipefail # Use "4" for the latest 4.x release, or pin to a specific version e.g. "4.13.1" DOCSIFY_VERSION="4" PRISM=false +COPY_CODE=false # ── Argument parsing ──────────────────────────────────────────────────────────── for arg in "$@"; do case "$arg" in --with-prism) PRISM=true ;; + --with-copy-code) COPY_CODE=true ;; *) echo "Unknown option: $arg" >&2; exit 1 ;; esac done @@ -81,6 +84,12 @@ if [[ "$PRISM" == true ]]; then fetch "${CDN}/prismjs@1/components/prism-javascript.min.js" assets/js/prism-javascript.min.js fi +if [[ "$COPY_CODE" == true ]]; then + echo "" + echo " Downloading copy-to-clipboard plugin..." + fetch "${CDN}/docsify-copy-code@3/dist/docsify-copy-code.min.js" assets/js/docsify-copy-code.min.js +fi + # ── Step 3: index.html ────────────────────────────────────────────────────────── step "Step 3 — Creating index.html" @@ -112,6 +121,14 @@ step "Step 3 — Creating index.html" <script src="assets/js/search.min.js"></script> HTML_HEAD + if [[ "$COPY_CODE" == true ]]; then + cat << 'HTML_COPYCODE' + + <!-- Copy-to-clipboard button for code blocks --> + <script src="assets/js/docsify-copy-code.min.js"></script> +HTML_COPYCODE + fi + if [[ "$PRISM" == true ]]; then cat << 'HTML_PRISM' @@ -191,3 +208,8 @@ if [[ "$PRISM" == true ]]; then echo -e "To add more languages, download additional prism-*.min.js files" echo -e "into assets/js/ and add their <script> tags to index.html." fi + +if [[ "$COPY_CODE" == true ]]; then + echo "" + echo -e "Copy-to-clipboard buttons are enabled on all code blocks." +fi |
