Skip to content

discoverBlogrolls ​

Discovers and validates OPML blogrolls from a webpage.

Signature ​

typescript
function discoverBlogrolls(
  input: DiscoverInput,
  options?: DiscoverOptions<BlogrollResult, 'html' | 'headers' | 'guess'>,
): Promise<Array<DiscoverResult<BlogrollResult>>>

Parameters ​

input ​

The URL to discover blogrolls from. Can be a string or an object:

typescript
// String - URL to fetch and scan
discoverBlogrolls('https://example.com', options)

// Object - provide existing content/headers
discoverBlogrolls({
  url: 'https://example.com',
  content: htmlContent,
  headers: responseHeaders,
}, options)

options ​

All options are optional. When not provided, sensible defaults are used.

PropertyTypeDefaultDescription
methodsDiscoverMethodsConfig['html', 'headers', 'guess']Which methods to use
fetchFnDiscoverFetchFnnative fetchCustom fetch function
extractFnDiscoverExtractFnfeedsmithCustom OPML extraction function
resolveUrlFnDiscoverResolveUrlFnresolve relativeCustom URL resolution function
resolveSiteUrlFnDiscoverResolveSiteUrlFnsite link from feedResolves the site URL to scan when the input is a feed
stopOnFirstMethodbooleanfalseStop after the first method that finds a valid result
stopOnFirstResultbooleanfalseStop after first valid blogroll
concurrencynumber3Max parallel validations
maxUrisnumber50Max total candidate URIs to fetch across all methods
includeInvalidbooleanfalseInclude invalid results
onProgressDiscoverOnProgressFnProgress callback
onErrorDiscoverOnErrorFnCalled when fetching the input or the site URL fails. DiscoverOnErrorFn lists everything it reports

Return Value ​

Returns a promise that resolves to an array of results:

typescript
// Valid result
{
  url: 'https://example.com/blogroll.opml',
  isValid: true,
  title: 'My Reading List',
  method: 'guess',
}

// Invalid result (when includeInvalid: true)
{
  url: 'https://example.com/not-opml.xml',
  isValid: false,
  error: Error, // Only set when the request or the extractor threw
  method: 'guess',
}

Examples ​

Basic Usage ​

typescript
import { discoverBlogrolls } from 'feedscout'

// Simple usage - all methods enabled by default
const blogrolls = await discoverBlogrolls('https://example.com')

// Or specify which methods to use
const blogrolls = await discoverBlogrolls('https://example.com', {
  methods: ['html', 'guess'],
})

With Custom Options ​

typescript
import { urisComprehensive } from 'feedscout/blogrolls'

const blogrolls = await discoverBlogrolls('https://example.com', {
  methods: {
    html: {
      anchorLabels: ['blogroll', 'opml'],
    },
    guess: {
      uris: urisComprehensive,
    },
  },
})