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

henshu-app

v1.0.3

Published

App wrapper for Henshu

Downloads

4

Readme

Henshu App

A dashboard workflow that provides services to an app that uses Henshu. The backend for Henshu App is Firebase, using Google for authentication, Firestore for storing the content collections, and Storage for keeping the uploaded images from the <henshu.img> tag.

Henshu App is just a workflow wrapper around Henshu itself, meaning that you would just write your Henshu site how you normally would while letting Henshu App do the heavier lifting to manage the data lifecycle.

Documentation

Install

yarn add henshu-app henshu firebase

then

import { HenshuApp, useHenshuApp } from 'henshu-app';

Add environment variable to your build command

In order for Henshu App to show the published version and disable the dashboard, you must add the following environment variable to your build command:

// if using create-react-app
"scripts": {
	"build": "REACT_APP_HENSHU_ENV=production react-scripts build",
}

Usage

There is more to it, if you need, but the only requirement to setup Henshu App is to provide your Firebase config to the provider component.

const App = () => {
	return (
		<HenshuApp config={firebaseConfig}>
			{/* App */}
		</HenshuApp>
	)
};

Workflow: Using the dashboard

To enter the dashboard, use Shift+'~'.

Once in the dashboard, you can start editing content. After making edits, you should press that 'save' button in the bottom panel. Once you are comfortable with how the draft copy has come along, you can press the 'publish' button to snapshot the draft into a separate Firestore collection, which is loaded by the production build.

API

The Provider

Langs: string[]

Adds a language selection dropdown to the dashboard. The selector allows the editor to switch between languages, which is kept in Firestore as separate documents. The languages provided in the array should be ISO-639-1. Each language is saved and published independently If no langs are provided, the default language is 'default'.

Seeds: {[string]: {[string]: string}}

Adds a seed button to your dashboard in the development environment. Useful for keeping a known good copy of your key/value terms to reseed the database during development. The first key/value is the language associated with it's key/value set of terms.

Example

const seeds = {
	'en': {
		'intro.header': 'Welcome',
		'intro.body': 'This is an application'
	},
	'es': {
		'intro.header': 'Bienvenidos',
		'intro.body': 'Esta es una aplicación',
	}
};

The Context

The shared context can be access through the useHenshuApp() hook. Through this hook, you can access just about all of the functionality behind Henshu App that you might need to augment how Henshu App works or how your website can become more customized depending on the current state of the dashboard.

Top Level

const { 
   isProductionBuild // boolean: Whether the REACT_APP_HENSHU_ENV env variable has been set to 'production'
	isEditing,        // boolean: Whether the user is logged in and the app is in edit mode
	setEditing,       // (isEditing: boolean) => void: Set whether editing is enabled (user must be logged in for the set value to matter)
	lang,             // string: The current language
	setLang,          // (lang: string) => void: Set the current language
	content,          // {[string]: string}: A key/value map of the current language's content
	setContent,       // (content: {[string]: string}) => void: Update the content object
	persist,          // PersistStore: The layer that handles loading and saving content
	user,             // UserStore: The layer that manages the user state in the dashboard
} = useHenshuApp();

Persist Store

const { persist: {
	save,    // () => Promise<void>: Snapshots the current content object to its Firestore document
	publish, // () => Promise<void>: Snapshots the current content object to the 'publish' Firestore collection
	upload,  // (blog: string) => Promise<string>: Stores a data URI string in Firebase storage and returns the public URL to load the asset.
}} = useHenshuApp(); 

User Store

const = { user: {
	login,       // () => Promise<void>: Launches a Google sign-in popup
	logout,      // () => Promise<void>: Deauthorizes the current session
	user,        // User|null: A Firebase User object or null
	setUser,     // (user: User|null) => void: Sets the user instance
	displayName, // string: The users displayName, derived from the user object
	isLoggedIn,  // boolean: Whether the user is present or not
}} = useHenshuApp();