Skip to content

Instantly share code, notes, and snippets.

@multipliedtwice
multipliedtwice / sitemap.xml.js
Created February 14, 2022 14:59
Sveltekit sitemap xml
import dayjs from "dayjs"
import { supportedLanguages } from "../config"
import fs from "fs"
import path from "path"
const cwd = process.cwd()
import util from "util"
import glob from "glob"
const stat = util.promisify(fs.stat)
@multipliedtwice
multipliedtwice / node-async-base64-to-file.ts
Created December 17, 2021 14:50
Base64 to File async with Nodejs
import * as fs from 'fs';
import * as path from 'path';
const base64regex: RegExp = /^data:([A-Za-z-+\/]+);base64,(.+)$/;
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const defaultFileOptions = { filePath: './uploads', types: ['jpg', 'jpeg', 'png'], randomizeFileNameLength: 10 };
const typesArrayToRegex = async (types: string[]) => {
const typesToString = await Promise.all(
types.map((type, index) => (index === types.length - 1 ? `${type}` : `${type}|`)),
@multipliedtwice
multipliedtwice / sitemap.xml.js
Last active November 20, 2021 13:49
Multilingual Sapper sitemap.xml with day.js
import dayjs from "dayjs"
import { supportedLanguages } from "../config"
const fs = require("fs")
const path = require("path")
const cwd = process.cwd()
const matter = require("gray-matter")
const util = require("util")
const glob = require("glob")