Skip to content

Commit

Permalink
Dynamic Sitemap - Oops, linting (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstockdi committed Jul 27, 2024
1 parent 9564d0c commit 525780d
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions packages/cli/src/plugins/copy/plugin-copy-sitemap.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { checkResourceExists } from "@greenwood/cli/src/lib/resource-utils.js";
import fs from 'fs/promises';


async function writeSitemap(compilation) {
try {
const { scratchDir, projectDirectory } = compilation.context;
const adapterScratchUrl = new URL('./sitemap.xml', scratchDir);

// Check if module exists
const sitemapModule = await import(`${projectDirectory}/src/sitemap.xml.js`);
const sitemap = await sitemapModule.generateSitemap(compilation);

await fs.writeFile(adapterScratchUrl, sitemap);
console.info('Wrote sitemap to ./sitemap.xml');

return adapterScratchUrl;
} catch (error) {
console.error('Error in sitemapAdapter:', error);
}
}
try {
const { scratchDir, projectDirectory } = compilation.context;
const adapterScratchUrl = new URL('./sitemap.xml', scratchDir);

// Check if module exists
const sitemapModule = await import(`${projectDirectory}/src/sitemap.xml.js`);
const sitemap = await sitemapModule.generateSitemap(compilation);

await fs.writeFile(adapterScratchUrl, sitemap);
console.info('Wrote sitemap to ./sitemap.xml');

return adapterScratchUrl;
} catch (error) {
console.error('Error in sitemapAdapter:', error);
}
}

const greenwoodPluginCopySitemap = [{
type: 'copy',
Expand All @@ -31,8 +27,8 @@ const greenwoodPluginCopySitemap = [{
const sitemapScratchUrl = await writeSitemap(compilation);

return [{
from: sitemapScratchUrl,
to: new URL('./sitemap.xml', outputDir)
from: sitemapScratchUrl,
to: new URL('./sitemap.xml', outputDir)
}];
}
}];
Expand Down

0 comments on commit 525780d

Please sign in to comment.