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

strapi-markdown-parser

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-markdown-parser

Strapi controller module to parse Markdown to HTML

  • 0.0.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by166.67%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to strapi-markdown-parser 👋

License: MIT Twitter: self_agency

Strapi controller module to parse Markdown to HTML.

Install

yarn add strapi-markdown-parser

Use

Open your collection or single type's controller file (eg., ./api/{COLLECTION}/controllers/${COLLECTION}.js), and add the following, substituting your collection or single type's name in the place of {COLLECTION}:

const StrapiMarkdown = require('strapi-markdown-parser')
const model = require('../models/{COLLECTION}.settings.json')

const { md } = new StrapiMarkdown(model)

module.exports = {
  async find(ctx) {
    const data = await strapi.services.{COLLECTION}.find(ctx.query)

    return md(data)
  },
  async findOne(ctx) {
    const { id } = ctx.params
    const data = await strapi.services.{COLLECTION}.findOne({ id })

    return md(data)
  }
}

Full Parameters

const { md } = StrapiMarkdown(model, types, options)
model

JSON object containing your model's settings, eg. ./api/{collection}/models/{collection}.settings.json.

types

Either an object or array specifying the types in your collection's model to transform to HTML. If an array, all fields will be treated as standard markdown and therefore paragraphs will be wrapped in <p> tags. If an object, types specified under standard will be wrapped in <p> tags, an those specified inline will not.

Defaults:

{
  standard: ['richtext'],
  inline: ['string']
}
options

Uses Marked as a parser and therefore options correspond to the Marked API.

Defaults:

{
  smartypants: true,
  headerIds: false,
  breaks: true
}

Known Issues

  • Does not currently work on Strapi components, only top-level fields. Component support to come.

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

FAQs

Package last updated on 01 Mar 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