GitHub Wiki 中的目录或侧边栏
如何在 GitHub Wiki 中创建目录或侧边栏菜单?
我看到一些提到它并且 gollum 后端似乎支持它,但是我如何在当前的 GitHub 项目中做到这一点?
它最好基于我在页面中自动拥有的标题。
这些链接都提到了它,但没有显示如何操作:
- https://gist.github.com/379469 - 一些JavaScript 黑客
https://github.com/blog/774-git-powered-wikis-improved - GitHub 提及它:
“GitHub Wiki 具有很少记录的页脚和侧边栏功能,有些人对此有所了解。 我们基于 git 的 Wiki 作者很熟悉。新的 Wiki 编辑器为您提供有限的基于网络的 编辑网站上的页脚和侧边栏。 ”
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
虽然您的解决方案有效,但使用 GitHub 的 Web 界面有一种更简单的方法。您只需创建一个名为
_Sidebar
和/或_Footer
的页面即可。请参阅具有多级功能的 Github Wiki 侧边栏菜单构建器中的详细说明。
编辑原始文章已消失,我在缓存中找不到它,因此我更新了链接。
While your solution works, there's an easier way to do it using GitHub's web interface. You can simply create a page named
_Sidebar
and/or_Footer
.See detailed instructions in Github Wiki sidebar menu builder with multi-level.
Edit The original article is gone and I can't find it in the cache so I've updated the link.
当您在项目的 wiki 中时,会出现一个链接添加自定义侧边栏。单击该按钮。
现在您有了一个可以编辑的页面,就像编辑任何其他 Markdown 页面。要制作目录,您必须手动完成。没有自动化方法(截至 2014 年 8 月)。例如:
When you are in the wiki of your project, there is a link Add a custom sidebar. Click that.
Now you have a page that you edit as you would edit any other Markdown page. To make a table of contents you have to do it manually though. There is no automated method (as of August 2014). So for example:
好的。让我看看我是否理解正确:
_Sidebar.md
[[link]]
作为sidebar这个过程非常痛苦。我很惊讶这个“gollum”wiki 竟然被接受了。
另外:
_Sidebar.md
因此对于所有页面都是全局的。我必须将我的 wiki 组织到文件夹中,这样我就可以为不同的页面定义不同的侧边栏。Okay. Let me see if I understand this correctly:
_Sidebar.md
[[link]]
for the sidebarThis process is a pain in the ass. I’m surprised this “gollum” wiki has any acceptance.
Also:
_Sidebar.md
is therefore global for all pages. I would have to organize my wiki into folders, so I can define different sidebars for different pages.请注意,最初的问题是关于创建侧边栏(简单,在答案中解决)或实际目录(未回答)。
我可以说的一件事是 gollum 2.1 wiki 语法允许使用
[[_TOC_]]
标签,但 GitHub wiki 无法识别它(还?)。Note that the original question was about creating a side bar (easy, solved in the answers) or an actual table of contents (not answered).
One thing I can say is that the gollum 2.1 wiki syntax allows for a
[[_TOC_]]
tag, but a GitHub wiki won't recognise that (yet?).我认为这是在 Gollum
README
中描述的。 (请参阅页眉和侧边栏部分。)本质上,您在包含页面内容的目录中创建
_footer.ext
和_sidebar.ext
。I think this is described in the Gollum
README
. (See the header and sidebar sections.)Essentially, you make a
_footer.ext
and_sidebar.ext
in the directory containing the page content.我已经实现了 npm 模块 github-wiki-sidebar 来帮助 github 用户轻松创建和维护侧边栏菜单。
来源和结果:
https://raw. githubusercontent.com/wiki/adriantanasa/github-wiki-sidebar/images/github-wiki-sidebar-generator.png
源页面(如 Wiki 管理中所示):
结果(具有自定义顺序):
先决条件:< /strong>
安装 github-wiki-sidebar
创建/更新您的 wiki 菜单:
在本地执行 github- wiki 存储库文件夹中的 wiki 侧边栏脚本
该模块允许自定义 Markdown 输出,包括项目排序、类别分隔符、菜单模板、链接格式和其他的。
I have implemented the npm module github-wiki-sidebar to help github users to easily create and maintain the sidebar menu.
Source and Result:
https://raw.githubusercontent.com/wiki/adriantanasa/github-wiki-sidebar/images/github-wiki-sidebar-generator.png
Source pages (as displayed in Wiki admin):
Result (with customised order):
Pre-requirements:
install the github-wiki-sidebar
Create/update your wiki menu:
execute locally the github-wiki-sidebar script in your wiki repository folder
The module allows customisation of the markdown output including ordering of items, the category separator, the template for the menu, the format of links and others.
如果您想使用可展开菜单(又名下拉菜单),请使用
_Sidebar.asciidoc
,并使用 AsciiDoc 标记语法[%collapsible]
。您仍然可以在链接中参考纯 Markdown :)
请记住省略相关链接中的后缀,因为 GitHub 有自己的方式来解析要使用的页面。
此外,GitHub Wikis 在解析非 wiki 链接时似乎使用平面名称空间。尽管您可能使用文件文件夹,但路径似乎并不重要。
If you'd like to use expandable menus (aka. Dropdown Menus), then go for
_Sidebar.asciidoc
, and use the AsciiDoc markup syntax[%collapsible]
.You can still refer to plain Markdown in the links :)
Remember to omit the suffix in the relative links as GitHub has it's own way to resolve what page to use.
Also GitHub Wikis seems to use a flat name space when parsing non wiki links. Although you might be using folders for your files, the path doesn't seem to count.
GitHub 将在 AsciiDoc 页面中自动生成文档目录,但不会在 Markdown 中生成。不过,这很容易做到。将 Markdown 转换为 AsciiDoc 也很容易 — 它们非常相似。
AsciiDoc
而不是Markdown
。:toc:
。我制作了一个演示存储库,演示了嵌入在维基页面,而不是侧边栏。结果如下:
GitHub will auto-generate a document table of contents in AsciiDoc pages but not Markdown. It's easy to do, though. Also easy to convert Markdown to AsciiDoc — they're very similar.
AsciiDoc
instead ofMarkdown
.:toc:
at the start of the document.I made a demo repo demonstrating an auto-generated TOC embedded in a Wiki page, not the sidebar. Here's the result: