Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ jobs:
# Verify combined PDF
test -f _site/docs.pdf || (echo "Missing docs.pdf" && exit 1)

# Verify single preview image for combined PDF
test -f _site/preview.png || (echo "Missing preview.png" && exit 1)
# Verify single preview image for combined PDF (derived from PDF name)
test -f _site/docs.png || (echo "Missing docs.png" && exit 1)

# Verify .md links were rewritten to .html
if grep -q '\.md"' _site/docs/index.html; then
Expand Down Expand Up @@ -319,20 +319,20 @@ jobs:
body += `**Single-file mode (test-output-single):**\n`;
body += `- resume.pdf\n`;
body += `- index.html\n`;
body += `- preview.png\n\n`;
body += `- resume.png\n\n`;
body += `**Combined mode (test-output-combined):**\n`;
body += `- docs.pdf (combined)\n`;
body += `- index.html (auto-generated index)\n`;
body += `- docs/*.html (individual pages)\n`;
body += `- preview.png\n\n`;
body += `- docs.png\n\n`;
body += `**Collection mode - flat (test-output-collection-flat):**\n`;
body += `- resume.pdf, cover-letter.pdf, references.pdf\n`;
body += `- resume.html, cover-letter.html, references.html\n`;
body += `- *-preview.png (one per document)\n\n`;
body += `- *.png (one per document)\n\n`;
body += `**Collection mode - nested (test-output-collection-nested):**\n`;
body += `- projects/web/*.pdf, projects/mobile/*.pdf\n`;
body += `- projects/web/*.html, projects/mobile/*.html\n`;
body += `- *-preview.png (one per document)\n`;
body += `- *.png (one per document)\n`;

await github.rest.issues.createComment({
owner: context.repo.owner,
Expand Down
66 changes: 59 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ inputs:
required: false
default: 'index.html'
output-preview:
description: 'Output preview image filename (without extension)'
description: 'Output preview image filename (without extension). Defaults to PDF name if not set.'
required: false
default: 'preview'
default: ''
preview-dpi:
description: 'Preview image resolution in DPI'
required: false
Expand Down Expand Up @@ -166,7 +166,13 @@ runs:
BASE_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
fi

PREVIEW_URL="${BASE_URL}/${{ inputs.output-preview }}.png"
PDF_NAME="${{ inputs.output-pdf }}"
PREVIEW_NAME="${{ inputs.output-preview }}"
if [ -z "$PREVIEW_NAME" ]; then
PREVIEW_NAME="${PDF_NAME%.pdf}"
fi

PREVIEW_URL="${BASE_URL}/${PREVIEW_NAME}.png"
PAGE_URL="${BASE_URL}/"

cat > /tmp/og-header.html << 'HEADER_EOF'
Expand All @@ -182,8 +188,8 @@ runs:
--include-in-header=/tmp/og-header.html \
--lua-filter="${{ github.action_path }}/filters/mdlinks-to-html.lua"

- name: Generate HTML pages (multi-file mode)
if: ${{ inputs.sources != '' }}
- name: Generate HTML pages (multi-file combined mode)
if: ${{ inputs.sources != '' && inputs.mode == 'combined' }}
shell: bash
run: |
set -euo pipefail
Expand All @@ -195,7 +201,13 @@ runs:
BASE_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
fi

PREVIEW_URL="${BASE_URL}/${{ inputs.output-preview }}.png"
PDF_NAME="${{ inputs.output-pdf }}"
PREVIEW_NAME="${{ inputs.output-preview }}"
if [ -z "$PREVIEW_NAME" ]; then
PREVIEW_NAME="${PDF_NAME%.pdf}"
fi

PREVIEW_URL="${BASE_URL}/${PREVIEW_NAME}.png"
PAGE_URL="${BASE_URL}/"

cat > /tmp/og-header.html << 'HEADER_EOF'
Expand All @@ -218,6 +230,40 @@ runs:
--lua-filter="${{ github.action_path }}/filters/mdlinks-to-html.lua"
done < /tmp/mdpress_files.txt

- name: Generate HTML pages (multi-file collection mode)
if: ${{ inputs.sources != '' && inputs.mode == 'collection' }}
shell: bash
run: |
set -euo pipefail

REPO_NAME="${{ github.event.repository.name }}"
if [ "${{ github.repository_owner }}" = "${{ github.event.repository.name }}" ]; then
BASE_URL="https://${{ github.repository_owner }}.github.io"
else
BASE_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}"
fi

while IFS= read -r SRC; do
REL="${SRC#./}"
DEST="_site/${REL%.md}.html"
PREVIEW_URL="${BASE_URL}/${REL%.md}.png"
PAGE_URL="${BASE_URL}/${REL%.md}.html"
mkdir -p "$(dirname "$DEST")"

cat > /tmp/og-header.html << HEADER_EOF
<meta property="og:type" content="website">
<meta property="og:image" content="${PREVIEW_URL}">
<meta property="og:url" content="${PAGE_URL}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="${PREVIEW_URL}">
HEADER_EOF

echo "Converting $SRC -> $DEST"
pandoc -s "$SRC" -o "$DEST" \
--include-in-header=/tmp/og-header.html \
--lua-filter="${{ github.action_path }}/filters/mdlinks-to-html.lua"
done < /tmp/mdpress_files.txt

- name: Generate index page (multi-file mode, combined)
if: ${{ inputs.sources != '' && inputs.mode == 'combined' }}
shell: bash
Expand Down Expand Up @@ -284,7 +330,13 @@ runs:
- name: Generate preview image (single-file or combined mode)
if: ${{ inputs.sources == '' || inputs.mode == 'combined' }}
shell: bash
run: pdftoppm "_site/${{ inputs.output-pdf }}" "_site/${{ inputs.output-preview }}" -png -singlefile -rx ${{ inputs.preview-dpi }} -ry ${{ inputs.preview-dpi }}
run: |
PDF_NAME="${{ inputs.output-pdf }}"
PREVIEW_NAME="${{ inputs.output-preview }}"
if [ -z "$PREVIEW_NAME" ]; then
PREVIEW_NAME="${PDF_NAME%.pdf}"
fi
pdftoppm "_site/$PDF_NAME" "_site/$PREVIEW_NAME" -png -singlefile -rx ${{ inputs.preview-dpi }} -ry ${{ inputs.preview-dpi }}

- name: Generate preview images (collection mode)
if: ${{ inputs.sources != '' && inputs.mode == 'collection' }}
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| `sources` | Space or newline separated list of Markdown files or glob patterns (multi-file mode) | — |
| `output-pdf` | Output PDF filename | `document.pdf` |
| `output-html` | Output HTML filename | `index.html` |
| `output-preview` | Output preview image filename (without extension) | `preview` |
| `output-preview` | Output preview image filename (without extension) | PDF name |
| `preview-dpi` | Preview image resolution in DPI | `150` |
| `mode` | Multi-file mode: `combined` (single PDF) or `collection` (separate PDFs) | `combined` |
| `index-title` | Title for auto-generated index page (multi-file mode) | `Index` |
Expand Down