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.
Fixing linting (ProjectEvergreen#1232)
- Loading branch information
Showing
4 changed files
with
13 additions
and
25 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
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 |
---|---|---|
@@ -1,37 +1,30 @@ | ||
import { checkResourceExists } from "@greenwood/cli/src/lib/resource-utils.js"; | ||
import fs from 'fs/promises'; | ||
|
||
|
||
|
||
|
||
|
||
const greenwoodPluginDynamicExport = (options = {}) => [{ | ||
type: 'copy', | ||
name: 'plugin-dynamic-sitemap', | ||
provider: async (compilation) => { | ||
const { base_url} = options; | ||
|
||
const { baseUrl } = options; | ||
const { outputDir } = compilation.context; | ||
|
||
let sitemapXML = '<?xml version="1.0" encoding="UTF-8"?>\n'; | ||
sitemapXML += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' | ||
sitemapXML += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'; | ||
|
||
compilation.graph.forEach(page => { | ||
sitemapXML += `<url><loc>${base_url}${page.outputPath}</loc></url>\n` | ||
}); | ||
sitemapXML += `<url><loc>${baseUrl}${page.outputPath}</loc></url>\n`; | ||
}); | ||
|
||
sitemapXML += '</urlset>' | ||
sitemapXML += '</urlset>'; | ||
|
||
const sitemapUrl = new URL('./sitemap.xml', outputDir); | ||
await fs.writeFile(sitemapUrl, sitemapXML); | ||
|
||
return { | ||
from: sitemapUrl, | ||
to: new URL('./sitemap.xml', outputDir) | ||
from: sitemapUrl, | ||
to: new URL('./sitemap.xml', outputDir) | ||
}; | ||
} | ||
}]; | ||
|
||
export { greenwoodPluginDynamicExport }; | ||
|
||
|
||
export { greenwoodPluginDynamicExport }; |
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
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