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

eleventy-nbsp-filter

v0.1.0

Published

Filter for Eleventy to replace spaces between words with   characters

Downloads

29

Readme

eleventy-nbsp-filter

Build Status

🛸 Filter for Eleventy to replace spaces between words with   characters.

Motivation

Sometimes it happens that titles move to a next line leaving one short word alone, one solution is to add a   entity instead of a normal space character, but doing this on your content files might not be ideal since then you need to escape that character in other places you consume that data.

I found myself polluting my titles with this character to then remove it, what if I just had a filter where given a title and a certain safe length of characters this gets done automatically, preserving the title as it is? This is why eleventy-nbsp-filter exists.

Install

# npm
npm i eleventy-nbsp-filter --save

# yarn
yarn add eleventy-nbsp-filter

Add the filter

Include the filter in your Eleventy project.

// .eleventy.js
const nbspFilter = require('eleventy-nbsp-filter')

const numberOfWordsToJoin = 2
const maxLength = 10

module.exports = function(eleventyConfig) {
  eleventyConfig.addFilter('nbsp', nbspFilter(numberOfWordsToJoin, maxLength))
}

The filter will add the last two words of a tet value, only if they don't pass the amount of ten characters together. You can pass any configuration that adapts to your needs.

Apply it

<h1>{{ page.title | nbsp }}</h1>

And that's it! Keep reading to understand why you need to pass some numbers to the filter.

How it works

The filter will require you to define how many words you want to join and the maximum number of characters which is safe to join, this is in order to avoid text to overflow the viewport.

So, let's say you add a filter with the config exactly like the example above.

If the filter receives this text, There is a place where the sidewalk ends it will bail out on adding the &nbsp; character because we said we wanted 2 words to be joint, but those together are 12 characters and we passed 10 as the maximum length.

Now if we pass this text, We'll walk with a walk that is measured and slow, then the result will be We'll walk with a walk that is measured and&nbsp;slow because the last two words sum to 7 characters, then the filter acts.

The config is an extra weight-lifting you need to do, but provides a safer and more adaptable distribution of itself to better adjust your needs regarding this super nitpicky action.

Text excerpts are taken from Shel Silverstein's poem "Where the Sidewalk Ends".

Contributing

To contribute Node.js and yarn are required.

Before commit make sure to follow conventional commits specification and check all tests pass by running yarn test.