Hexo
hexo官方标签插件使用
00 分钟
发布于: 2020-4-18
最后更新: 2024-8-18
type
status
date
slug
summary
category
tags
password
Created time
Jul 30, 2024 06:21 PM
Last edited time
Aug 18, 2024 04:13 PM
UUID
icon
🗒️发表的笔记
URL CK
ErrorCheck
ErrorCheck
Description

1. 标签插件(Tag Plugins)

标签插件和 Front-matter 中的标签不同,它们是用于在文章中快速插入特定内容的插件。

1.1. 引用块

在文章中插入引言,可包含作者、来源和标题。
别号: quote

1.1.1. 样例

没有提供参数,则只输出普通的 blockquote
{% blockquote %} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem. {% endblockquote %}
引用书上的句子
{% blockquote David Levithan, Wide Awake %} Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy. {% endblockquote %}
引用 Twitter
{% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %} NEW: DevDocs now comes with syntax highlighting. http://devdocs.io {% endblockquote %}
引用网络上的文章
{% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} Every interaction is both precious and an opportunity to delight. {% endblockquote %}

1.2. 代码块

在文章中插入代码。
别名: code
Specify additional options in option:value format, e.g. line_number:false first_line:5.
Extra Options
Description
Default
line_number
Show line number
true
highlight
Enable code highlighting
true
first_line
Specify the first line number
1
mark
Line highlight specific line(s), each value separated by a comma. Specify number range using a dash Example:mark:1,4-7,10 will mark line 1, 4 to 7 and 10.
wrap
Wrap the code block in``
true

1.2.1. 样例

普通的代码块
{% codeblock %} alert('Hello World!'); {% endcodeblock %}
指定语言
{% codeblock lang:objc %} [rectangle setX: 10 y: 10 width: 20 height: 20]; {% endcodeblock %}
附加说明
{% codeblock Array.map %} array.map(callback[, thisArg]) {% endcodeblock %}
附加说明和网址
{% codeblock _.compact http://underscorejs.org/#compact Underscore.js %} _.compact([0, 1, false, 2, '', 3]); => [1, 2, 3] {% endcodeblock %}

1.3. 反引号代码块

另一种形式的代码块,不同的是它使用三个反引号来包裹。
\[language] [title] [url] [link text] code snippet

1.4. Pull Quote

在文章中插入 Pull quote。

1.5. jsFiddle

在文章中嵌入 jsFiddle。

1.6. Gist

在文章中嵌入 Gist。

1.7. iframe

在文章中插入 iframe。

1.8. Image

在文章中插入指定大小的图片。

1.9. Link

在文章中插入链接,并自动给外部链接添加 target="_blank" 属性。

1.10. Include Code

插入 source/downloads/code 文件夹内的代码文件。source/downloads/code 不是固定的,取决于你在配置文件中 code_dir 的配置。

1.10.1. 样例

嵌入 test.js 文件全文
只嵌入第 3 行
嵌入第 5 行至第 8 行
嵌入第 5 行至文件结束
嵌入第 1 行至第 8 行

1.11. Youtube

在文章中插入 Youtube 视频。

1.12. Vimeo

在文章中插入 Vimeo 视频。

1.13. 引用文章

引用其他文章的链接。
在使用此标签时可以忽略文章文件所在的路径或者文章的永久链接信息、如语言、日期。
例如,在文章中使用 {% post_link how-to-bake-a-cake %} 时,只需有一个名为 how-to-bake-a-cake.md 的文章文件即可。即使这个文件位于站点文件夹的 source/posts/2015-02-my-family-holiday 目录下、或者文章的永久链接是 2018/en/how-to-bake-a-cake,都没有影响。
默认链接文字是文章的标题,你也可以自定义要显示的文本。此时不应该使用 Markdown 语法 []()
默认对文章的标题和自定义标题里的特殊字符进行转义。可以使用 escape选项,禁止对特殊字符进行转义。
链接使用文章的标题
{% post_link hexo-3-8-released %}
链接使用自定义文字
{% post_link hexo-3-8-released '通往文章的链接' %}
对标题的特殊字符进行转义
{% post_link hexo-4-released 'How to use <b> tag in title' %}
禁止对标题的特殊字符进行转义
{% post_link hexo-4-released '<b>bold</b> custom title' false %}

1.14. 引用资源

引用文章的资源。

1.15. Raw

如果您想在文章中插入 Swig 标签,可以尝试使用 Raw 标签,以免发生解析异常。

1.16. 文章摘要和截断

在文章中使用 ,那么 之前的文字将会被视为摘要。首页中将只出现这部分文字,同时这部分文字也会出现在正文之中。
例如:
首页中将只会出现
正文中则会出现
注意,摘要可能会被 Front Matter 中的 excerpt 覆盖。
上一篇
hexo使用Markdown出现标题错位,降级等异常情况
下一篇
Git上传的文件应用失败找不到该文件

评论
Loading...