Skip to content

Commit

Permalink
Added options in the include
Browse files Browse the repository at this point in the history
  • Loading branch information
notangelmario committed Aug 11, 2023
1 parent 9e4aea1 commit 230a4b5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SitemapContext } from "./sitemap.ts";
import { Manifest, Plugin } from "./types.ts";
import { Manifest, Plugin, RouteProps } from "./types.ts";

interface PluginOptions {
include?: string[];
exclude?: string[];
include?: Array<string | { path: string, options: RouteProps }>
exclude?: Array<string>
}

export const freshSEOPlugin = (manifest: Manifest, opts: PluginOptions = {}): Plugin => {
Expand All @@ -16,8 +16,13 @@ export const freshSEOPlugin = (manifest: Manifest, opts: PluginOptions = {}): Pl
const sitemap = new SitemapContext(req.url, manifest);

if (opts.include) {
opts.include.forEach((path) => {
sitemap.add(path);
opts.include.forEach((route) => {
if (typeof route === "string") {
sitemap.add(route);
return;
}

sitemap.add(route.path, route.options);
})
}

Expand Down

0 comments on commit 230a4b5

Please sign in to comment.