![pnpm 9.5 Introduces Catalogs: Shareable Dependency Version Specifiers](https://cdn.sanity.io/images/cgdhsj6q/production/c06a5b74512bcc6da29d38cef96a454fa947810d-1024x1024.webp?w=400&fit=max&auto=format)
Security News
pnpm 9.5 Introduces Catalogs: Shareable Dependency Version Specifiers
pnpm 9.5 introduces a Catalogs feature, enabling shareable dependency version specifiers, reducing merge conflicts and improving support for monorepos.
@sanity/block-content-to-markdown
Advanced tools
Readme
Render an array of block text from Sanity to markdown.
Note: Currently in beta - please leave us feedback :)
npm install --save @sanity/block-content-to-markdown
const toMarkdown = require('@sanity/block-content-to-markdown')
const client = require('@sanity/client')({
projectId: '<your project id>',
dataset: '<some dataset>',
useCdn: true
})
const serializers = {
types: {
code: props => '```' + props.node.language + '\n' + props.node.code + '\n```'
}
}
client.fetch('*[_type == "article"][0]').then(article => {
console.log(toMarkdown(article.body, {serializers}))
})
serializers
- Specifies the functions used for rendering content. Merged with default serializers.serializers.types
- Serializers for block types, see example aboveserializers.marks
- Serializers for marks - data that annotates a text child of a block. See example usage below.serializers.list
- Function to use when rendering a list nodeserializers.listItem
- Function to use when rendering a list item nodeserializers.hardBreak
- Function to use when transforming newline characters to a hard breakimageOptions
- When encountering image blocks, this defines which query parameters to apply in order to control size/crop mode etc.In addition, in order to render images without materializing the asset documents, you should also specify:
projectId
- The ID of your Sanity project.dataset
- Name of the Sanity dataset containing the document that is being rendered.const input = [
{
_type: 'block',
children: [
{
_key: 'a1ph4',
_type: 'span',
marks: ['s0m3k3y'],
text: 'Sanity'
}
],
markDefs: [
{
_key: 's0m3k3y',
_type: 'highlight',
color: '#E4FC5B'
}
]
}
]
const highlight = props => {
const content = Array.isArray(props.children) ? props.children.join('') : props.children
return `<span style="background-color: ${props.mark.color};">${content}</span>`
}
toMarkdown(input, {serializers: {marks: {highlight}}})
toMarkdown(input, {
imageOptions: {w: 320, h: 240, fit: 'max'},
projectId: 'myprojectid',
dataset: 'mydataset'
})
MIT-licensed. See LICENSE.
FAQs
Unknown package
We found that @sanity/block-content-to-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
pnpm 9.5 introduces a Catalogs feature, enabling shareable dependency version specifiers, reducing merge conflicts and improving support for monorepos.
Security News
A threat actor on BreachForums is selling an unverified npm vulnerability for account takeover, but npm has not officially confirmed the existence of this security concern.
Security News
Cyber insurance rates are dropping as the market matures, according to a new report projecting global premiums to reach $43 billion by 2030, driven by international market uptake and growth in the SME sector.