From 8db3d39d0a6d4c42a97d810c241e93973440e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Thu, 26 Nov 2020 10:19:55 +0800 Subject: [PATCH] Update deploy and embed-files (#30) * Update deploy and embed-files * Update --- _sidebar.md | 2 +- deploy.md | 4 +++ embed-files.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/_sidebar.md b/_sidebar.md index 84ab17e..0ddbd62 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -22,7 +22,7 @@ * [CDN](zh-cn/cdn.md) * [离线模式(PWA)](zh-cn/pwa.md) * [服务端渲染 (SSR)](zh-cn/ssr.md) - * [文件嵌入(new)](zh-cn/embed-files.md) + * [文件嵌入](zh-cn/embed-files.md) * [Awesome docsify](zh-cn/awesome.md) * [Changelog](zh-cn/changelog.md) diff --git a/deploy.md b/deploy.md index fdad4ab..14ae0dd 100644 --- a/deploy.md +++ b/deploy.md @@ -38,6 +38,10 @@ pages: !> 你可以用 `- cp -r docs/. public` 替换脚本, 如果 `./docs` 是你的 docsify 子文件夹。 +## Gitee Pages + +在对应的 Gitee 仓库服务中选择 `Gitee Pages`,选择您要部署的分支,填写您要部署的分支上的目录,例如`docs`,填写完成之后点击启动即可。 + ## Firebase 主机 !> 你需要先使用谷歌账号登陆 [Firebase 控制台](https://console.firebase.google.com) ,然后使用 `npm i -g firebase-tools` 命令安装 Firebase CLI 。 diff --git a/embed-files.md b/embed-files.md index 4ca22d8..11269a7 100644 --- a/embed-files.md +++ b/embed-files.md @@ -73,4 +73,79 @@ docsify 4.6 开始支持嵌入任何类型的文件到文档里。你可以将 [](../_media/example.html ':include :type=code text') -?> 如何高亮代码?你可以查看[这份文档](zh-cn/language-highlight.md). +?> 如何高亮代码?你可以查看[这份文档](zh-cn/language-highlight.md)。 + +## 嵌入Gist + +你可以将 Gist 作为 Markdown 内容或代码块嵌入。这是基于[嵌入文件](#embed-files)部分开头的方法,不过是嵌入一个原始的 Gist URL。 + +?> 这里**不需要**插件或修改配置来使其工作。事实上,即使你使用插件或修改配置来允许加载外部脚本,从 Gist 复制的 "Embed" `script`标签也无法加载。 + +### 确定Gist的元数据 + +从查看`gist.github.com`上的 Gist 开始。在本指南中,我们使用这个 Gist: + +- https://gist.github.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15 + +从 Gist 中找出以下内容: + +| 字段 | 示例 | 说明 | +| ------------ | ---------------------------------- | ------------------------------------------------------------------- | +| **Username** | `anikethsaha` | Gist 的作者 | +| **Gist ID** | `c2bece08f27c4277001f123898d16a7c` | Gist 的标识符。该标识在 Gist 的有效期内是固定的 | +| **Filename** | `content.md` | 在 Gist 中选择一个文件名。即使是单文件的 Gist,也需要这样做才能嵌入 | + +你将需要这些来为目标文件建立 _raw gist URL_ 。它的格式如下: + +- `https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME` + +下面是根据示例 Gist 举出的两个例子: + +- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md +- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js + +?> 另外你也可以直接点击 Gist 文件上的 _Raw_ 按钮来获取原始 URL。但是如果你使用这种方法,请确保**删除**`raw/`和文件名之间的修订号,这样 URL 就会与上面的模式一致。否则当更新 Gist 时,你嵌入的 Gist 将**不会**显示最新的内容。 + +继续下面的一个部分,将 Gist 嵌入到 Docsify 页面上。 + +### 渲染 Gist 中的 Markdown 内容 + +这是一个很好的方法,可以将内容**无缝**地嵌入到你的文档中,而不需要将别人发送到外部链接。这种方法很适合在多个仓库的文档网站上重复使用一个 Gist,比如安装说明。这种方法同样适用于您的账户或其他用户拥有的 Gist。 + +格式: + +```markdown +[LABEL](https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME ':include') +``` + +例如: + +```markdown +[gist: content.md](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md ':include') +``` + +你会看到: + +[gist: content.md](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md ':include') + +`LABEL`可以是任何你想要的文本。如果链接被破坏,它可以作为一个 _fallback_ 信息。所以在这里重复文件名是很有用的,万一你需要修复一个破坏的链接。它还可以使嵌入的元素一目了然。 + +### 渲染 Gist 中的代码块 + +格式与上一节相同,但是在alt文本中添加了`:type=code`。与[嵌入的类型](#embedded-file-type)部分一样,语法高亮将从扩展名(如`.js`或`.py`)中**推断**,所以你可以将`type`设置为`code`。 + +格式: + +```markdown +[LABEL](https://gist.githubusercontent.com/USERNAME/GIST_ID/raw/FILENAME ':include :type=code') +``` + +例如: + +```markdown +[gist: script.js](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js ':include :type=code') +``` + +你会看到: + +[gist: script.js](https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js ':include :type=code')