Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mika-f/smxml
Create valid sitemap with builder pattern, written in TypeScript.
https://github.com/mika-f/smxml
Last synced: 4 days ago
JSON representation
Create valid sitemap with builder pattern, written in TypeScript.
- Host: GitHub
- URL: https://github.com/mika-f/smxml
- Owner: mika-f
- License: mit
- Created: 2024-01-22T12:18:49.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-01-25T12:21:00.000Z (10 months ago)
- Last Synced: 2024-05-02T02:21:29.360Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @natsuneko-laboratory/smxml
Create valid sitemap with builder pattern, written in TypeScript.
## Install
```bash
$ npm install @natsuneko-laboratory/smxml
$ yarn add @natsuneko-laboratory/smxml
$ pnpm add @natsuneko-laboratory/smxml
```## Usage
```typescript
import { SitemapBuilder } from "@natsuneko-laboratory/smxml";// create base builder
const base = SitemapBuilder.create("https://www.natsuneko.blog");// create sitemap index
const index = base.asIndex().addLocation({ url: "/sitemap-0.xml" });console.log(index.build());
// https://www.natsuneko.blog/sitemap-0.xmlconsole.log(index.build({ minified: false }));
/*
*
*
*
* https://www.natsuneko.blog/sitemap-0.xml
*
*
*/// create sitemap index
const urls = base.asUrlSet().addUrl({
loc: "/categories",
lastMod: new Date(),
changeFreq: "daily",
priority: 0.7,
});console.log(urls.build({ minified: false }));
/*
*
*
*
* https://www.natsuneko.blog/categories
* 2024-01-24T14:33:13.603Z
* daily
* 0.7
*
*
*/
```## License
MIT by [@6jz](https://twitter.com/6jz)