Socket
Book a DemoInstallSign in
Socket

gatsby-remark-widows

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-remark-widows

Removes widows from text over 4 words

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

gatsby-remark-widows

Automatically adds a non-breaking space between the last 2 words in a text node parsed by gatsby-transformer-remark. This ensures there isn't a "widow", or single word left at the end of a wrapped sentance/paragraph.

Nulla et exercitation excepteur ullamco
eiusmod.

Lorem ipsum dolor sit Lorem irure aliquip magna labore qui
velit officia aliquip deserunt aliqua. Aute tempor fugiat nisi
adipisicing et aliquip sint minim cupidatat elit consequat
et.

:arrow_down:

Nulla et exercitation excepteur
ullamco eiusmod.

Lorem ipsum dolor sit Lorem irure aliquip magna labore qui
velit officia aliquip deserunt aliqua. Aute tempor fugiat nisi
adipisicing et aliquip sint minim cupidatat elit
consequat et.

Install

npm install --save gatsby-remark-widows

Currently uses \u00a0 to insert a space so you don't need to use dangerouslySetInnerHTML.
Your browser should™ render that as  

Warning: This currently effects every text node. You can limit by word count via the options.

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      // Probably best to place after other plugins
      plugins: [`gatsby-remark-widows`],
    },
  },
];

Options

You may set some options to configure which text nodes are processed by their word count. Defaults to minLength: 4

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [
        {
          resolve: 'gatsby-remark-widows',
          options: {
            minLength: 4, // default
            maxLength: null, // default
          },
        },
      ],
    },
  },
];

Todo

  • Add more options
  • Add tests

Keywords

gatsby

FAQs

Package last updated on 14 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.