166 lines
5.1 KiB
Bash
Executable File
166 lines
5.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
echo "Starting Quartz Wiki..."
|
|
|
|
# Check if content directory has files
|
|
if [ -z "$(ls -A /app/content 2>/dev/null)" ]; then
|
|
echo "Warning: Content directory is empty!"
|
|
# Create a default index page
|
|
mkdir -p /app/content
|
|
echo "# Wiki Home
|
|
|
|
Willkommen im doing-it Wiki!
|
|
|
|
Dieses Wiki wird mit Obsidian Quartz betrieben.
|
|
" > /app/content/index.md
|
|
fi
|
|
|
|
# Copy content to Quartz content directory
|
|
echo "Copying vault content to Quartz..."
|
|
mkdir -p /app/quartz-repo/content
|
|
cp -r /app/content/* /app/quartz-repo/content/ 2>/dev/null || true
|
|
|
|
# Build Quartz
|
|
echo "Building Quartz site..."
|
|
cd /app/quartz-repo
|
|
|
|
# Check if Quartz CLI exists and try different methods
|
|
QUARTZ_CLI="/app/quartz-repo/node_modules/@jackyzha0/quartz/cli/index.js"
|
|
QUARTZ_BUILD_SUCCESS=false
|
|
|
|
# Method 1: Direct node call to Quartz CLI (avoids npx BusyBox issue)
|
|
if [ -f "$QUARTZ_CLI" ]; then
|
|
echo "Trying direct node call to Quartz CLI..."
|
|
if node "$QUARTZ_CLI" build --contentDir ./content --outputDir /app/public 2>&1; then
|
|
QUARTZ_BUILD_SUCCESS=true
|
|
echo "Quartz build successful!"
|
|
fi
|
|
fi
|
|
|
|
# Method 2: Try using npm run script
|
|
if [ "$QUARTZ_BUILD_SUCCESS" = false ] && [ -f "package.json" ]; then
|
|
echo "Trying npm run build..."
|
|
if npm run build 2>&1; then
|
|
QUARTZ_BUILD_SUCCESS=true
|
|
echo "Quartz build successful via npm!"
|
|
# Copy output if it went to default location
|
|
if [ -d "./public" ] && [ -n "$(ls -A ./public 2>/dev/null)" ]; then
|
|
cp -r ./public/* /app/public/ 2>/dev/null || true
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# If Quartz build succeeded, copy output
|
|
if [ "$QUARTZ_BUILD_SUCCESS" = true ]; then
|
|
if [ -d "/app/quartz-repo/public" ] && [ -n "$(ls -A /app/quartz-repo/public 2>/dev/null)" ]; then
|
|
echo "Copying Quartz output to public directory..."
|
|
cp -r /app/quartz-repo/public/* /app/public/ 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
# If build failed, create fallback static site
|
|
if [ "$QUARTZ_BUILD_SUCCESS" = false ]; then
|
|
echo "Quartz build failed, creating fallback static site..."
|
|
mkdir -p /app/public
|
|
cd /app/content
|
|
|
|
# Create index.html
|
|
cat > /app/public/index.html << 'EOFHTML'
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>doing-it Wiki</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
|
|
background: #161618;
|
|
color: #ebebec;
|
|
line-height: 1.6;
|
|
padding: 40px 20px;
|
|
}
|
|
.container {
|
|
max-width: 900px;
|
|
margin: 0 auto;
|
|
}
|
|
h1 {
|
|
font-size: 48px;
|
|
font-weight: 600;
|
|
margin-bottom: 20px;
|
|
color: #ebebec;
|
|
}
|
|
h2 {
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
margin: 40px 0 20px;
|
|
color: #ebebec;
|
|
}
|
|
ul {
|
|
list-style: none;
|
|
padding: 0;
|
|
}
|
|
li {
|
|
margin: 15px 0;
|
|
}
|
|
a {
|
|
color: #ff3b30;
|
|
text-decoration: none;
|
|
font-size: 18px;
|
|
transition: color 0.3s;
|
|
display: inline-block;
|
|
}
|
|
a:hover {
|
|
color: #ff453a;
|
|
}
|
|
.intro {
|
|
font-size: 20px;
|
|
color: #d4d4d4;
|
|
margin-bottom: 40px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>doing-it Wiki</h1>
|
|
<p class="intro">Willkommen im doing-it Wiki! Hier finden Sie nützliche Informationen rund um IT-Weiterbildung und Schulungen.</p>
|
|
<h2>Inhalte</h2>
|
|
<ul id="content-list">
|
|
EOFHTML
|
|
|
|
# Find all markdown files and create links
|
|
if [ -n "$(find /app/content -name "*.md" -type f 2>/dev/null)" ]; then
|
|
find /app/content -name "*.md" -type f | while read file; do
|
|
title=$(basename "$file" .md)
|
|
relative_path=$(echo "$file" | sed "s|/app/content/||")
|
|
echo " <li><a href=\"/$relative_path\">$title</a></li>" >> /app/public/index.html
|
|
done
|
|
else
|
|
echo " <li><em>Keine Inhalte gefunden</em></li>" >> /app/public/index.html
|
|
fi
|
|
|
|
echo " </ul>" >> /app/public/index.html
|
|
echo " </div>" >> /app/public/index.html
|
|
echo "</body>" >> /app/public/index.html
|
|
echo "</html>" >> /app/public/index.html
|
|
|
|
# Copy markdown files to public
|
|
cp -r /app/content/* /app/public/ 2>/dev/null || true
|
|
fi
|
|
|
|
# Ensure public directory exists
|
|
if [ ! -d "/app/public" ] || [ -z "$(ls -A /app/public 2>/dev/null)" ]; then
|
|
echo "Error: Public directory is empty, creating minimal site..."
|
|
mkdir -p /app/public
|
|
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>doing-it Wiki</title></head><body><h1>doing-it Wiki</h1><p>Wiki wird geladen...</p></body></html>" > /app/public/index.html
|
|
fi
|
|
|
|
echo "Build complete. Starting server on port 8080..."
|
|
cd /app
|
|
serve -s public -l 8080
|