Closed whl88 closed 5 years ago
我已经解决了,将图片转成base64 编码的形式就行。 我平时使用Webstorm 写博客,为此装了一个图片转base64的插件,很好用。
@whl88 base64确实不错,但是也存在一些弊端。如果想继续使用post_asset_folder,可以参照官方文档: 资源文件夹
@shenliyang 参照官方文档我将Front-matter写成如下样子,会报错。
---
title: xxxxxxxxxx
comments: true
categories:
- 前端
tags:
- Matomo
date: 2018-12-23 12:41:05
img: {% asset_img 500458875_wx.jpg This is an example image %}
---
报错信息如下:
ERROR Process failed: _posts/Matomo-Javascript-方式追踪-自定义变量.md
YAMLException: missed comma between flow collection entries at line 10, column 7:
img: {% asset_img 500458875_wx.jpg Thi ...
^
at generateError (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:165:10)
at throwError (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:171:9)
at readFlowCollection (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:691:7)
at composeNode (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1333:11)
at readBlockMapping (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1062:11)
at composeNode (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1332:12)
at readDocument (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1492:3)
at loadDocuments (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1548:5)
at Object.load (E:\workspace\front\whl88.github.io\node_modules\js-yaml\lib\js-yaml\loader.js:1569:19)
at parseYAML (E:\workspace\front\whl88.github.io\node_modules\hexo-front-matter\lib\front_matter.js:80:21)
at parse (E:\workspace\front\whl88.github.io\node_modules\hexo-front-matter\lib\front_matter.js:56:12)
at Promise.all.spread (E:\workspace\front\whl88.github.io\node_modules\hexo\lib\plugins\processor\post.js:51:20)
at tryCatcher (E:\workspace\front\whl88.github.io\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (E:\workspace\front\whl88.github.io\node_modules\bluebird\js\release\promise.js:509:35)
at Promise._settlePromise (E:\workspace\front\whl88.github.io\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (E:\workspace\front\whl88.github.io\node_modules\bluebird\js\release\promise.js:614:10)
所以不得已,采用了base64实现。
非常感谢您的付出和分享。 请教您一个问题,我打开了配置中的post_asset_folder: true | 启动 Asset 文件夹,希望与文章有关的图片都放到自己的资源文件夹里面,请问缩略图如果放到资源文件夹,怎么引用?