mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-01-22 17:30:00 +00:00
1 line
638 B
JavaScript
1 line
638 B
JavaScript
import slugify from"slugify";import path from"path";import fs from"fs";import{promisify}from"util";const writeFile=promisify(fs.writeFile);import{words}from"./undefined-words";const defintionPath=path.resolve(process.cwd(),"11ty/definitions/"),template="\n---\ntitle: {{title}}\nslug: {{slug}}\ndefined: false\n---\n";export function createDefinitions(){return words.forEach(async t=>{const e=t,i=slugify(t.toLowerCase().replace(/ \([a-z]+\)| ([a-z-]+) slur/i,"")),r=template.replace("{{title}}",e).replace("{{slug}}",i).trim();try{await writeFile(`${defintionPath}/${i}.md`,r,"utf8")}catch(t){console.error(t),process.exit(1)}return!0})} |