中文教程的图片改为外置附件形式
-
可以看看 https://tw-cn.netlify.app/#布局 里的图片,都是外置的了。
我添加了 tidgi-external-attachments 插件,在使用太记编辑知识库时,拖入的图片会在点击「导入」后自动被移动到知识库文件夹内的
/files
文件夹里。然后我添加了一个
$:/core/templates/canonical-uri-external-image
条目title: $:/core/templates/canonical-uri-external-image <!-- This template is used to assign the ''_canonical_uri'' field to external images. Change the `./images/` part to a different base URI. The URI can be relative or absolute. --> images/<$view field="title" format="urlencoded"/>
(太微核心里的原版是
doubleurlencoded
,会导致 netlify 发布的网站加载不了图片,因为文件名被多 urlencod 了一次,我这里改成了正确的urlencoded
)构建的时候在
scripts/build.js
里用' --setfield \'[is[image]] [is[binary]] +[!has[_canonical_uri]]\' _canonical_uri $:/core/templates/canonical-uri-external-image text/plain' + ' --setfield \'[is[image]] [is[binary]] +[!has[_canonical_uri]]\' text "" text/plain'
[!has[_canonical_uri]]
让它只对以前拖进 wiki 内置的图片生效,把它们变成外置。对于新的用太记外置插件自动外置了的,就不要影响了。