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

gitbook-plugin-theme-code

v0.0.24

Published

A GitBook theme for websites focusing on code

Downloads

5

Readme

GitBook Theme - for websites focusing on code

This is based on the default theme for GitBook since version 3.0.0. Currently there are no big changes but some bug fixes and a site title added to the top of the sidebar.

An example snapshot:

Image

Example configuration (book.json):

{
  "title": "Site Title",
  "author": "Author Name",
  "authorHomepage": "http://www.example.com",
  "baiduStatisticsCode": "",
  "description": "site description",
  "language": "zh-hans",
  "copyright": "All Rights Reserved",
  "variables": {
    "homePage": "/"
  },
  "plugins": [
    "theme-code",
    "splitter",
    "prism",
    "folding-chapters",
    "-sharing"
  ],
  "pluginsConfig": {
    "theme-default": {
      "showLevel": true
    }
  }
}

To developers

If you want to develop GitBook theme and publish it to npm repository, you should name your package to somewhat like gitbook-plugin-theme-themename. For details, please refer to the official online document. Here are some tips for you.

Tip 1: Test your plugin locally

In the plugin's folder, run:

npm link

Then in your book's folder:

npm link gitbook-plugin-plugin-name

Tip 2: build on base of default official theme for GitBook

Actually, this project is also built on base of the GitBook Default Theme. However, if you want to use the default theme, you should remember to fix two bugs showed bellow (At first I would like to send a pull request to the author of that project, but when I open its github page, I found many PR unhandled, so I planned not to waste my time -_-):

In the file src/js/theme/navigation.js, you could find code like this:

// Get current page summary chapters
$chapters = $('.book-summary .summary .chapter')
    .filter(function() {
        var $link = $(this).children('a'),
            href  = null;
    
        // Chapter doesn't have a link
        if (!$link.length) {
            return false;
        }
        else {
            href = $link.attr('href').split('#')[0];
        }
    
        var resolvedRef = url.resolve(window.location.pathname, href);
        return window.location.pathname == resolvedRef;
    });

You should replace the code window.location.pathname == resolvedRef; to decodeURIComponent(window.location.pathname) == decodeURIComponent(resolvedRef).

The bug can be repeated if your url in the browser contains special characters such as Chinese, because equality judgement in the code will fail in that case: window.location.pathname will get the encoded characters, while $link.attr('href') will get the original characters.

Here is another bug, in _layouts/website/summary.html:

{% if article.path or article.url %}
    </a>
{% else %}
    </span>
{% endif %}

The code above should be replaced by the code below:

{% if (article.path and getPageByPath(article.path)) or article.url %}
    </a>
{% else %}
    </span>
{% endif %}

Otherwise, you will find sometime the HTML tag SPAN is closed by tag A.