Skip to content

Instantly share code, notes, and snippets.

View joranquinten's full-sized avatar
🚀
Rocket man

Joran Quinten joranquinten

🚀
Rocket man
View GitHub Profile
@joranquinten
joranquinten / nuxt-static-sitemap.js
Created October 30, 2022 20:48
Small node script that generates a sitemap xml based in a folder and its subfolders (assuming they each represent an individual page). Works well after rendering an SSR generated website.
const fs = require("fs");
const path = require("path");
const config = require("./package.json"); // Please add a "url" field to the package.json to serve as base domain
const ignoreFolders = ["_nuxt"]; // Modify if you see fit
const readFolder = "./dist"; // The location where static files are generated
const outputFile = "sitemap.xml" // The location to store the sitemap (placed at the root of the readFolder)
function flatten(lists) {
return lists.reduce((a, b) => a.concat(b), []);
@joranquinten
joranquinten / generate-sitemap.js
Created January 22, 2019 14:03
Generate sitemap XML for NextJs static sites based on exportPathMap
/*
Generates a sitemap based on the entries in exportPathMap in next.config.js file
Author: Joran Quinten
Don't forget to add the domain name as process variable PUBLIC_DOMAIN!
Trigger the file with a separate script in your package.json and add it to your build command in Netlify
(for instance, set Build command to: "npm run production && npm run postexport")
@joranquinten
joranquinten / hookAssets.js
Created February 4, 2016 09:27
hookAssets
/**
Dynamically hook (an array of) assets
**/
var hookAssets = function(urls) {
var pattern = /(?:\.([^.]+))?$/;
if (typeof(urls) === 'string') urls = url.split(','); // force it to by an array
for (var i = 0; i < url.length; i++) {