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

@springernature/util-package-renderer

v3.3.1

Published

Renders a package that passes SN package validation

Downloads

497

Readme

Package Renderer

Renders an Elements-compatible package into HTML with all resources inlined.
Optionally write the result to disk as index.html.

NOTE: As of v3.0.0 this package works with dart-sass, for node-sass support please continue using v2.2.2

Usage

const renderer = require('@springernature/util-package-renderer');
await renderer(config);

Config

| Parameter | Default Value | Type | Required | Description | |---------------------------------|---------------------------------|----------|----------|----------------------------------------------------------| | config.demoCodeFolder | demo | String | Yes | Name of demo code folder within your package | | config.brandContext | @springernature/brand-context | String | Yes | Name of the brand-context package on NPM | | config.reportingLevel | title | String | Yes | Amount of reporting for util-cli-reporter | | config.dynamicTemplateLocation | . | String | Yes | Where to start looking for dynamic handlebars templates | | config.minify | false | Boolean | Yes | Minify the JS and CSS output | | config.packageRoot | . | String | Yes | Path to the package to render | | config.distFolderPath | null | String | No | Path to where index.html should be written |

Full examples

A working implementation can also be found in runner.js.

Using default config

'use strict';
const renderer = require('@springernature/util-package-renderer');

// By default no distFolder is defined and the result is returned as a String
(async () => {
	try {
		const result = await renderer();
		console.log(result);
	} catch (error) {
		console.error(error);
	}
})();

Return result as String, with config

const path = require('path');
const renderer = require('@springernature/util-package-renderer');

const fulldir = path.resolve(__dirname, 'apackage');
const demoFolderName = 'demo';
const brandContext = '@springernature/brand-context';

(async () => {
	try {
		const result = await renderer({
			demoCodeFolder: demoFolderName,
			reportingLevel: 'title',
			dynamicTemplateLocation: './path/to/location'
			minify: true,
			packageRoot: fulldir,
			brandContext: brandContext
		});
		console.log(result);
	} catch (error) {
		console.error(error);
	}
})();

Write result to disk, with config

const path = require('path');
const renderer = require('@springernature/util-package-renderer');

const fulldir = path.resolve(__dirname, 'apackage');
const demoFolderName = 'demo';
const brandContext = '@springernature/brand-context';
const distFolder = path.join(fulldir, 'dist');

(async () => {
	try {
		await renderer({
			demoCodeFolder: demoFolderName,
			reportingLevel: 'title',
			dynamicTemplateLocation: './path/to/location'
			minify: true,
			packageRoot: fulldir,
			brandContext: brandContext,
			distFolderPath: distFolder
		});
	} catch (error) {
		console.error(error);
	}
})();