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

@flexdemo/guides-react

v0.0.12

Published

A Component that will display guides as part of a documentation

Downloads

3

Readme

Guides React

A React component that will render small help guides.

Quickstart

import { Guides } from "guides-react";
//...
<App>
  <Guides logo={<h1>Some Awesome Logo</h1>} footer={<span>Imprint</span>} placeholder={"Search"} />
</App>;
//...

Examples

Basic usage

  1. Install and start the guides-backend server
  2. Include component in your app
import { Guides } from "guides-react";
//...
<App>
  <Guides logo={<h1>Some Awesome Logo</h1>} footer={<span>Imprint</span>} placeholder={"Search"} />
</App>;
//...
  1. Build your App with REACT_APP_GUIDES_API_URL Environment Variable set to the appropriate Backend URL

Usage without a Server

import { Guides } from "guides-react";
const guides = [
  {
    internalName: "guide_1.md",
    content:
      "# Usage without a Server\nUsing guides-react without a server is fairly simple, but writing and inserting guides is not very confortable",
  },
];
//...
<App>
  <Guides logo={<h1>Some Awesome Logo</h1>} footer={<span>Imprint</span>} placeholder={"Search"} guides={guides} />
</App>;

Storybook

This component contains Storybook examples. To run the Storybook clone the repository and run npm run storybook.

Do note, that the Storybook requires differently prefixed environment variables, as REACT_APP_* variables do not work. All environment variables can also be provided with the STORYBOOK_ prefix. For example REACT_APP_GUIDES_API_URL can also be provided with STORYBOOK_GUIDES_API_URL .

Backend

This component is designed to work with the guides-backend server, which can be used to supply the guides and provide a indexed search of these guides.

It is also possible to use a custom Backend, or no backend at all. See the examples for further information.

Response Timeouts

This library tracks likes and dislikes for documents, but only in a very limited fashion. No use accounts are necessary, but to prevent abuse of the likes and dislikes a timeout can be set in which the same document can not be likes or disliked again. By default this timeout is 5 Minutes, but it can be changed by setting the REACT_APP_GUIDES_RESPONSE_TIMEOUT variable to a string like 5M or 30S. See moment.js for more information uon duration parsing. (The "PT" is appended by default)

Custom backend

It is also fairly easy to implement the required backend routs yourself, this section will describe the required routes, parameters and results.

/docs [GET]

Requests a List of all available documents.

Parameters: None

Result:

| Name | Value | | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Content-Type | application/json | | Return Code | 200 | | Expected Content | [{filename: string // the full name of the file (relativ to the backend server key: string //The name of the file without any prefix or suffix }] |

Note: This route can be redirected by setting the REACT_APP_GUIDES_DOCS_ROUTE environment variable to the appropriate route. The default is docs (no / prefix)

/search/:query [GET]

Requests a List of all available documents that match the given query.

Parameters:

| Name | Type | value | | ----- | ------ | ----------------------- | | query | string | The query to search for |

Result:

| Name | Value | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Content-Type | application/json | | Return Code | 200 | | Expected Content | [{filename: string // the full name of the file (relativ to the backend server key: string //The name of the file without any prefix or suffix count: number // value for ranking the result -> the higher the better }] |

Note: This route can be redirected by setting the REACT_APP_GUIDES_SEARCH_ROUTE environment variable to the appropriate route. The default is search (no / prefix)

/document uri [GET]

Requests the content of the document. The exact URL depends on the result of the /docs query, more specific on the filename field.

Parameters: None

Result:

| Name | Value | | ------------ | ----- | | Content-Type | text | | Return Code | 200 |

/like/doc_key and /dislike/doc_key [POST]

Likes or dislikes to specified document. The values of these likes and dislikes do not need to be public. They mainly serve the purpose of giving the document writer feedback over good and bad documents.

Note: These routes can be redirected by setting the REACT_APP_GUIDES_LIKE_ROUTE or REACT_APP_GUIDES_DISLIKE_ROUTE environment variable to the appropriate route. The default is like and dislike (no / prefix or /doc_key postfix)

Parameters:

| Name | Type | value | | ------- | ---- | ----------------------------------- | | doc_key | url | The key returned by the /docs route |

Result:

| Name | Value | | ------------ | ----- | | Content-Type | text | | Return Code | 200 |