【发布时间】:2022-02-04 00:39:21
【问题描述】:
这是 Nuxt 的纯静态实现。我正在使用从 yaml 内容文件(不是 markdown)中读取的 markdown 内容。由于内容在 json 对象中,因此它们使用$md.render(blog.content) 呈现。假设 blog.content 是一个 markdown 字符串。
模板如下:
...
<div v-html="$md.render(blog.content)></div>
...
nuxt.config.js 文件有以下内容:
export default {
target: static,
...
modules: [
'@nuxt/content',
'@nuxtjs/markdownit',
...
],
markdownit: {
runtime: true,
html: true,
},
...
}
这对常规 md 字符串按预期工作。
我想使用存储在博客页面图像子目录中的图像(不是来自资产或静态目录)。并在markdown字符串中引用它
内容目录的结构是:
content
blogs
blog1
images
b1i1.png
b1i2.png
content.yaml
blog2
images
content.yaml
...
markdown 字符串可能是这样的
# Study this Digaram
The following is a diagram
<img src="images/b1i1" alt="diagram"/>
有没有办法将此图像发送给 vue 以将其解析为生成图像的路径?谢谢
【问题讨论】: