Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ionic-react-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic-react-sitemap

Generate a sitemap for an Ionic/React app

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Ionic React Sitemap

Ionic React Sitemap is a tool for generating a sitemap for an Ionic/React apps. It's based off lanierc's react-build-sitemap. Supports typescript.

This package is far from perfect, but it gets the job done! If you notice any issues or have suggestions for improvements, you are welcome to submit pull requests. Your contribution is appreciated in making this package better for everyone.

Installation

You can install this tool using npm:

npm install ionic-react-sitemap

Or you may use ionic-react-sitemap package via with npx:

Usage

NPX

You may use it easily on your CI;

npx ionic-react-sitemap ./src/App.js ./build http://yoururl.com

This command generates a sitemap for an Ionic/React app with the main entry file located at ./src/App.js, the build directory located at ./build, and the base URL set to http://yoururl.com.

If you don't specify the --url, --app-path, or --build-path options, the tool will prompt you to enter the values interactively. For example:

npx ionic-react-sitemap

This command will prompt you to enter the app path, build path, and base URL for your app.

JS

You can use Ionic React Sitemap in your plain JavaScript code:

const generateSitemap = require('ionic-react-sitemap');

const appPath = './src/App.js';
const buildPath = './build';
const url = 'http://yoururl.com';

generateSitemap(appPath, buildPath, url)
  .then(() => {
    console.log(`Sitemap generated successfully at ${buildPath}/sitemap.xml`);
  })
  .catch((error) => {
    console.error('Error generating sitemap:', error);
  });

Build Process

Or you can use it in your build process:

const generateSitemap = require('ionic-react-sitemap');
const path = require('path');
const webpack = require('webpack');

const appPath = './src/App.js';
const buildPath = './build';
const url = 'http://yoururl.com';

generateSitemap(appPath, buildPath, url)
  .then(() => {
    const config = {
      entry: appPath,
      output: {
        path: path.resolve(__dirname, buildPath),
        filename: 'bundle.js',
      },
      // ...
    };

    webpack(config, (err, stats) => {
      // ...
    });
  })
  .catch((error) => {
    console.error('Error generating sitemap:', error);
  });

API

Method SignatureDescription
generateSitemap(appPath: string, buildPath: string, url: string): Promise<void>Generate a sitemap for an Ionic/React app.

Parameters

ParameterTypeDefaultDescription
appPathstring./src/App.js or ./src/App.tsxThe path to the app's main entry file (e.g. ./src/App.tsx).
buildPathstring./buildThe path to the build directory for the app (e.g. ./build).
urlstringnullThe base URL for the app.
pathsstring[]["page", "AppPages"](Experimental) Paths for dynamic routes based on a map/url array.
elementsstring[]["Route","IonRoute", "Redirect"]JSX elements used to generate the sitemap.
lastModbooleantrueInclude <lastmod> tag.

Known issues

  1. It may or may not work with class components.
  2. Nested Routes May or May not be Supported

License

MIT

Keywords

FAQs

Package last updated on 09 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc