emacs-china / EGO

EGO is a static site generator that depends on Emacs, Git and Org-mode.
94 stars 11 forks source link

请问怎么在导航栏中生成category? #75

Closed Liu233w closed 8 years ago

Liu233w commented 8 years ago

在org-page中,如果有多个category的话,会为每一个category生成对应的目录,并在导航栏中生成链接。但是EGO中貌似只能通过 :summary 生成tags之类的目录。

还有,这一句是什么意思?我怎么生成category?

导航栏的设置,有 category 和 summary 两种

kuangdash commented 8 years ago

手机上快速回复下…

如果 ego--get-file-category 这个函数没出问题的话,那应该是具有和 org-page 一样的 category 功能。

Liu233w commented 8 years ago

在org-page中,每个category的链接会被自动放在导航栏上。单击之后会跳到相应category的index。但是在ego中的说明中貌似只能在:summary指定一个链接指向所有category的index。比如

:summary (("所有文章" :category) ("文章标签" :tags) ("按年度分类" :year :updates 10))

我是这么设置的。有没有什么办法可以直接通过导航栏的链接跳转到某个category的index?

kuangdash commented 8 years ago

这个和 org-page 一样,在 repository 的 source branch 里放几个目录,就有几个 category 了。

Liu233w commented 8 years ago

这么说吧,比如说我在站点文件夹中建立了blog wiki两个文件夹。在org-page里面导航栏会显示成

blog wiki tags About Github RSS

这几个链接。 但是在EGO中,如果在设置里面去掉:summary选项,就只会显示

tags About Github RSS

这三个链接。我在EGO的文档里面没有找到设置成第一个样式的说明。以下是我的设置:

  (ego-add-to-alist 'ego-project-config-alist
               `(("my-blog" ; 站点工程的名字
                  :repository-directory "~/documents/blog/" ; 站点的本地目录
                  :site-domain  "http://liu233w.github.io/"; 站点的网址
                  :site-main-title  "科学君的不科学博客"; 站点的标题
                  :site-sub-title  "by 不科学的科学君"; 站点的副标题
                 :theme (default) ; 使用的主题
                 :summary (("所有文章" :category) ("文章标签" :tags) ("按年度分类" :year :updates 10)) ; 导航栏的设置,有 category 和 summary 两种
                 :retrieve-category-function ego--get-file-category
                 :default-category "blog"
                 :source-browse-url ("Github" "https://github.com/liu233w/liu233w.github.io") ; 你的工程源代码所在的位置
                 :personal-disqus-shortname "liu233w" ; 使用 disqus 评论功能的话,它的短名称
                 :confound-email t ; 是否保护邮件名称呢?t 是保护,nil 是不保护,默认是保护
                 :web-server-docroot "~/webRoot/liu233w.github.io" ; 本地测试的目录
                 :web-server-port 5432; 本地测试的端口
                 :personal-avatar "https://raw.githubusercontent.com/Liu233w/liu233w.github.io/source/avatar.jpg"
                 :repository-org-branch "source"
                 :repository-html-branch "master"
                 )

显示出来的结果是

所有文章 文章标签 按年度分类 About Github RSS

应该怎么让它显示成

blog wiki 文章标签 按年度分类 About Github RSS

再次感谢

kuangdash commented 8 years ago

明白了,这里可以设置 ego--category-config-alist 变量。这个变量可以在 ego-config.el 文件里找到,然后仿照 “blog” 条目的设置进行设置就可以了。(在配置文件里重新定义这个变量,添加一个 “wiki” 条目)

由于这个变量是在 ego-project-config-alist 之外的变量,所以可能会在多站点管理时出现问题。打算在下一版本进行修复……

PS:我认为 wiki 这个词的意思至少是代表多人编辑的知识库,而非单指知识库,所以用这个词来表现时髦可能会适得其反。而且添加一个 “wiki” 标签其实也能解决你将一些 org 文件标记为 “知识库” 的需要。

Liu233w commented 8 years ago

嗯,成功了,谢谢。其实还需要把那两个category的名字加到 ego--category-show-list 里面才能满足我的需求的

  (setf ego--category-show-list
        '("blog" "acm"))

还有,那个wiki我只是举个例子,其实我是想开个acm 的category放acm的题解来着。 你发现了一只大学竞赛狗(:зゝ∠)

kuangdash commented 8 years ago

不好意思,EGO 的代码经过三个人的手修补了,代码冗余很多。(还好 show-list 和 category-config-alist 离的很近)

这里是有 bug 的,但不打算在这一版本上改进了。所以不建议使用 categories,直接用 tags 会清爽很多。