Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "sitemapy", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Simple utility to generate sitemaps in xml, with zero dependencies", | ||
@@ -5,0 +5,0 @@ "main": "dist/sitemapy.js", |
@@ -5,2 +5,72 @@ # Sitemapy | ||
Simple utility to generate sitemaps | ||
Simple utility to generate sitemaps | ||
## 👀 How to use ? | ||
```sh | ||
npm i sitemapy | ||
``` | ||
```js | ||
import {createSitemap} from "sitemapy" | ||
const siteRoot = "https://github.com" | ||
let pages = [ | ||
{ | ||
url: "/about", //all optional except url | ||
priority: 1, | ||
changefreq: "daily", | ||
lastmod: 10-04-22 | ||
} | ||
] | ||
const sitemap = createSitemap({pages, siteRoot}) //returns string of sitemap XML | ||
``` | ||
## Typescript | ||
```js | ||
import {createSitemap} from "sitemapy" | ||
import type {SitemapElement, SitemapConfig} from "sitemapy" | ||
const siteRoot = "https://github.com" | ||
let pages: Array<SitemapElement> = [ | ||
{ | ||
url: "/about", //all optional except url | ||
priority: 1, | ||
changefreq: "daily", | ||
lastmod: 10-04-22 | ||
} | ||
] | ||
const config: SitemapConfig = {pages, siteRoot} | ||
const sitemap = createSitemap(config) //returns string of sitemap XML | ||
``` | ||
## Examples | ||
With express | ||
```js | ||
import axios from "axios" | ||
import {createSitemap} from "sitemapy" | ||
app.get("/sitemap.xml", async (req, res) => { | ||
const siteRoot = "https://github.com" | ||
const {data} = await axios.get("/api/sitemapData") | ||
const sitemap = createSitemap({pages: data, siteRoot}) | ||
res.setHeader('Content-Type', 'application/xml') | ||
res.send(sitemap) | ||
}) | ||
``` |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
8639
0
100
75