Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ type Config = {
url: string;
/** Pattern to match against for links on a page to subsequently crawl */
match: string;
/** Optional Selector to limit grabbing the links from */
matchSelector?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the term matchSelector is a bit broad, maybe we can call this linkSelector to be more clear whats different between this and selector

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @steve8708 for feedback
my reason for selecting "matchSelector" was to make it tied to the "match" property.
on the other hand, you have a point too.
what do you think?

/** Selector to grab the inner text from */
selector: string;
/** Don't crawl more than this many pages */
Expand Down
7 changes: 6 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const configSchema = z.object({
* @default ""
*/
match: z.string().or(z.array(z.string())),

/**
* Selector to grab links from
* @example "li > a.block"
* @default ""
*/
matchSelector: z.string().optional(),
/**
* Selector to grab the inner text from
* @example ".docs-builder-container"
Expand Down
1 change: 1 addition & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function crawl(config: Config) {
await enqueueLinks({
globs:
typeof config.match === "string" ? [config.match] : config.match,
selector: config.matchSelector,
});
},
// Comment this option to scrape the full website.
Expand Down