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
64 changes: 32 additions & 32 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,193 +2,193 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://physicshub.github.io/</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://physicshub.github.io/contribute</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://physicshub.github.io/about</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/create</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/what-is-physics</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/class-12-physics-complete-guide</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/physics-bouncing-ball-comprehensive-educational-guide</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/comprehensive-guide-to-vector-operations</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/ball-uniformly-accelerated-motion</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/ball-free-fall-comprehensive-guide</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/spring-connection</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/physics-of-pendulum-explained</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/projectile-parabolic-motion</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/physics-behind-three-body-problem</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/blog/pi-from-block-collisions-explained</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/BouncingBall</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/VectorsOperations</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/BallAcceleration</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/BallGravity</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/SpringConnection</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/SimplePendulum</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/ParabolicMotion</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/InclinedPlane</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/CircularMotion</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/ThreeBody</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/HorizontalSpring</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/DoublePendulum</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/CollisionSimulation</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/test</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://physicshub.github.io/simulations/PiCollisions</loc>
<lastmod>2026-07-21T00:00:00.000Z</lastmod>
<lastmod>2026-07-27T00:00:00.000Z</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
Expand Down
29 changes: 25 additions & 4 deletions scripts/sitemap-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,35 @@ async function generateSitemap() {

const rawXml = (await streamToPromise(sitemap)).toString();

// Add XML declaration and format
// Format only — SitemapStream already emits an XML declaration.
// A previous version prepended a second <?xml ...?>, which browsers
// tolerate but Google Search Console rejects as invalid XML (#107).
const formatted = xmlFormat(rawXml, {
indentation: " ",
collapseContent: true,
lineSeparator: "\n",
});

const xmlOutput = formatted;
// Guarantee exactly one XML declaration, even if a dependency starts
// emitting none or more than one. (GSC rejects duplicated prologs.)
const body = formatted.replace(/<\?xml[^?]*\?>\s*/gi, "").trimStart();
if (!body.startsWith("<urlset")) {
throw new Error(
"Sitemap body must start with <urlset> after stripping XML declarations"
);
}

let xmlOutput = `<?xml version="1.0" encoding="UTF-8"?>\n${body}`;
if (!xmlOutput.endsWith("\n")) {
xmlOutput += "\n";
}

const declarationCount = (xmlOutput.match(/<\?xml\b/gi) || []).length;
if (declarationCount !== 1) {
throw new Error(
`Sitemap must contain exactly one XML declaration, found ${declarationCount}`
);
}

// Ensure public directory exists
const publicDir = join(__dirname, "../public");
Expand All @@ -91,13 +112,13 @@ async function generateSitemap() {

// Write to public directory
const publicPath = join(publicDir, `${sitemapName}.xml`);
writeFileSync(publicPath, xmlOutput);
writeFileSync(publicPath, xmlOutput, "utf8");
console.log(`✅ Sitemap generated with ${allRoutes.length} links in public/`);

// Also write to out/ if it exists (for deployment consistency)
const outDir = join(__dirname, "../out");
if (existsSync(outDir)) {
writeFileSync(join(outDir, `${sitemapName}.xml`), xmlOutput);
writeFileSync(join(outDir, `${sitemapName}.xml`), xmlOutput, "utf8");
console.log(`✅ Sitemap copied to ./out/`);
}

Expand Down
Loading