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
52 changes: 1 addition & 51 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hormone Experts – Men's Health</title>
<script crossorigin src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.23.10/babel.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
""" + component_code + """
ReactDOM.render(<MensHealthCombined />, document.getElementById('root'));
</script>
</body>
</html>
"""

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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ dist
# Vite logs files
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
gh-pages-dist/
49 changes: 49 additions & 0 deletions scripts/build-gh-pages.py
Original file line number Diff line number Diff line change
@@ -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 = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hormone Experts \u2013 Men's Health</title>
<script crossorigin src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.23.10/babel.min.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
""" + component_code + """
ReactDOM.render(<MensHealthCombined />, document.getElementById('root'));
</script>
</body>
</html>
"""

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)")