Skip to content

Commit

Permalink
✨ feat: resolves #265, add support for tranlated post
Browse files Browse the repository at this point in the history
  • Loading branch information
Stark-X-ZA committed Mar 30, 2024
1 parent 4559f79 commit 2c51bf7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ theme: archer
- [设置文章版权信息](https://github.com/fi3ework/hexo-theme-archer/wiki/%E8%AE%BE%E7%BD%AE%E6%96%87%E7%AB%A0%E7%89%88%E6%9D%83%E4%BF%A1%E6%81%AF)
- [启用 Algolia 搜索](https://github.com/fi3ework/hexo-theme-archer/wiki/%E5%90%AF%E7%94%A8-Algolia-%E6%90%9C%E7%B4%A2)
- [切换为英文界面](https://github.com/fi3ework/hexo-theme-archer/wiki/%E8%8B%B1%E6%96%87%E7%95%8C%E9%9D%A2)
- [翻译的文章](#翻译的文章)

### 启用字数统计

Expand Down Expand Up @@ -281,6 +282,20 @@ custom_font:

`url` 为引入的自定义字体的 CDN 链接或本地链接。

### 翻译的文章

在文章的 Front-matter 中添加 `translated` 字段,以显示翻译信息。

``` markdown
---
translated:
author: 'Stark-X'
title: '你好,世界'
link: 'https://github.com'
---
```


## 文章撰写增强

Archer 主题为您撰写的文章提供了一些增强的展示内容。
Expand Down
3 changes: 3 additions & 0 deletions languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ publish_date: 发表日期
update_date: 更新日期
license: 版权声明
read_more: 阅读全文
original_post_link: 源文章链接
original_post_author: 源文章作者
translater: 译者
3 changes: 3 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ publish_date: 'Publish date'
update_date: 'Update date'
license: 'License'
read_more: 'READ ARTICLE'
original_post_link: 'Original post link'
original_post_author: 'Original post author'
translater: 'Translater'
6 changes: 6 additions & 0 deletions layout/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<!-- license -->
<% if(theme.copyright.enable === true && page.copyright !== false) { %>
<div class="license-wrapper">
<% if(page.translated) { %>
<p><%- __('translater') %><a href="<%- config.url %>"><%- config.author %></a>
<p><%- __('original_post_author') %><%- page.translated.author %>
<p><%- __('original_post_link') %><a href="<%- page.translated.link %>" target="_blank"><%- page.translated.title || page.translated.link %></a>
<% } else { %>
<p><%- __('author') %><a href="<%- config.url %>"><%- config.author %></a>
<% } %>
<p><%- __('post_link') %><a href="<%- page.permalink %>"><%- page.permalink %></a>
<p><%- __('publish_date') %><a href="<%- page.permalink %>"><%- (page.date).format('MMMM Do YYYY, h:mm:ss a') %></a>
<p><%- __('update_date') %><a href="<%- page.permalink %>"><%- (page.updated).format('MMMM Do YYYY, h:mm:ss a') %></a>
Expand Down

0 comments on commit 2c51bf7

Please sign in to comment.