Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use $source\_$theme.yml file for theme config #440

Closed
wants to merge 3 commits into from
Closed

use $source\_$theme.yml file for theme config #440

wants to merge 3 commits into from

Conversation

chenall
Copy link
Contributor

@chenall chenall commented Jan 12, 2014

抱歉, 英文不好,还是用中文好了..

功能

  • 使得每个站点的主题配置文件独立,方便多站点使用同一主题,并且避免更新主题后导致的配置丢失.
  • 还可以方便测试各个主题的功能.

使用

首先把主题的_config.yml文件复制到你的站点source目录下,并改名为_THEME.yml,THEME是对应的主题名称.
每个主题都可以在source目录下放一个对应的主题配置.

使用例子

我有两个站点hexo.chenall.net和chenall.net使用的是同样的主题,没有这个功能之前,我必须一个站一个目录,并且每个站都要有对应的主题文件,这样很不方便.

这个配合 #435,#436 新增的--config功能就可以很方便的配置多站点.

注: 多站时,每个站的配置中source目录和public目录要改成各自独立的不要一样.

@tommy351
Copy link
Member

這雖然是個不錯的點子,不過請考慮向下相容性,當上述路徑不存在時,搜尋主題內的配置檔案。

@chenall
Copy link
Contributor Author

chenall commented Jan 13, 2014

已经有考虑了保持相下兼容性的,如果source目录下的配置不存在还是使用原来的配置.

  if (!fs.existsSync(configPath))
+    configPath = pathFn.join(hexo.theme_dir, '_config.yml');

@tommy351
Copy link
Member

建議採用async方式實作。

@chenall
Copy link
Contributor Author

chenall commented Jan 15, 2014

刚接触nodejs,不熟,不知这样改行不?

目前如果配置文件在source目录下不会自动刷新配置,

尝试过以下方法,
修改util/file2.js 让 exports.watch函数返回watcher,这样就可以直接通过watcher.add添加进去,再修改一些代码可以实现.

修改的代码相对比较多,感觉不正统就放弃了,

作者对这些比较熟,如果可能的话看能不能处理下.

@tommy351
Copy link
Member

這部份還挺麻煩的,因為source資料夾應由hexo.source管理,而themes資料夾應由hexo.theme管理。

@chenall
Copy link
Contributor Author

chenall commented Jan 16, 2014

如果不好處理就算了,必竟這個一般只有在調試時才會需要用到,確實有需要可以自己寫一個scripts插件來實現.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants