Skip to content

Theme update for Hexo 5 & i18n #92

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2.1
orbs:
node: circleci/[email protected]

workflows:
matrix-tests:
jobs:
- node/test:
version: 14.18.1
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## vNEXT
## v3.0.0

* Remove `underscore`
* Compatibility fixes for Hexo v5
* i18n

## v1.0.16

Expand Down
3 changes: 0 additions & 3 deletions circle.yml

This file was deleted.

6 changes: 6 additions & 0 deletions languages/cs-CZ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Česky
pagination:
previous: Předchozí
next: Další
github:
edit: Editovat na GitHubu
6 changes: 6 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: English
pagination:
previous: Previous
next: Next
github:
edit: Edit on GitHub
6 changes: 3 additions & 3 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<meta property="og:url" content="<%- config.url %>">
<meta property="og:title" content="<%- page.title %> | <%- config.title %>">
<meta property="og:description" content="<%- page.description %>">
<meta property="og:image" content="<%- config.logo && config.logo.desktop || theme.logo.desktop %>">
<meta name="twitter:site" content="<%- theme.social_links.twitter %>">
<meta property="og:image" content="<%- config.logo && config.logo.desktop %>">
<meta name="twitter:site" content="<%- config.social_links.twitter %>">
<meta name="twitter:title" content="<%- page.title %> | <%- config.title %>">
<meta name="twitter:description" content="<%- page.description %>">
<meta name="twitter:image" content="<%- config.logo && config.logo.desktop || theme.logo.desktop %>">
<meta name="twitter:image" content="<%- config.logo && config.logo.desktop %>">

<!-- Misc -->
<meta name="google-site-verification" content="" />
Expand Down
44 changes: 21 additions & 23 deletions layout/page.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span class="icon-menu"></span>
</div>
<div class="nav-item nav-item-logo">
<% logo = config.logo || theme.logo %>
<% logo = config.logo %>
<a class="logo-wrapper" href="<%- logo.url %>" title="<%- logo.title %> <%- logo.subtitle %>" <%- logo.target && 'target=' + logo.target %> >
<img src="<%- relative_url(page.path, logo.nav_mobile) %>" alt="<%- logo.title %>" class="logo"/>
<% if (logo && logo.subbrand) { %>
Expand All @@ -30,23 +30,14 @@
</div>
</div>


<% if (config.apollo_nav) { %>
<div class="nav-group right">
<div id="nav-container" class="show-desktop"></div>
<script src="https://apollographql-nav.netlify.com/index.js"></script>
<script>ApolloNav.initNav({ theme: 'light' }, 'nav-container')</script>
</div>
<% } else { %>
<div class="nav-group right">
<% _.each(config.nav_links || theme.nav_links, function (link, title) { %>
<div class="nav-item show-desktop <%- link.active && 'active' %> <%- link.separator && 'separator' %>">
<a class="link" href="<%- link.url || link %>" <%- link.target && 'target=' + link.target %> >
<span><%- title %></span>
</a>
</div>
<% }) %>
<% } %>
<div class="nav-group right">
<% Object.entries(config.nav_links).forEach(function ([title, link]) { %>
<div class="nav-item show-desktop <%- link.active && 'active' %> <%- link.separator && 'separator' %>">
<a class="link" href="<%- link.url || link %>" <%- link.target && 'target=' + link.target %> >
<span><%- title %></span>
</a>
</div>
<% }) %>
</div>
</div>

Expand Down Expand Up @@ -78,8 +69,15 @@
<div class="content-wrapper">
<%
function findAdjacent (direction) {
var pagePaths = _.flatten(_.map(config.sidebar_categories, function(vals) { return vals; }));
var pages = _.map(pagePaths, function (val) { return site.pages.findOne({path: val + '.html'}); });
var pagePaths = Object.entries(config.sidebar_categories).map(function([key, vals]) { return vals; }).reduce( (a, b) => a.concat(b), []);
// i18n
if (page.lang && page.lang !== 'en') {
const lang = page.lang + '/';
pagePaths.forEach((path, index) => {
pagePaths[index] = `${lang}${path}`;
})
}
var pages = pagePaths.map(function (val) { return site.pages.findOne({path: val + '.html'}); });
var i = pages.length
while (i--) {
if (pages[i] && pages[i].title === page.title) {
Expand All @@ -95,15 +93,15 @@

<a class="link primary prev" href="<%- relative_url(page.path, prev.path) %>">
<span class="icon-arrow-left-alt"></span>
<span class="subtitle-pagination">Previous</span>
<span class="subtitle-pagination"><%= __('pagination.previous') %></span>
<%- prev.title %>
</a>

<% } %>
<% var next = findAdjacent(1); if (next) { %>

<a class="link primary next" href="<%- relative_url(page.path, next.path) %>">
<span class="subtitle-pagination">Next</span>
<span class="subtitle-pagination"><%= __('pagination.next') %></span>
<%- next.title %>
<span class="icon-arrow-right-alt"></span>
</a>
Expand All @@ -114,7 +112,7 @@

<div class="github">
<a class="link tertiary " href="<%- githubUrl %>" target="_blank">
<span class="icon-github"></span>Edit on GitHub</a>
<span class="icon-github"></span><%= __('github.edit') %></a>
</div>

<% if (page.discourseTopicId) { %>
Expand Down
17 changes: 11 additions & 6 deletions layout/partials/sidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
if (isOutsidePath(path)) {
return path;
}
// i18n
let lang = '';
if (page.lang && page.lang !== 'en') {
lang = page.lang + '/';
}

// The path we've been told to find from _config.yaml.
const htmlPath = `${path}.html`
const htmlPath = `${lang}${path}.html`

const extraClasses = [];

Expand Down Expand Up @@ -51,11 +56,11 @@
<script>ApolloNav.initNav({ theme: 'light', id: 'mobile-nav' }, 'sidebar-panel-nav')</script></a>
<% } else { %>
<div class="panel-item">
<a class="" href="<%- relative_url(page.path, theme.logo.url) %>" title="<%- theme.logo.title %>" <%- theme.logo.target && 'target=' + theme.logo.target %> >
<span><%- theme.logo.title %> <%- theme.logo.subtitle %></span>
<a class="" href="<%- relative_url(page.path, config.logo.url) %>" title="<%- config.logo.title %>" <%- config.logo.target && 'target=' + config.logo.target %> >
<span><%- config.logo.title %> <%- config.logo.subtitle %></span>
</a>
</div>
<% _.each(config.nav_links || theme.nav_links, function (link, title) { %>
<% Object.entries(config.nav_links).forEach(function ([title, link]) { %>
<div class="panel-item <%- link.active && 'active' %>">
<a class="" href="<%- link.url || link %>" <%- link.target && 'target=' + link.target %> >
<span><%- title %></span>
Expand Down Expand Up @@ -93,8 +98,7 @@
<% } %>

<ul class="toc">
<% _.each(config.sidebar_categories, function(pages, category) { %>

<% Object.entries(config.sidebar_categories).forEach(function ([category, pages]) { %>
<li>
<% if (category !== 'null') { %>
<div class="heading-toc"><%- category %></div>
Expand All @@ -103,6 +107,7 @@
<ul class="list-toc">
<% pages.forEach(function(path) { %>
<% const details = pathDetails(path) %>

<% if (details) { %>
<li class="item-toc <%- details.extraClasses %>">
<a
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meteor-theme-hexo",
"version": "2.0.3",
"description": "[Read the docs docs.](https://docs-docs.netlify.com/docs/docs/)",
"version": "3.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node ./tests/index.js"
Expand Down