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

@next-book/publisher

v1.0.2

Published

Publish web books with next-book

Downloads

17

Readme

Next-book publishing tool

@next-book/publisher is a tool for mapping HTML files for use with next-book tools. See an example, API documentations or a example book created with publisher, that builds functionalityon top of its markup: displaying and remembering position, tracing reader's journey through a book etc.

Use with node.js

Install in a book's repository (global installation is discouraged as publisher is in its early development and API changes are expected):

npm i @next-book/publisher

CLI use

Use publish-nb command, e. g.

publish-nb --src text --out book

Mapper reads all \*.html files in the source directory (--src, by default ./src), sorts them by filename, maps them and outputs the result into the output directory (--out, by default ./book).

It also creates a spine.json file that collects metadata about the book and adds several structural meta tags into files (prev, next, license, spine) that allow book traversal (with Javascript or native browser affordances).

It's required to include a book.json file in the source directory that adds metadata and a list of chapters. It's possible to specify static folders that will be copied from source to output as they are.

{
	"meta": {
		"title": "Free Culture",
		"author": "Lawrence Lessig",
		"subtitle": "How big media uses technology and the law to lock down culture and control creativity",
		"published": 2004,
		"keywords": ["copyright law", "intellectual property", "public domain", "web", "Napster"]
	},
	"chapters": [
		"01-preface.html",
		"02-introduction.html",
		"03-piracy.html",
		"04-property.html",
		"05-puzzles.html",
		"06-balances.html",
		"07-conclusion.html",
		"08-afterword.html",
		"09-acknowledgments.html"
	],
	"static": ["style", "scripts", "images"]
}

You can preview the book on a local web server by running the publish-nb with -w flag (or with --server param).

publish-nb --src text --out book --server

Use in browser

Download @next-book/publisher from npm or github and include it in your project files. Check the example with extensive highlighting to see how the result looks like.

<script type="text/javascript" src="./publisher/dist/browser.js"></script>
<script type="text/javascript">
	window.addEventListener('load', () => NbMapper.mapHtml());
</script>

Browser use is currently primarily for quick try-outs, not intended for production use.

Use in a Node.js script

Map HTML string or JSDOM objects in a script:

const html = '...';
const publisher = require('@next-book/publisher');
publisher.map(html);

Config the publisher with an options object publisher.map(html, conf), see API docs for Options.

Contributing

Clone repository and install devDependencies. Build a complete project with npm run build. Limit PRs only to changed source files.

License

@next-book/publisher © 2016–2020 next-book

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.