forked from ProjectEvergreen/greenwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic Sitemap - moved to greenwood plugins (ProjectEvergreen#1232)
- Loading branch information
Showing
14 changed files
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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); | ||
} | ||
} | ||
|
||
|
||
|
||
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/cli/test/cases/build.plugins.copy-sitemap/greenwood.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
plugins: [] | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
packages/cli/test/cases/develop.plugins.resource-sitemap/greenwood.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export default { | ||
plugins: [ | ||
] | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions
8
packages/plugin-adapter-sitemap/test/cases/build.default/greenwood.config.js
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/plugin-adapter-sitemap/test/cases/develop.default/greenwood.config.js
This file was deleted.
Oops, something went wrong.