1.0.4 • Published 2 years ago

@polarzoe/sitemap v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Sitemap

Small library for creating schema.org compatible XML sitemaps.

Compatibility

Should work in all browser and node environments including service workers.

The code is generated using the typescript es2021 target, so you need to transpile it to your needed target yourself when necessary.

Example

const sitemap = new Sitemap();
const entries = await getEntries();

entries.forEach((entry) => {
    sitemap.add(new Url(
        new URL(entry.uri),
        entry.dateUpdated,
        'weekly',
        0.5
    ));
    
    // or
    sitemap.add({
        loc: new URL(entry.uri),
        lastmod: entry.dateUpdated,
        changefreq: 'weekly',
        priority: 0.5
    });
});

// export as string
const result = sitemap.toString();

// or stream
sitemap.stream().pipe(response);

Change defaults

// static
Url.defaultChangeFreq = 'daily';
Url.defaultPriority = 1;

// or on an instance
const url = new Url();
url.defaultChangeFreq = 'daily';
url.defaultPriority = 1;
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago