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

@slashid/docusaurus-theme-slashid

v0.5.4

Published

SlashID theme for Docusaurus.

Downloads

142

Readme

SlashID theme to add authentication to Docusaurus.

license npm latest package npm downloads prettier PRs Welcome


Overview

The @slashid/docusaurus-theme-slashid package extends @docusaurus/preset-classic to add authentication to websites generated using Docusaurus.

Key Features:

  • Compatible: Supports Magic Links, Passkeys, OTP via sms and SSO.
  • Personalization: Allows to load per-user configuration data into docusaurus.

Documentation

For detailed setup & usage instructions, please check the documentation in our developer portal. Below you'll find a short summary of steps required to get started quickly.

Installation

Theme:

# npm
npm install @slashid/docusaurus-theme-slashid
# yarn
yarn add @slashid/docusaurus-theme-slashid

Configuring docusaurus.config.js

After installing the app and signing up with SlashID go through the following steps in order.

Adding the styles

Include the login form styles:

// under presets

{
    theme: {
        customCss: [
            require.resolve("@slashid/react/style.css"), // add this line
        ],
    }
}

Adding the Auth button

You can render a button in the navbar to allow customers to log in. To do so, add this item to the navbar.items field in the themeConfig:

{
  // ...
  themeConfig: ({
    // ...
    navbar: {
      // ...
      items: [
        // ...
        {
          type: "custom-AuthButton",
          position: "right",
          className: "button button--secondary button--lg",
        },
      ],
    },
  });
}

Configure the theme

Add the following to the themeConfig in docusaurus.config.js:

// docusaurus.config.js

{
  ...

   themeConfig:
    /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
     ({
      ...
      slashID: {
        orgID: "your slash id org id",
        forceLogin: "boolean flag to determine if login is required",
        baseURL: "optional base API URL for the SDK, defaults to the production environment",
        sdkURL: "optional base SDK page URL for the SDK, defaults to the production environment",
        privatePaths: [
          {
            path: "a glob or a regex specifiying the path to protect",
            groups: ["optional list of groups that can access the path"],
          }
        ],
        formConfiguration: {
          // authentication methods presented to end users
          factors: [{ method: "email_link" }],
          // logo you want to display on the login form
          logo: "<YOUR_LOGO_URL>",
          // customisable text content
          text: {
            "initial.title": "/id Docusaurus login theme",
          },
        },
      },

    themes: ["@slashid/docusaurus-theme-slashid"],
  }
}

The configuration options are explained in the following section.

Theme Configuration Options

The docusaurus-theme-slashid theme can be configured with the following options:

| Name | Type | Default | Description | | --------------------------- | --------------------- | ----------- | ---------------------------------------------------------------------- | | slashID.orgID | string | null | The SlashID organization ID. | | slashID.forceLogin | boolean | false | Make login required. | | slashID.baseURL | boolean | false | Base API URL for the SDK, defaults to the production environment. | | slashID.sdkURL | boolean | false | Base SDK page URL for the SDK, defaults to the production environment. | | slashID.uxMode | redirect or modal | redirect | Behaviour when accessing a private path when unauthenticated. | | slashID.privatePaths | PrivatePath[] | undefined | Optional set of private paths. | | slashID.formConfiguration | object | undefined | Optional form configuration |

Form configuration

As mentioned in the above table, it is possible to customise the login form by passing in the slashID.formConfiguration object. The values sent here are the same ones that can be passed to the <ConfigurationProvider>. This lets you specify the authentication methods displayed to your users, customise the UI by swapping the text constants and the logo.

Interface: PrivatePath

A private path is a path that requires authentication to access. The slashID.privatePaths option is an array of PrivatePath objects.

interface PrivatePath {
  path: string; // a glob or a regex specifiying the path to protect
  groups?: string[]; // optional list of groups that can access the path
}

Page level configuration

The theme can be configured at the page level using front matter to pass sidebar_custom_props.

sidebar_custom_props:
  slashid:
    auth: true
    groups:
      - member

The above configuration will require the user to be authenticated and belong to the member group to view the page. groups property is optional and if not specified, the user only needs to be authenticated to view the page.

Support

Please read SUPPORT.md for details on how to get support for this project.