Skip to content

Commit 1e4f7a0

Browse files
committed
building...
1 parent f63398e commit 1e4f7a0

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

.github/workflows/marp-pages.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build and Deploy Marp Talks to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '22'
19+
- name: Install Marp CLI
20+
run: npm install -g @marp-team/marp-cli
21+
22+
- name: Build Marp talks
23+
run: ./scripts/marpit.sh
24+
25+
- name: Deploy to GitHub Pages
26+
uses: peaceiris/actions-gh-pages@v4
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./public
30+
publish_branch: gh-pages

scripts/marpit.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
# marpit.sh: Build Marp talks to HTML and generate index
3+
set -e
4+
# Change to the directory where this script is located
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
cd "$SCRIPT_DIR/.."
7+
8+
# Create public directory if not present
9+
mkdir -p public
10+
grep -v '^#' .marp-talks | while IFS= read -r file; do
11+
echo "seen $file"
12+
done
13+
14+
15+
# Build Marp talks to HTML
16+
files=()
17+
while IFS= read -r line; do
18+
files+=("$line")
19+
done < <(grep -v '^#' .marp-talks) # Extract lines to an array
20+
21+
for file in "${files[@]}"; do
22+
file="$(echo "$file" | xargs)" # Trim whitespace at the beginning and end of the line
23+
echo "Processing $file"
24+
[ -z "$file" ] && continue
25+
# Vérification que le fichier existe
26+
if [ ! -f "$file" ]; then
27+
echo "File $file does not exist. Skipping."
28+
continue
29+
fi
30+
# Relative path without extension
31+
relpath="${file%.md}"
32+
# Source directory (where the .md is)
33+
srcdir=$(dirname "$file")
34+
# Target directory in public/
35+
dstdir="public/$srcdir"
36+
mkdir -p "$dstdir"
37+
# Copy all contents from the source directory (files and subdirectories)
38+
if [ -d "$srcdir" ]; then
39+
cp -r "$srcdir"/* "$dstdir"/ 2>/dev/null || true
40+
fi
41+
# Generate the HTML and PDF in the target directory
42+
out_html="$(basename "$file" .md).html"
43+
out_pdf="$(basename "$file" .md).pdf"
44+
marp --html --allow-local-files "$file" -o "$dstdir/$out_html"
45+
marp --pdf --allow-local-files "$file" -o "$dstdir/$out_pdf"
46+
47+
# Check if HTML file was generated and report its size
48+
htmlpath="$dstdir/$out_html"
49+
if [ -f "$htmlpath" ]; then
50+
size=$(stat -c %s "$htmlpath" 2>/dev/null || stat -f %z "$htmlpath" 2>/dev/null)
51+
echo "Generated $htmlpath ($size bytes)"
52+
else
53+
echo "File $htmlpath was not generated."
54+
fi
55+
56+
# Check if PDF file was generated and report its size
57+
pdfpath="$dstdir/$out_pdf"
58+
if [ -f "$pdfpath" ]; then
59+
size=$(stat -c %s "$pdfpath" 2>/dev/null || stat -f %z "$pdfpath" 2>/dev/null)
60+
echo "Generated $pdfpath ($size bytes)"
61+
else
62+
echo "File $pdfpath was not generated."
63+
fi
64+
done
65+
66+
echo "All talks processed."
67+
# Add index.html listing all talks
68+
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>simdjson&#39;s talks</title><link rel="stylesheet" href="styles.css"></head><body><h1>simdjson&#39;s talks</h1>' > public/index.html
69+
# Collect all talks and years
70+
awk 'BEGIN{FS="/"} /^[^#]/ && NF>0 { year=$1; talks[year]=talks[year] $0 "\n"; years[year]=1 } END { for (y in years) print y }' .marp-talks | sort -r > years.txt
71+
while read year; do
72+
[ -z "$year" ] && continue
73+
echo "<h2>$year</h2><ul>" >> public/index.html
74+
grep "^$year/" .marp-talks | while read file; do
75+
[ -z "$file" ] && continue
76+
case "$file" in \#*) continue ;; esac
77+
relpath="${file%.md}"
78+
htmlpath="$relpath.html"
79+
pdfpath="$relpath.pdf"
80+
title=$(grep -m 1 '^title:' "$file" | sed 's/^title: //')
81+
description=$(grep -m 1 '^description:' "$file" | sed 's/^description: //')
82+
echo "<li><a href='$htmlpath' title='$description'>$title</a> <a href='$pdfpath' title='$description'>PDF</a></li>" >> public/index.html
83+
done
84+
echo "</ul>" >> public/index.html
85+
done < years.txt
86+
rm years.txt
87+
echo '</body></html>' >> public/index.html
88+
cp css/styles.css public/ || true

0 commit comments

Comments
 (0)