Add dynamic robots.txt generation and update sitemap handling

- Remove static robots.txt file.
- Implement dynamic robots.txt generator script (`generate_robots_txt.js`) to allow hostname flexibility.
- Update sitemap generation script to also use dynamic hostname from arguments.
- Modify Vite config to include automated generation of both sitemap and robots.txt during build.
- Add `public/robots.txt` to `.gitignore`.
This commit is contained in:
geoffsee
2025-05-28 22:04:28 -04:00
parent 82ba490dae
commit db5137e772
5 changed files with 56 additions and 10 deletions

View File

@@ -3,14 +3,18 @@ import vike from "vike/plugin";
import { defineConfig } from "vite";
import * as child_process from "node:child_process";
const APP_FQDN = "open-gsio.seemueller.workers.dev";
export default defineConfig(({ command }) => {
const customPlugins = [
{
name: "sitemap-generator",
buildStart(options) {
if (command === "build") {
child_process.execSync("./scripts/generate_sitemap.js");
child_process.execSync("./scripts/generate_sitemap.js " + APP_FQDN);
console.log("Generated Sitemap -> public/sitemap.xml");
child_process.execSync("./scripts/generate_robots_txt.js " + APP_FQDN);
console.log("Generated robots.txt -> public/robots.txt");
}
},
},
@@ -40,6 +44,7 @@ export default defineConfig(({ command }) => {
build: {
emitAssets: false,
sourcemap: false,
minify: true,
target: ["es2020", "edge88", "firefox78", "chrome87", "safari13"],
rollupOptions: {
output: {