Ghost手册(2018.12.20)
不再维护的中文Ghost开源站点:https://www.ghostchina.com/ghost-cheat-sheet/
文件路径
| 配置文件 | /config.js |
| 主题 | /content/themes |
| 插件 | /content/apps |
| 图片 | /content/images |
| 导航(默认) | /core/server/helpers/tpl/navigation.hbs |
| 分页(默认) | core/server/helpers/tpl/pagination.hbs |
MarkDown/快捷键
| Save | - | Ctrl + S |
| Bold | **text** | Ctrl / Cmd + B |
| Emphasize | __text__ | Ctrl / Cmd + I |
| Inline Code | `code` | Cmd + K / Ctrl + Shift + K |
| Link | [title](http://) | Ctrl + Shift + L |
| Image |  | Ctrl + Shift + I |
| List | * item | Ctrl + L |
| H1 | # Heading | Ctrl + Alt + 1 |
| H2 | ## Heading | Ctrl + Alt + 2 |
| H3 | ### Heading | Ctrl + Alt + 3 |
| Select Word | Ctrl + Alt + W | |
| Uppercase | - | Ctrl + U |
| Lowercase | - | Ctrl + Shift + U |
| Titlecase | - | Ctrl + Alt + Shift + U |
| Insert Current Date | - | Ctrl + Shift + 1 |
相关资源
Default.hbs
default.hbs 文件中可以用到的 Handlebars 指令
Head
{{meta_title}}
{{meta_description}}
{{ghost_head}}
Body
{{body_class}}
{{{body}}}
Footer
{{@blog.title}}
{{@blog.url}}/rss/
{{ghost_foot}}
主题构成
- /assets
- /css
- screen.css
- post.css
- /fonts
- /images
- /js
- /partials
- pagination.hbs
- /css
- default.hbs
- index.hbs [必须]
- post.hbs [必须]
- page.hbs [可选]
- tag.hbs [可选]
- package.json
Handlebars
注释
{{! 'A Comment' }}
HTML 转义
{{content}}
if 指令
{{#if author.website}}
{{else}}
{{/if}}
unless 指令
{{#unless author.website}}
{{/unless}}
foreach 指令
{{#foreach posts}}
{{/foreach}}
块表达式
{{#author}}
{{/author}}
Index.hbs
index.hbs 文件中可以使用的 Handlebars 指令
加载父模板 default.hbs
{{!< default}}
Header
{{#if @blog.cover}}
{{@blog.cover}}
{{/if}}
{{#if @blog.logo}}
{{@blog.logo}}
{{/if}}
{{@blog.title}}
{{@blog.description}}
文章
{{#foreach posts}}
{{/foreach}}
{{post_class}}
{{date format='YYYY-MM-DD'}}
{{date published_at format="MMMM DD, YYYY"}}
{{date published_at timeago="true"}}
{{#if tags}}
{{tags}}
{{tags separator=" | "}}
{{/if}}
{{excerpt}}
{{excerpt characters="140"}}
{{content}}
{{content words="100"}}
分页
{{pagination}}
API 概览
- @blog.title
- @blog.url
- @blog.logo
- @blog.description
- meta_title
- meta_description
- body
- body_class
- ghost_head
- ghost_foot
- pagination
- next
- page
- pages
- page_url prev
- page_url next
- prev
- post_class
- post, posts
- author
- name
- website
- bio
- cover
- image
- excerpt [characters][words]
- content [characters][words]
- url [absolute]
- tags [separator]
- name
- date [format][timeago]
- id
- published_at
Post.hbs
post.hbs 文件中可以使用的 Handlebars 指令
加载父模板 default.hbs
{{!< default}}
Header
{{#if @blog.cover}}
{{@blog.cover}}
{{/if}}
{{#if @blog.logo}}
{{@blog.logo}}
{{/if}}
{{@blog.title}}
{{@blog.description}}
{{date published_at timeago="true"}}
文章
{{post_class}}
{{#if}}
{{else}}
{{/if}}
{{#post}}
{{/post}}
{{url}}
{{{title}}}
{{date format='YYYY-MM-DD'}}
{{date published_at format="MMMM DD, YYYY"}}
{{#if tags}} {{tags}}
{{tags separator=" | "}}
{{/if}}
{{content}}
作者信息
{{#author}}
{{/author}}
{{#if author}}
{{/if}}
{{author.name}}
{{author.bio}}
{{author.email}
{{author.website}}
{{author.image}}
{{author.cover}}