用 Typora 写 Hexo 博客

Typora 是一个非常优秀的 Markdown 编辑器,与大部分编辑器不同,它使用了一种所及即所得的编辑模式,输入 Markdown 格式的文字,实时渲染。

我用的 Hexo 博客系统,里面的图片路径比较特殊,/images/xx.png 这种路径,一般编辑器是无法识别的,去网上搜了一圈也没找到到底如何在 Typora 中设置,最后在官方文档中找到了。

If you’re using markdown for building websites, you may specify a URL prefix for image preview in local computer with property typora-root-url in YAML Front Matters.

For example, input typora-root-url:/User/Abner/Website/typora.io/ in YAML Front Matters, and then ![alt](/blog/img/test.png) will be treated as ![alt](file:///User/Abner/Website/typora.io/blog/img/test.png) in typora.

In new version, instead of manually input typora-root-url property, you could just click item from the menu bar EditImage ToolsUse Image Root Path to tell Typora to generate typora-root-url property automatically.

所谓的 YAML 配置,就是在 Hexo 的文档头部加上最下面这一行:

1
2
3
4
5
6
7
8
9
10
11
---
title: Typora Hexo 博客
tags:
- Hexo
- Typora
categories:
- Blog System
- Hexo
date: 2018-07-01 21:36:15
typora-root-url: ../
---

可以在 Typore 的菜单中选择 编辑图片工具设置图片根目录 ,和手动加那一行的效果是一样的,也会把这个配置写到文档中。