Skip to content

Commit

Permalink
Dynamic Sitemap - combining plugins (ProjectEvergreen#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstockdi committed Jul 22, 2024
1 parent 3de7f8a commit d94bcba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
29 changes: 13 additions & 16 deletions packages/plugin-adapter-sitemap/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs/promises';
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';

async function sitemapAdapter(compilation) {
try {
Expand All @@ -16,24 +17,12 @@ async function sitemapAdapter(compilation) {
}
}

const greenwoodPluginAdapterSitemap = (options = {}) => [{
type: 'adapter',
name: 'plugin-adapter-sitemap',
provider: (compilation) => {
return async () => {
await sitemapAdapter(compilation, options);
};
}
}];

/*
*
* Sitemap
*
*/

import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';

class SitemapResource extends ResourceInterface {
constructor(compilation, options) {
super(compilation, options);
Expand Down Expand Up @@ -62,11 +51,19 @@ class SitemapResource extends ResourceInterface {

}

const greenwoodPluginResourceSitemap = {
const greenwoodPluginSitemap = (options = {}) => [{
type: 'adapter',
name: 'plugin-adapter-sitemap',
provider: (compilation) => {
return async () => {
await sitemapAdapter(compilation, options);
};
}
},
{
type: 'resource',
name: 'plugin-sitemap',
provider: (compilation, options) => new SitemapResource(compilation, options)
};
}];

export { greenwoodPluginResourceSitemap };
export { greenwoodPluginAdapterSitemap };
export { greenwoodPluginSitemap };
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import { greenwoodPluginAdapterSitemap, greenwoodPluginResourceSitemap } from '../../../src/index.js';
import { greenwoodPluginSitemap } from '../../../src/index.js';

export default {
plugins: [
greenwoodPluginAdapterSitemap(),
greenwoodPluginResourceSitemap
greenwoodPluginSitemap(),
]
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import { greenwoodPluginAdapterSitemap, greenwoodPluginResourceSitemap } from '../../../src/index.js';
import { greenwoodPluginSitemap } from '../../../src/index.js';

export default {
plugins: [
greenwoodPluginAdapterSitemap(),
greenwoodPluginResourceSitemap
greenwoodPluginSitemap(),
]
};

0 comments on commit d94bcba

Please sign in to comment.