Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async create(filePath) {
const shouldCreate = !this.pages[filePath];
if (shouldCreate) {
this.pages[filePath] = true;
const componentPath = path.join(this.pagesDirectory, filePath);
const content = await readFile(componentPath);
const { data: frontmatter } = grayMatter(content);
this.createPage({
path: createPath(filePath),
component: componentPath,
context: frontmatter,
});
}
}
this.store.getState().pages.forEach(page => {
if (page.component === componentPath) {
this.deletePage({
path: createPath(filePath),
component: componentPath,
});
}
});
this.pages[filePath] = undefined;