Skip to content

discoverBlogrolls

Discovers and validates OPML blogrolls from a webpage.

Signature

typescript
function discoverBlogrolls(
  input: DiscoverInput,
  options?: DiscoverOptions<BlogrollResult>,
): 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
normalizeUrlFnDiscoverNormalizeUrlFnCustom URL normalization function
concurrencynumber3Max parallel validations
stopOnFirstResultbooleanfalseStop after first valid blogroll
includeInvalidbooleanfalseInclude invalid results
onProgressDiscoverOnProgressFnProgress callback

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',
}

// Invalid result (when includeInvalid: true)
{
  url: 'https://example.com/not-opml.xml',
  isValid: false,
  error: Error,
}

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,
    },
  },
})