褪尘矗心

Hexo 转至 Aomori 一些问题

对于我而言最高效的编辑 MarkDown 方式是文字编写和图片拖入/拷贝,同时图片会自动保存在文章同级目录同名资源文件夹下,便于管理。

感谢 Aomori 提供的优质主题!


所用第三方库版本信息:

  • hexo ^5.0.0
  • hexo-renderer-marked ^4.0.0
  • hexo-abbrlink ^2.2.1
  • hexo-image-link ^2.1.0

出现的一些问题:

  • 不能直接将 MarkDown 文件和资源文件夹复制纸 _post 目录,会出现资源无法加载的情况,应使用 Hexo 命令进行文章创建。
  • 资源路径中不能出现空格(如文件名中不能有空格),未知哪个插件的问题。
  • Front-matter 中不能用文章资源文件夹功能,无奈放在 source/images/ 目录下。

hexo-image-link 支持 URI 编码(简单粗暴):

// uri encode
let asset_dir_name_encode = encodeURIComponent(asset_dir_name)
// Character may be ahead of paths: '(' or '<' or whitespace.
let look_behind = '(?<=[\(<\s])';
// Asset paths in markdown start with './' or not, then folder's name, end with '/'.
let path_markdown = RegExp(look_behind + '(\.\/)?' + asset_dir_name + '\/', 'g');
let path_markdown_encode = RegExp(look_behind + '(\.\/)?' + asset_dir_name_encode + '\/', 'g');
if (!path_markdown_encode.test(data.content)) { // no asset link found, do nothing
  if (!path_markdown_encode.test(data.content)) {
    return;
  }
} else {
  path_markdown = path_markdown_encode;
}

本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可。