question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot render markdown strings stored in a yaml file

See original GitHub issue

Environment


  • Operating System: Linux
  • Node Version: v16.18.0
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.19.2
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. yaml file in the content folder with a key value pair that contains markdown syntax (~/content/file.yml)
    • title: test file
    • description: this has **markdown**
  2. access the data in the vue template:
let { data } = await useAsyncData(() => { return queryContent("file".findOne();
  1. Render the description into html:
<p><ContentRendererMarkdown :value="data.description" />

Output:

Describe the bug

The hope is to be able to send the markdown syntax into the template from the yaml file as just a string and to render it.

I’ve tried a few ways, this felt like it would have been the most logical however it doesn’t convert the markdown into html.

Additional context

A major reason for why we are using this workflow is to integrate with Netlify CMS as a simple UI for non-technical contributors to help out (this is for a website for the Fedora Project).

Logs

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
farnabazcommented, Oct 27, 2022

This is not possible at the time, supporting this feature means that we should ship whole markdown parser into browser which creates two issues:

  • Increasing bundle size
  • Increase render time and affects website’s performance

If you have a specific structure and you want to render markdown from description field. You can create custom transformer for .yaml files and parse the field, then you will be able to use ContentRendererMarkdown to render the description.

Here is simple example:

import { defineTransformer, transformContent } from '@nuxt/content/transformers'
export default defineTransformer({
  name: 'my-transformer',
  extensions: ['.yaml'],
  async parse (id, rawContent) {
    const yamlObject = transformContent(id, rawContent)
    if (yamlObject.description) {
      yamlObject._description = await transformContent('content:dummy.md', yamlObject.description)
    }
    return yamlObject
  }
})
0reactions
ManasMadrechacommented, Nov 17, 2022

@farnabaz Oh, so in V2, it’s more intelligent, nice 😋 thanks for the detailed information and your invaluable contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to output data from Yaml variables (written in markdown ...
You have a string that contains markdown, and you want to render that markdown and include the result in your output.
Read more >
YAML: The Missing Battery in Python
In this tutorial, you'll learn all about working with YAML in Python. By the end of it, you'll know about the available libraries, ......
Read more >
SSM document data elements - AWS Systems Manager
This topic describes the data elements used in Command and Automation SSM documents. The schema version used to create a document defines the...
Read more >
YAML & Markdown | Quire
Content is stored in two different plain-text formats in Quire: YAML (yam-ul) for data, and Markdown for more narrative or textual content.
Read more >
Configuration - Grav Documentation
All Grav configuration files are written in YAML syntax with a .yaml file ... used to render the site, page ordering, twig and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found