Socket
Socket
Sign inDemoInstall

hexo-insert-markdown

Package Overview
Dependencies
254
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hexo-insert-markdown

A Hexo plugin that allows you to insert Markdown files in your posts.


Version published
Weekly downloads
34
increased by70%
Maintainers
1
Install size
7.59 kB
Created
Weekly downloads
 

Changelog

Source

1.4.4 (2022-08-15)

Bug Fixes
  • Remove log statement (3dca8975)

Readme

Source

hexo-insert-markdown

A Hexo plugin that allows you to insert Markdown files in existing Markdown files.

Installation

  1. Add this plugin to your Hexo site with npm install hexo-insert-markdown --save
  2. Insert the {% insertmd %} tag in your posts or pages to include Markdown content from files
  3. Rebuild your site to see the effect of this plugin: hexo clean && hexo generate

Note: The path to file includes must be relative to the source directory of your Hexo installation. Files in subdirectories of the specified path will also be inserted.

Usage

Insert Markdown file

Open your Markdown file (a post or page) and include this custom tag:

{% insertmd your/file.md %}

Insert separator

If you want to specify a custom separator, that is rendered after each include, you can use:

{% insertmd your/file.md '---' %}

Insert Markdown files from directory

Include all Markdown files from a directory (and its subdirectories):

{% insertmd your/directory/with/includes '---' %}

Insert TOC on top of includes

If you want to render a table of contents (TOC) on top of your includes, you have to supply an empty object ({}) as third parameter to insertmd:

{% insertmd your/directory/with/includes '---' '{}' %}

All options from the hexo-util tocObj are supported, so you can define the minimum and maximum level of TOC headings:

{% insertmd error-ts/includes '---' '{ "max_depth": 2 }' %}

It works without using a separator too:

{% insertmd error-ts/includes '{ "max_depth": 2 }' %}

Note: The TOC options must be valid JSON (curly braces around objects and double quotes around property names).

FAQ

What was your motivation?

This plugin was inspired by hexo-include-markdown. It extends its functionality with syntax highlighting for code blocks.

Why is this plugin using tags ({% ... %}) instead of helpers (<%- ... %>)?

Helpers cannot be used in source files (source) which is why this plugin uses tags.

How can I embed code?

To include code (JavaScript, TypeScript, etc.) you can use Hexo's built-in codeblock or include_code syntax. It works like this:

{% include_code lang:javascript my-code.js %}

Note: Your code files must be stored in the source/downloads/code directory of your Hexo blog.

Keywords

FAQs

Last updated on 15 Aug 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc