diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 43ea5a2..50441e9 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -15,57 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: Build static index.html from Select-product-page.jsx - run: | - python3 - << 'PYEOF' - import re, os - - with open('Select-product-page.jsx', 'r') as f: - content = f.read() - - # Replace ES module import with global React reference using regex - # to handle variations in whitespace or quote style - component_code = re.sub( - r'''import\s*\{\s*useState\s*\}\s*from\s*['"]react['"];?''', - 'const { useState } = React;', - content - ) - # Remove export default so MensHealthCombined is a plain function in browser scope - component_code = re.sub( - r'\bexport\s+default\s+function\s+', - 'function ', - component_code - ) - - html = """ - - - - - Hormone Experts – Men's Health - - - - - - -
- - - -""" - - os.makedirs('gh-pages-dist', exist_ok=True) - with open('gh-pages-dist/index.html', 'w') as f: - f.write(html) - - print(f"Generated gh-pages-dist/index.html ({len(html)} bytes)") - PYEOF + run: python3 scripts/build-gh-pages.py - name: Deploy to gh-pages branch uses: peaceiris/actions-gh-pages@v3.9.3 diff --git a/.gitignore b/.gitignore index 9a5aced..5aed382 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,4 @@ dist # Vite logs files vite.config.js.timestamp-* vite.config.ts.timestamp-* +gh-pages-dist/ diff --git a/scripts/build-gh-pages.py b/scripts/build-gh-pages.py new file mode 100644 index 0000000..7b4d6ab --- /dev/null +++ b/scripts/build-gh-pages.py @@ -0,0 +1,49 @@ +import re +import os + +with open('Select-product-page.jsx', 'r') as f: + content = f.read() + +# Replace ES module import with global React reference using regex +# to handle variations in whitespace or quote style +component_code = re.sub( + r'''import\s*\{\s*useState\s*\}\s*from\s*['"]react['"];?''', + 'const { useState } = React;', + content +) +# Remove export default so MensHealthCombined is a plain function in browser scope +component_code = re.sub( + r'\bexport\s+default\s+function\s+', + 'function ', + component_code +) + +html = """ + + + + + Hormone Experts \u2013 Men's Health + + + + + + +
+ + + +""" + +os.makedirs('gh-pages-dist', exist_ok=True) +with open('gh-pages-dist/index.html', 'w') as f: + f.write(html) + +print(f"Generated gh-pages-dist/index.html ({len(html)} bytes)")