mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-07-26 12:08:15 +00:00
fix(website): generate sitemap only in build output
This commit is contained in:
@@ -114,17 +114,13 @@ jobs:
|
||||
sed -i "s/New v[0-9]\+\.[0-9]\+\.[0-9]\+ Release/New v$VERSION Release/g" README.md
|
||||
echo " ✓ README.md -> v$VERSION"
|
||||
|
||||
# 7. website/sitemap.xml — lastmod dates
|
||||
sed -i "s/<lastmod>[0-9-]*<\/lastmod>/<lastmod>$(date +%Y-%m-%d)<\/lastmod>/g" website/sitemap.xml
|
||||
echo " ✓ website/sitemap.xml -> lastmod $(date +%Y-%m-%d)"
|
||||
|
||||
echo "Version injection complete."
|
||||
|
||||
- name: Commit and push version updates back to main
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git add extension/manifest.base.json shared/constants.js package.json website/version.json website/template.html README.md website/sitemap.xml
|
||||
git add extension/manifest.base.json shared/constants.js package.json website/version.json website/template.html README.md
|
||||
git commit -m "chore(release): update versions to $GITHUB_REF_NAME [skip ci]" || echo "No changes to commit"
|
||||
git push origin HEAD:main
|
||||
env:
|
||||
|
||||
+2
-3
@@ -539,7 +539,7 @@ async function compile() {
|
||||
}
|
||||
|
||||
// ── 5.5 Generate dynamic sitemap ──
|
||||
generateSitemap(wwwDir, websiteDir);
|
||||
generateSitemap(wwwDir);
|
||||
|
||||
// Auto-copy Google verification files and IndexNow/txt key files from website source to www root
|
||||
const websiteFiles = fs.readdirSync(websiteDir);
|
||||
@@ -684,7 +684,7 @@ async function compile() {
|
||||
console.log('KoalaSync build finished successfully! Output: website/www/');
|
||||
}
|
||||
|
||||
function generateSitemap(wwwDir, websiteDir) {
|
||||
function generateSitemap(wwwDir) {
|
||||
const languages = [
|
||||
{ code: 'en', prefix: '', hreflang: 'en' },
|
||||
{ code: 'de', prefix: 'de/', hreflang: 'de' },
|
||||
@@ -774,7 +774,6 @@ function generateSitemap(wwwDir, websiteDir) {
|
||||
|
||||
xml += `\n</urlset>\n`;
|
||||
|
||||
fs.writeFileSync(path.join(websiteDir, 'sitemap.xml'), xml.trim() + '\n', 'utf8');
|
||||
fs.writeFileSync(path.join(wwwDir, 'sitemap.xml'), xml.trim() + '\n', 'utf8');
|
||||
console.log(' ✓ Dynamically generated sitemap.xml with current date');
|
||||
}
|
||||
|
||||
-2668
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
const https = require('https');
|
||||
|
||||
const websiteDir = __dirname;
|
||||
const sitemapPath = path.join(websiteDir, 'sitemap.xml');
|
||||
const sitemapPath = path.join(websiteDir, 'www', 'sitemap.xml');
|
||||
|
||||
// 1. Find the IndexNow key file in the website directory
|
||||
const files = fs.readdirSync(websiteDir);
|
||||
@@ -34,7 +34,7 @@ console.log(`Key Location: ${keyLocation}`);
|
||||
|
||||
// 2. Parse URLs from sitemap.xml
|
||||
if (!fs.existsSync(sitemapPath)) {
|
||||
console.error(`Error: sitemap.xml not found at ${sitemapPath}`);
|
||||
console.error(`Error: generated sitemap.xml not found at ${sitemapPath}. Run \`node website/build.cjs\` first.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user