https://github.com/danielmahon/gatsby-remark-widows
Gatsby plugin for gatsby-transformer-remark to remove widows in text nodes.
https://github.com/danielmahon/gatsby-remark-widows
Last synced: about 1 year ago
JSON representation
Gatsby plugin for gatsby-transformer-remark to remove widows in text nodes.
- Host: GitHub
- URL: https://github.com/danielmahon/gatsby-remark-widows
- Owner: danielmahon
- Created: 2018-04-14T21:12:26.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-14T21:26:20.000Z (about 8 years ago)
- Last Synced: 2025-04-11T12:49:29.674Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/gatsby-remark-widows
- Size: 19.5 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```javascript
// 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`
```javascript
// 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