Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-related-links

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

gitbook-plugin-related-links

Handles related links for pages

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

This plugin manages related links for the Markdown files in your Gitbook. It retrieves the title for the links so you can just list the filename and not worry about changing files when your topic titles change.

The plugin takes file names from the front matter of a Markdown file, gets the titles from those files, and generates a related links section at the bottom of the file with links to each of those files. This keeps your related links sections consistent and keeps you from having to hard-code the titles of links to other pages in your Gitbook.

Notes:

  • This plugin currently supports only Markdown files, not AsciiDoc files.
  • To determine the title of a page, the plugin retrieves the first H1 in the file and uses its text. The plugin could be enhanced to use the title from front matter or from the summary file.
  • If the file name does not end in .md, the plugin copies the link to the related links section without changing anything. In this way you can specify custom link text as usual by using a standard Markdown link, or you can link to an external site by putting in a URL. However, to keep the YAML legal, you must surround Markdown links with single quotes. See the example below.

Installation

Add the plugin to your book.json:

{
  "plugins": [ "related-links" ],
  "pluginsConfig": {
     "header": "### Related topics"
  }
}

Then run gitbook install.

Configuration

  • header: Specify the heading under which to put the related links. The plugin adds this heading and an unordered list of links under it at the bottom of the Markdown file. The default is "### Related topics".

Example

Here's a Markdown file with some links in the front matter:

---
relatedLinks:
- myFile.md
- http://gitbook.com
- ../otherfiles/relatedFile.md
- '[My custom link text](someOtherFile.md)'
---
# Here's my file that needs related links

At build time, before Gitbook converts the Markdown to HTML, the plugin gets the link titles from the MD files in the front matter. The resulting file looks like this:

# Here's my file that needs related links

### Related links
- [My special file](myFile.md)
- http://gitbook.com
- [My related file](../otherfiles/relatedFile.md)
- [My custom link text](someOtherFile.md)

Tests

To run tests, run these commands:

npm install
npm run test

Contributing

  • See issue_template.md for information to submit in an issue.
  • Please refer to Shutterstock’s Code of Conduct for contributors.

License: MIT

Keywords

FAQs

Package last updated on 16 Oct 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

  • 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