-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { checkResourceExists } from "@greenwood/cli/src/lib/resource-utils.js"; | ||
Check failure on line 1 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
Check failure on line 1 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
Check failure on line 1 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
import fs from 'fs/promises'; | ||
|
||
|
||
Check failure on line 4 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
async function writeSitemap(compilation) { | ||
try { | ||
Check failure on line 6 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
const { scratchDir, projectDirectory } = compilation.context; | ||
Check failure on line 7 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
const adapterScratchUrl = new URL('./sitemap.xml', scratchDir); | ||
Check failure on line 8 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
|
||
Check failure on line 9 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
// Check if module exists | ||
Check failure on line 10 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
const sitemapModule = await import(`${projectDirectory}/src/sitemap.xml.js`); | ||
Check failure on line 11 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
const sitemap = await sitemapModule.generateSitemap(compilation); | ||
Check failure on line 12 in packages/cli/src/plugins/copy/plugin-copy-sitemap.js GitHub Actions / build (18)
|
||
|
||
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', | ||
name: 'plugin-copy-sitemap', | ||
provider: async (compilation) => { | ||
|
||
const { outputDir } = compilation.context; | ||
const sitemapScratchUrl = await writeSitemap(compilation); | ||
|
||
return [{ | ||
from: sitemapScratchUrl, | ||
to: new URL('./sitemap.xml', outputDir) | ||
}]; | ||
} | ||
}]; | ||
|
||
export { greenwoodPluginCopySitemap }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
plugins: [] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export default { | ||
plugins: [ | ||
] | ||
}; |
This file was deleted.
This file was deleted.