#Entries from a custom content loader return no HTML when using render()

8 messages · Page 1 of 1 (latest)

devout token
#

I'm working on a custom content loader for taking word documents and converting them to markdown. The current setup converts them from .docx to .html and then the .html is converted to markdown.

Adding them to the store looks like this:

// this happens inside of a node:glob, using mammoth.js and turndown for the conversion pipeline
for await (const match of matches) {
    const { value, messages } = await mammoth.convertToHtml({ path: match }, { styleMap: options.styleMap });
    if (messages.length) {
        messages.forEach((msg) => {
            logger.info(msg.message)
        });
    }
    const id = getId(match);
    const data = {
        match,
        id,
    };
    const digest = generateDigest({
        id,
        body: service.turndown(value),
        data
    });
    store.set({
        body: service.turndown(value),
        id,
        digest,
        data
    })
}

The docs made it seem like if there was a body with a valid markdown, then running render(entry) would give the Content, headings, etc. But when I run <Content /> it renders no html.

fading falcon
#

IIRC there’s a specific property that needs to be set to provide the HTML output, one sec.

#

Ah yeah, it’s rendered: { html }, so in your case something like this I think:

 store.set({
        rendered: { html: service.turndown(value) },
        id,
        digest,
        data
  })
devout token
#

Okay, we're closer but now it is just outputting the markdown as is no html tags

#

or are you saying pass the html to the rendered.html?

fading falcon
#

Yes! Sorry, wasn’t sure what that turndown method was doing

#

If value is already HTML then rendered: { html: value } should be all you need.