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

sceptre

v1.2.5

Published

A CLI tool for compiling React Router page structures into generated imports

Downloads

7

Readme

Sceptre

Implement Next.js style page directories in your single page application by generating routing definitions from a page directory.

Installation

Install the CLI

npm install -g sceptre

Page folder structure

Pages are defined using a folder structure in your application. Subfolders denote path segments, while pages map to index.tsx or index.jsx files. When using sceptre, each page is given it's own directory in which assets and styles can be placed, allowing for a clean and structured page setup.

Exporting pages

Each page is expected to contain a default export of it's RouteObject. The path property will automatically be populated when parsing the tree, so it may be omitted.

const IndexPage = () => {
    return (
        <div>
            Page content
        </div>
    )
};

IndexPage.info = {
	title: 'Index Page'
}

export default IndexPage;

URL Parameters

Parameters can be defined by using [name] as folder name. This will automatically translate into :name when building routes.

We also support a other parameter type: ... which will match any path segment.

Index mapping

Folders named @ will map to the index page of the parent directory.

Parent pages

You can add a parent pages by making a folder named _ anywhere in your file tree. Parent pages are responsible for placing an <Outlet /> where child routes will be rendered. Routes can be parented any number of times, each rendering in its closest parent outlet.

Visual example:

/example/_				- Responsible for rendering outlet 1
/example/@				- Rendered inside outlet 1
/example/page/_			- Rendered inside outlet 1 and responsible for rendering outlet 2
/example/page/@			- Rendered inside outlet 2
/example/page/child 	- Rendered inside outlet 2

Example folder structure

pages/
    @/
        index.tsx
        styles.tsx
    help/
        index.tsx
        style.scss
    settings/
        _/
            index.tsx
        overview/
            index.tsx
        [param]/
            index.tsx
    folder/
        _/
            index.tsx
        [...]/
            index.tsx
            style.scss

The above example translates to the given routes

/
/help
/settings/overview
/settings/:param
/folder/*

Usage

sceptre ./src/pages/**/index.tsx ./src/generated/routes.ts --base ./src/pages

This command will compile all index components placed recursively within the pages directory and generates a routes.ts.

Base directory

The --base flag should point to the directory containing all pages. By default it is set to the current execution directory.

Identing

You can optionally pass --indent none | tab | <number> to control the indentation of the generated routing configuration. By default indentation is disabled.

Forced js extensions

Certain environments may require all script file imports to end with .js regardless of their actual extension. In this case you can pass the --force-js flag.

Vindigo

This package was originally developed for use in Vindigo, a free and open source task planner.

License

sceptre is licensed under MIT

Copyright (c) 2022-present, Starlane Studios