Socket
Socket
Sign inDemoInstall

@metalsmith/excerpts

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metalsmith/excerpts

A Metalsmith plugin to extract an excerpt from HTML files.


Version published
Weekly downloads
12
increased by20%
Maintainers
3
Weekly downloads
 
Created
Source

@metalsmith/excerpts

A Metalsmith plugin to extract an excerpt from HTML files.

metalsmith: core plugin npm: version ci: build code coverage license: MIT

Installation

NPM:

npm install @metalsmith/excerpts

Yarn:

yarn add @metalsmith/excerpts

Usage

The excerpt is scraped from the first paragraph (<p> tag) of the rendered HTML contents of a file and added to its metadata excerpt key.

const excerpts = require('@metalsmith/excerpts')

metalsmith.use(excerpts()) // default -> file.excerpt
metalsmith.use(excerpts({ multipleFormats: true })) // -> file.excerpt.html & file.excerpt.text

Custom excerpts

You can define a custom excerpt in the front-matter of specific files:

---
excerpt: This will be the excerpt
---

This would be the excerpt if none was specified in the front-matter

Excerpts with tags stripped

Sometimes you may need access to the text content of the excerpt without HTML tags. Pass the multipleFormats: true option to store an excerpt object with both HTML and text excerpts { html: '...', text: '...' }:

metalsmith.use(excerpts({ multipleFormats: true }))

CLI usage

Add the @metalsmith/excerpts key to your metalsmith.json plugins key:

{
  "plugins": [{ "@metalsmith/excerpts": { "multipleFormats": false } }]
}

License

MIT

Keywords

FAQs

Package last updated on 17 Dec 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc