Mravuri96 / svelte-sitemap

Small helper which scans your Svelte routes and generates static sitemap.xml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm version Package License Build & Publish

Svelte static sitemap.xml generator

Small helper which scans your Svelte routes and generates static sitemap.xml

Install

via yarn

yarn add svelte-sitemap --dev

via npm

npm install svelte-sitemap --save-dev

Usage

CLI

svelte-sitemap --domain https://example.com

It scans your routes in build/ folder and generates build/sitemap.xml file

JavaScript

import { createSitemap } from './src/index';

createSitemap('https://example.com', { debug: true });

Example

Highly recommended to use as postbuild hook in you package.json

{
  "name": "my-project",
  "scripts": {
    "postbuild": "svelte-sitemap --domain https://mydomain.com"
  }
}

Options

Option Description default example
-d, --domain Use your domain (required) https://example.com -d https://mydomain.com
-o, --out-dir Set custum build folder build -o dist
-i, --ignore Ignore files or folders [] -i '**/admin/**' -i 'my-secret-page'
-t, --trailing-slashes Add trailing slashes false --trailing-slashes
-r, --reset-time Set lastModified time to now false -r
-h, --help Display this usage info - -
-v, --version Show version - -
--debug Show some useful logs - --debug

FAQ

How to exclude directory?

Let's say we want to ignore all admin folders and subfolders + just one exact page pages/my-secret-page

svelte-sitemap --domain https://www.example.com --ignore 'pages/my-secret-page' --ignore '**/admin/**'

Development

I welcome you to customize this according to your needs ;)

Pull requests for any improvements would be great!

Developing and debugging this library

git clone git@github.com:bartholomej/svelte-sitemap.git
cd svelte-sitemap
yarn
yarn start

Run demo locally

You can find and modify it in ./demo.ts file

yarn demo

Credits

Donation

If this project have helped you save time please consider making a donation for some 🍺 or 🍵 ;)

Privacy Policy

I DO NOT STORE ANY DATA. PERIOD.

I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.

That's why, with this library, what happens on your device stays on your device till disappear.

License

Copyright © 2021 Lukas Bartak

Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)

All contents are licensed under the MIT license.

ezoic increase your site revenue

About

Small helper which scans your Svelte routes and generates static sitemap.xml

License:MIT License


Languages

Language:TypeScript 84.9%Language:JavaScript 14.7%Language:Shell 0.3%Language:HTML 0.1%