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

@elderjs/plugin-markdown

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elderjs/plugin-markdown - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

54

index.js

@@ -30,9 +30,16 @@ const glob = require('glob');

remarkHtml,
plugin.config.useSyntaxHighlighting && [
require('./rehype-shiki'),
typeof plugin.config.useSyntaxHighlighting === 'boolean' ? {} : plugin.config.useSyntaxHighlighting, // its an options object
],
];
}
if (plugin.config.useSyntaxHighlighting) {
const rehypeShiki = require('./rehype-shiki');
let rehypeShikiConfig = {};
if (typeof plugin.config.useSyntaxHighlighting !== 'boolean') {
rehypeShikiConfig = plugin.config.useSyntaxHighlighting;
}
plugin.config.remarkPlugins.push(
[rehypeShiki, rehypeShikiConfig]
);
}
plugin.markdownParser = prepareMarkdownParser(plugin.config.remarkPlugins);

@@ -59,24 +66,25 @@

const { data, contents } = await plugin.markdownParser.process(md);
const { frontmatter } = data;
const { data, contents: html, data: { frontmatter } } = await plugin.markdownParser.process(md);
let slug;
if (data && data.frontmatter && data.frontmatter.slug) {
plugin.markdown[route].push({
slug: frontmatter.slug,
frontmatter: data.frontmatter,
html: contents,
});
plugin.requests.push({ slug: frontmatter.slug, route });
} else {
let fileSlug = file.replace('.md', '').split('/').pop();
if (fileSlug.includes(' ')) {
fileSlug = fileSlug.replace(/ /gim, '-');
if (plugin.config.slugFormatter && typeof(plugin.config.slugFormatter) === 'function') {
let relativePath = file.replace(`${mdsInRoute}/`, '');
slug = plugin.config.slugFormatter(relativePath, frontmatter);
}
if (typeof(slug) !== 'string') {
if (frontmatter && frontmatter.slug) {
slug = frontmatter.slug;
} else {
slug = file.replace('.md', '').split('/').pop();
if (slug.includes(' ')) {
slug = slug.replace(/ /gim, '-');
}
}
plugin.markdown[route].push({
slug: fileSlug,
frontmatter,
html: contents,
});
plugin.requests.push({ slug: fileSlug, route });
}
plugin.markdown[route].push({
slug,
frontmatter,
html,
});
plugin.requests.push({ slug, route });
}

@@ -83,0 +91,0 @@

{
"name": "@elderjs/plugin-markdown",
"version": "0.1.14",
"version": "0.1.15",
"description": "Easily create routes from your markdown files on your Elder.js site using the remark ecosystem.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -21,2 +21,6 @@ # Elder.js Plugin: Markdown

routes: [], // if all of your markdown lives in ./src/routes/blog/, you'd add 'blog' to this array.
slugFormatter: function(relativeFilePath, frontmatter) {
return false; // If needed, a custom slug for the url can be crafted from the relative path to the file and
// frontmatter in it (if any). slugFormatter must be a function and must return a string to be used.
},
useSyntaxHighlighting: false // This plugin ships with syntax highlighting ability for your convenience. Recommend setting true for technical blogs. See below for customizing options

@@ -23,0 +27,0 @@ }

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