selfdefined/_temp/create-empty-definitions-min.js

1 line
638 B
JavaScript
Raw Normal View History

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})}