GitHub Wiki 中的目录或侧边栏

发布于 2025-01-04 09:21:53 字数 533 浏览 5 评论 0 原文

如何在 GitHub Wiki 中创建目录或侧边栏菜单?

我看到一些提到它并且 gollum 后端似乎支持它,但是我如何在当前的 GitHub 项目中做到这一点?

它最好基于我在页面中自动拥有的标题。

这些链接都提到了它,但没有显示如何操作:

How do I create a ToC or a sidebar menu in a GitHub Wiki?

I saw some mentions of it and gollum the backend seems to support it, but how do I do it in a current GitHub project?

It should best be based on the headers I have in the page automatically.

These links all mention it, but do not show how to do it:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

豆芽 2025-01-11 09:21:53

虽然您的解决方案有效,但使用 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.

套路撩心 2025-01-11 09:21:53

当您在项目的 wiki 中时,会出现一个链接添加自定义侧边栏。单击该按钮。

在此处输入图像描述

现在您有了一个可以编辑的页面,就像编辑任何其他 Markdown 页面。要制作目录,您必须手动完成。没有自动化方法(截至 2014 年 8 月)。例如:

# My menu
* [Home][home]
* [Technical documentation][techdocs]
* [User manual][usermanual]

[home]: https://github.com/myproject/wiki/Home
[techdocs]: https://github.com/myproject/wiki/Technical-documentation
[usermanual]: https://github.com/myproject/wiki/User-manual

When you are in the wiki of your project, there is a link Add a custom sidebar. Click that.

Enter image description here

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:

# My menu
* [Home][home]
* [Technical documentation][techdocs]
* [User manual][usermanual]

[home]: https://github.com/myproject/wiki/Home
[techdocs]: https://github.com/myproject/wiki/Technical-documentation
[usermanual]: https://github.com/myproject/wiki/User-manual
腹黑女流氓 2025-01-11 09:21:53

好的。让我看看我是否理解正确:

  1. 克隆你的 GitHub wiki。 (wiki 中有一个 Git 部分。您可以查看类似 wiki 的代码。)
  2. 创建 _Sidebar.md
  3. 在普通 wiki 页面中,使用 [[link]] 作为sidebar
  4. 提交并推送回 GitHub

这个过程非常痛苦。我很惊讶这个“gollum”wiki 竟然被接受了。

另外: _Sidebar.md 因此对于所有页面都是全局的。我必须将我的 wiki 组织到文件夹中,这样我就可以为不同的页面定义不同的侧边栏。

Okay. Let me see if I understand this correctly:

  1. Clone your GitHub wiki. (There’s a Git section in the wiki. You can checkout your wiki-like code.)
  2. Create _Sidebar.md
  3. In normal wiki pages, use [[link]] for the sidebar
  4. Commit and push back to GitHub

This 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.

眼泪淡了忧伤 2025-01-11 09:21:53

请注意,最初的问题是关于创建侧边栏(简单,在答案中解决)或实际目录(未回答)。

我可以说的一件事是 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?).

酒几许 2025-01-11 09:21:53

我认为这是在 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.

浅沫记忆 2025-01-11 09:21:53

我已经实现了 npm 模块 github-wiki-sidebar 来帮助 github 用户轻松创建和维护侧边栏菜单。

来源和结果:
https://raw. githubusercontent.com/wiki/adriantanasa/github-wiki-sidebar/images/github-wiki-sidebar-generator.png

源页面(如 Wiki 管理中所示):

Home
Installation
Roadmap
Usage
Usage: Command line modifiers
Usage: Init Mode

结果(具有自定义顺序):

先决条件:< /strong>

  • 在本地克隆您的 github wiki 存储库(显示在 Wiki UI 的右下角)
  • 安装 github-wiki-sidebar

    git clone /<我的项目名称>.wiki.git
    npm install -g github-wiki-侧边栏
    

创建/更新您的 wiki 菜单:

  • 在您的 github.com wiki 管理员上创建新页面/重命名页面
  • 在本地执行 github- wiki 存储库文件夹中的 wiki 侧边栏脚本

    cd /path/to/<我的项目名称>.wiki
    # 这会获取最新更改,生成侧边栏文件 (_Sidebar.md) 并将更改推送到 github
    github-wiki-侧边栏--git-push
    

该模块允许自定义 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):

Home
Installation
Roadmap
Usage
Usage: Command line modifiers
Usage: Init Mode

Result (with customised order):

Pre-requirements:

  • clone your github wiki repository locally (displayed on the bottom-right of the Wiki UI)
  • install the github-wiki-sidebar

    git clone <https://github.com/<username>/<my-project-name>.wiki.git
    npm install -g github-wiki-sidebar
    

Create/update your wiki menu:

  • create new pages / rename pages on your github.com wiki admin
  • execute locally the github-wiki-sidebar script in your wiki repository folder

    cd /path/to/<my-project-name>.wiki
    # this fetches latest changes, generates sidebar file (_Sidebar.md) and pushes changes to github
    github-wiki-sidebar --git-push
    

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.

浅浅淡淡 2025-01-11 09:21:53

如果您想使用可展开菜单(又名下拉菜单),请使用 _Sidebar.asciidoc,并使用 AsciiDoc 标记语法 [%collapsible]

您仍然可以在链接中参考纯 Markdown :)
请记住省略相关链接中的后缀,因为 GitHub 有自己的方式来解析要使用的页面。

此外,GitHub Wikis 在解析非 wiki 链接时似乎使用平面名称空间。尽管您可能使用文件文件夹,但路径似乎并不重要。

.Main 1
[%collapsible]
====
. link:./subitem1[Subitem 1]
. link:./subitem2[Subitem 2]
====
.Main 2
[%collapsible]
====
. link:./subitem3[Subitem 3]
. link:./subitem4[Subitem 4]
====

输入图片此处描述

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.

.Main 1
[%collapsible]
====
. link:./subitem1[Subitem 1]
. link:./subitem2[Subitem 2]
====
.Main 2
[%collapsible]
====
. link:./subitem3[Subitem 3]
. link:./subitem4[Subitem 4]
====

enter image description here

漫雪独思 2025-01-11 09:21:53

GitHub 将在 AsciiDoc 页面中自动生成文档目录,但不会在 Markdown 中生成。不过,这很容易做到。将 Markdown 转换为 AsciiDoc 也很容易 — 它们非常相似。

  1. 将文档类型设置为 AsciiDoc 而不是 Markdown
  2. 在文档开头插入 :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.

  1. Make the doc type AsciiDoc instead of Markdown.
  2. Insert :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:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文