import templatePaths from "./templatePaths"; const fs = require("fs"); export enum Templates { HOME, ARCHIVE, CATEGORY, SINGLE_POST, NOT_FOUND } const hasTemplate = (template: Templates) => { const mapTemplateToPath: { [key in Templates]: string } = { [Templates.HOME]: templatePaths.home, [Templates.ARCHIVE]: templatePaths.archive, [Templates.CATEGORY]: templatePaths.category, [Templates.SINGLE_POST]: templatePaths.post, [Templates.NOT_FOUND]: templatePaths.notFound }; const path = mapTemplateToPath[template]; return path ? fs.existsSync(path) : false; }; export default hasTemplate;