icylogic / carbon

A blazing slow hexo theme
MIT License
48 stars 12 forks source link

English documentation on how to customize it? #15

Closed alexserver closed 9 years ago

alexserver commented 9 years ago

Hello, I've forked your work as I found this the coolest theme for hexo. Can it be possible to put some english documentation on how to customize some things ? for example, the footer, I'd like to modify the links for /about and /archives, but I didn't find a way yet. I see you have this in your jade template for footer:

ul#footer-links
  +footer-link('about')
  +footer-link('archives')
  li
    a.out-site(href=url_for(theme.feed))
      = __("feed")

Where can I change the label for this ?

icylogic commented 9 years ago

Hi, I've put these variables that could be modified into this config file. For your example, you could simply change these lines:

menu:
  about: /about
  archives: /archives

Generally speaking, these settings are for users to customize. However, you could modify the file to provide a different default configuration. Other files that may be modified are i18n files.

I will leave some comments in _config.yml as explaination later on.

As for other changes, you need to look into jade/coffe/stylus files. And I could not provide a complete documentation for these files, since they are written based on hexo docs and ohter themes. When you feel confused, you may need to read hexo docs or just open an issue here, I would answer you as soon as possible.

thinkingofmaud commented 9 years ago

Nice to see you back. Icylogic.

@alexserver

Carbon uses jade for the templating. http://jade-lang.com/ Think of it like haml+javascript. A 'mixin' works as a function.

So, if you want to modify the template to easily make links you would use something like this:

//footer.jade

  mixin footer-link(name)
    if theme.menu[name]
      +link(__(name), url_for(theme.menu[name]))

  mixin link(text, url)
    li
      if config.language === 'zh-CN' || config.language === 'zh-TW'
        a.zh(href=url)
          = text
      else
        a(href= url)
          = text

  mixin outlink(text, url)
    li
      a.out(href= url)
        = text

  ul#footer-links
    +footer-link('about')
    +footer-link('archives')
    +outlink('My site', '//mysite.net')
    if theme.feed
      +link(__("feed"), url_for(theme.feed))
    +outlink('Theme.Carbon', theme.repo)
    +outlink('Hexo', 'https://hexo.io')

You could also create a 'blogroll' on the config.yml and iterate it on the pattern.

'__' is a shortcut for the internationalization function, for acessing the values on theme/languages/