edge-sitemap
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Edge Sitemap

Generator of Sitemaps using web standard technology for operation in Edge Computing.

Usage

import { SitemapStream } from 'edge-sitemap'

function createReadableStream() {
  return new ReadableStream({
    start(controller) {
      controller.enqueue({
        loc: '/',
        priority: 1.0,
      })
      controller.enqueue({
        loc: '/privacy',
        priority: 0.1,
      })
      controller.close()
    },
  })
}

addEventListener('fetch', (event) => {
  const baseURL = 'https://example.com/'
  const body = createReadableStream()
    .pipeThrough(new SitemapStream({ baseURL }))
    .pipeThrough(new TextEncoderStream())
  const response = new Response(body, {
    headers: {
      'Content-Type': 'application/xml; charset=UTF-8',
    },
  })

  return event.respondWith(response)
})

Package Sidebar

Install

npm i edge-sitemap

Weekly Downloads

47

Version

1.1.1

License

MIT

Unpacked Size

12.6 kB

Total Files

6

Last publish

Collaborators

  • ykzts