build_docs.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env bash
  2. # Build script for VitePress documentation
  3. set -e
  4. echo "================================================"
  5. echo "DDNS Documentation Builder"
  6. echo "Using VitePress (Vue-powered Static Site Generator)"
  7. echo "================================================"
  8. echo ""
  9. # Check if Node.js is installed
  10. if ! command -v node &> /dev/null; then
  11. echo "Error: Node.js is not installed"
  12. echo "Please install Node.js from https://nodejs.org/"
  13. exit 1
  14. fi
  15. echo "Node.js version: $(node --version)"
  16. echo ""
  17. # Check if npm is installed
  18. if ! command -v npm &> /dev/null; then
  19. echo "Error: npm is not installed"
  20. exit 1
  21. fi
  22. echo "npm version: $(npm --version)"
  23. echo ""
  24. # Install dependencies if needed
  25. if [ ! -d "node_modules" ]; then
  26. echo "Installing dependencies..."
  27. npm install
  28. echo ""
  29. fi
  30. # Create docs directory structure
  31. echo "Setting up documentation structure..."
  32. # Create docs directory if it doesn't exist
  33. mkdir -p docs
  34. # Copy README as index
  35. if [ -f "README.md" ]; then
  36. cp README.md docs/index.md
  37. echo "✓ Copied README.md to docs/index.md"
  38. fi
  39. # Copy English README if exists
  40. if [ -f "README.en.md" ]; then
  41. mkdir -p docs/en
  42. cp README.en.md docs/en/index.md
  43. echo "✓ Copied README.en.md to docs/en/index.md"
  44. fi
  45. # Copy doc directory
  46. if [ -d "doc" ]; then
  47. # Copy to root level docs
  48. cp -r doc docs/
  49. echo "✓ Copied doc/ directory"
  50. # For English version, also copy the doc directory
  51. if [ -d "docs/en" ]; then
  52. cp -r doc docs/en/
  53. echo "✓ Copied doc/ to English version"
  54. fi
  55. fi
  56. echo ""
  57. echo "Building documentation website..."
  58. npm run docs:build
  59. echo ""
  60. echo "================================================"
  61. echo "Build complete!"
  62. echo "================================================"
  63. echo ""
  64. echo "Output directory: docs/.vitepress/dist"
  65. echo ""
  66. echo "To preview locally:"
  67. echo " npm run docs:preview"
  68. echo ""
  69. echo "To start development server:"
  70. echo " npm run docs:dev"
  71. echo ""