npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mapify-cli

v2.0.0

Published

A CLI tool for generating `sitemap.xml` files for various frontend frameworks including Angular, React, and Vue. Automatically detects changes in project files to update the `lastmod` attribute and supports multiple build outputs.

Downloads

351

Readme

mapify-cli

mapify-cli is a CLI tool for generating sitemap.xml files for various frontend frameworks such as Angular, React, Vue, and more. It simplifies the creation of sitemaps by using a configuration file and automatically detects changes in your project files to update the lastmod attribute.

Features

  • Framework Agnostic: Works with Angular, React, Vue, and other frontend frameworks.
  • Automatic Last Modified Dates: Detects the latest modifications of component files to update the lastmod attribute in your sitemap.
  • Customizable Config: Provides options to configure default change frequencies, priorities, and more.
  • Multiple Builds Support: Handles multiple build outputs seamlessly. You can specify different output paths for various builds like SSR and serverless.
  • Force Option: Allows you to bypass Git detection for lastmod updates.

Installation

To install mapify-cli, run:

npm install -g mapify-cli

Usage

Commands

  • --init: Initializes a sample config file (mapify.config.js).
  • --config <path>: Uses a custom configuration file.
  • --generate: Generates the sitemap.xml file based on the config.

Example

To generate the sitemap.xml, use:

npx mapify-cli --generate

Configuration

Create a configuration file (mapify.config.js) in your project root. The configuration should look like this:

/** @type {import('mapify-cli').MapifyConfig} */

module.exports = {
    baseUrl: "http://example.com", // required
    outputPaths: ['./dist/angular-ui/browser', './dist/angular-ui-serverless/browser'],  // required
    pages: [
        {
            path: '/',  // required
            priority: 1,  // required
            changeFreq: 'weekly',  // (optional) default = monthly
            componentPath: './src/app/pages/home/**' // (optional)
        },
        {
            path: '/about',
            priority: 0.8,
            componentPath: './src/app/pages/about/**'
        },
        {
            path: '/contact',
            priority: 0.8,
            componentPath: './src/app/pages/contact/**'
        },
        {
            path: '/login',
            priority: 0.9,
            changeFreq: 'weekly',
            componentPath: './src/app/pages/login/**'
        }
    ],
    defaultChangeFreq: 'monthly', // optional
    defaultPriority: 0.5, // optional
    forceLastModificationDate: false // optional
};

Options

  • baseUrl (string): The base URL of your site.
  • outputPaths (string[]): Array of output paths where the sitemap.xml will be saved. Supports multiple builds, such as SSR and serverless builds.
  • pages (IPage[]): Array of page configurations.
    • path (string): The URL path of the page.
    • priority (number): The priority of the page (0.0 to 1.0).
    • changeFreq (ChangeFreq): Optional. How frequently the page is likely to change (e.g., 'daily', 'weekly'). Defaults to defaultChangeFreq.
    • componentPath (string): Optional. Path to the components used to detect the last modified date.
  • defaultChangeFreq (ChangeFreq): Default change frequency for all pages.
  • defaultPriority (number): Default priority for all pages.
  • forceLastModificationDate (boolean): If true, skips Git detection for lastmod and uses the current date.

GitHub Action

To automate sitemap generation using GitHub Actions, add the following workflow to your .github/workflows/ directory:

name: Generate Sitemap

on:
  push:
    branches:
      - main

jobs:
  generate-sitemap:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Generate Sitemap
        run: npx mapify-cli --generate

License

This project is licensed under the MIT License.

Contributing

We welcome contributions to improve mapify-cli. Please see the CONTRIBUTING.md file for more information.

Support

For any issues or feature requests, please open an issue on the GitHub repository.

Code of Conduct

We are committed to providing a welcoming and inclusive environment for all contributors. Please review our Code of Conduct to understand our community standards and expectations.