
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
solidjs-markdoc
Advanced tools
Render Markdoc syntax with SolidJS.
npm install solidjs-markdoc
You can provide simple markdown strings to the renderer to render Markdoc.
import Markdoc from "@markdoc/markdoc";
import render from "solidjs-markdoc";
function App() {
const md = `
# Hello World
We can render markdown.
`;
const ast = Markdoc.parse(md);
const content = Markdoc.transform(ast);
return render(content);
}
Setup a Markdoc schema.
schema/
āāā Alert.markdoc.ts
// schema/Alert.markdoc.ts
export default {
render: "Alert",
description: "Display the enclosed content in an alert box",
children: ["paragraph", "tag", "list"],
attributes: {
type: {
type: String,
default: "default",
matches: ["default", "info", "warning", "error", "success"],
},
},
};
Create your Solid component.
function Alert({ type, children }) {
return (
<div class={`alert alert--${type}`}>
{children}
</div>
);
}
Import the renderer and schema into your component.
import Markdoc from "@markdoc/markdoc";
import render from "solidjs-markdoc";
import alert from "./schema/Alert.markdoc";
function Alert({ type, children }) {
return (
<div class={`alert alert--${type}`}>
{children}
</div>
);
}
function App() {
//...
}
Create the config
to pass into your Markdoc.transform
call.
function App() {
const md = `
# Getting started
You can run SolidJS components in here.
Check this alert:
{% alert type="info" %}
Hey there! Something to look at!
{% /alert %}
`;
const config = {
tags: {
alert,
},
};
const ast = Markdoc.parse(md);
const content = Markdoc.transform(ast, config);
//...
}
Finally, return the result of the render
function making sure to supply your custom component to the render function's components
object.
function App() {
// ...
return render(content, {
components: {
Alert,
},
});
}
const alert = {
render: "Alert",
description: "Display the enclosed content in an alert box",
children: ["paragraph", "tag", "list"],
attributes: {
type: {
type: String,
default: "default",
matches: ["default", "info", "warning", "error", "success"],
},
},
};
function Alert({ type, children }) {
return (
<div class={`alert alert--${type}`}>
{children}
</div>
);
}
function App() {
const md = `
# Getting started
You can run SolidJS components in here.
Check this alert:
{% alert type="info" %}
Hey there! Something to look at!
{% /alert %}
`;
const config = {
tags: {
alert,
},
};
const ast = Markdoc.parse(md);
const content = Markdoc.transform(ast, config);
return render(content, {
components: {
Alert,
},
});
}
FAQs
SolidJS renderer for Markdoc
The npm package solidjs-markdoc receives a total of 6 weekly downloads. As such, solidjs-markdoc popularity was classified as not popular.
We found that solidjs-markdoc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.