Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aminnairi/rollup-plugin-sitemap

Sitemap generator
https://github.com/aminnairi/rollup-plugin-sitemap

generator plugin rollup sitemap xml

Last synced: about 5 hours ago
JSON representation

Sitemap generator

Awesome Lists containing this project

README

        

# @aminnairi/rollup-plugin-sitemap

Sitemap generator

## Installation

```bash
npm install rollup @aminnairi/rollup-plugin-sitemap
touch rollup.config.js
```

## Configuration

```javascript
import { defineConfig } from "rollup"
import { sitemap } from "@aminnairi/rollup-plugin-sitemap"

export default defineConfig({
input: "index.js",
plugins: [
sitemap({
baseUrl: "https://domain.com",
urls: [
{ location: "/" },
{ location: "/about" }
{ location: "/contact" }
]
})
],
output: {
file: "build/index.js",
format: "cjs"
}
})
```

```xml
cat build/sitemap.xml


https://domain.com/


https://domain.com/about


https://domain.com/contact

```

## Configuration with last modification

```javascript
import { defineConfig } from "rollup"
import { sitemap } from "@aminnairi/rollup-plugin-sitemap"

export default defineConfig({
input: "index.js",
plugins: [
sitemap({
baseUrl: "https://domain.com",
urls: [
{
location: "/",
lastModified: new Date()
},
{
location: "/about",
lastModified: new Date()
}
{
location: "/contact",
lastModified: new Date()
}
]
})
],
output: {
file: "build/index.js",
format: "cjs"
}
})
```

```xml
cat build/sitemap.xml


https://domain.com/
2022-09-09


https://domain.com/about
2022-09-09


https://domain.com/contact
2022-09-09

```

## Configuration with change frequency

```javascript
import { defineConfig } from "rollup"
import { sitemap } from "@aminnairi/rollup-plugin-sitemap"

export default defineConfig({
input: "index.js",
plugins: [
sitemap({
baseUrl: "https://domain.com",
urls: [
{
location: "/",
changeFrequency: "monthly"
},
{
location: "/about",
changeFrequency: "monthly"
}
{
location: "/contact",
changeFrequency: "monthly"
}
]
})
],
output: {
file: "build/index.js",
format: "cjs"
}
})
```

```xml
cat build/sitemap.xml


https:/domain.com/
monthly


https:/domain.com/about
monthly


https:/domain.com/contact
monthly

```

## Configuration with priority

```javascript
import { defineConfig } from "rollup"
import { sitemap } from "@aminnairi/rollup-plugin-sitemap"

export default defineConfig({
input: "index.js",
plugins: [
sitemap({
baseUrl: "https://domain.com",
urls: [
{
location: "/",
priority: 1
},
{
location: "/about",
priority: 1
}
{
location: "/contact",
priority: 1
}
]
})
],
output: {
file: "build/index.js",
format: "cjs"
}
})
```

```xml
cat build/sitemap.xml


https:/domain.com/
1


https:/domain.com/about
1


https:/domain.com/contact
1

```

## Contributing

See [`CONTRIBUTING.md`](./CONTRIBUTING.md).

## License

See [`LICENSE`](./LICENSE).