Skip to content

Commit

Permalink
feat: add exclude pattern for links in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Schmittat committed Jan 6, 2024
1 parent 0bbbddd commit 16443ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export const configSchema = z.object({
* @default ""
*/
match: z.string().or(z.array(z.string())),

/**
* Pattern to match against for links on a page to exclude from crawling
* @example "https://www.builder.io/c/docs/**"
* @default ""
*/
exclude: z.string().or(z.array(z.string())).optional(),
/**
* Selector to grab the inner text from
* @example ".docs-builder-container"
Expand Down
2 changes: 2 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export async function crawl(config: Config) {
await enqueueLinks({
globs:
typeof config.match === "string" ? [config.match] : config.match,
exclude:
typeof config.exclude === "string" ? [config.exclude] : config.exclude ?? [],
});
},
// Comment this option to scrape the full website.
Expand Down

0 comments on commit 16443ed

Please sign in to comment.