Skip to content

Commit

Permalink
Fixing linting (ProjectEvergreen#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstockdi committed Jun 14, 2024
1 parent 63e3807 commit 74ba3ff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-dynamic-sitemap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {

plugins: [
greenwoodPluginDynamicExport({
"base_url": "https://example.com"
"baseUrl": "https://example.com"
})
]
}
Expand Down
27 changes: 10 additions & 17 deletions packages/plugin-dynamic-sitemap/src/index.js
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 };
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* {
* plugins: [{
* greenwoodPluginDynamicExport({
* "base_url": "https://example.com"
* "baseUrl": "https://example.com"
* })
* }]
*
Expand All @@ -30,15 +30,12 @@
*/

import fs from 'fs';
import chai from 'chai';
import path from 'path';
import { runSmokeTest } from '../../../test/smoke-test.js';
import { getSetupFiles, getOutputTeardownFiles } from '../../../test/utils.js';
import { Runner } from 'gallinago';
import { fileURLToPath, URL } from 'url';

const expect = chai.expect;

describe('Build Greenwood With Dynamic Sitemap Plugin: ', function() {
const LABEL = 'Using Dynamic Sitemap feature';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
Expand All @@ -62,9 +59,7 @@ describe('Build Greenwood With Dynamic Sitemap Plugin: ', function() {
runSmokeTest(['public', 'index'], LABEL);

describe('Sitemap.xml should exist and be well formed', function() {
let robots;


it('should have one sitemaps file in the output directory', function() {
const sitemapXML = fs.readFileSync(path.join(this.context.publicDir, './sitemap.xml'));
console.log(sitemapXML);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dynamic-sitemap/test/greenwood.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ console.log(greenwoodPluginDynamicExport);
export default {
plugins: [
...greenwoodPluginDynamicExport({
"base_url": "https://example.com"
'baseUrl': 'https://example.com'
})
]
};

0 comments on commit 74ba3ff

Please sign in to comment.