Skip to content

Commit

Permalink
update to [email protected] (#166)
Browse files Browse the repository at this point in the history
* Update .npmignore

* Update dependency uglify-js to v3.6.3 (#158)

* Update dependency uglify-js to v3.6.4 (#162)

* upgrade to [email protected]

* Update dependency uglify-js to v3.6.5 (#163)

* drop angular i18n

* update badage

* Update dependency uglify-js to v3.6.7 (#164)

* support string as content_width
  • Loading branch information
ikeq authored Nov 2, 2019
1 parent 6e276ea commit 78b7aca
Show file tree
Hide file tree
Showing 29 changed files with 127 additions and 190 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ test/
.travis.yml
.github/
.DS_Store
renovate.json
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Inside

[![build-img]][travis] [![release-img]][releases] [![license-img]](LICENSE)
[![build-img]][travis]
[![release-img]][releases]
[![hexo-image]][hexo]
[![license-img]](LICENSE)

❤️ SPA, flat and clean theme for [Hexo].

Expand Down Expand Up @@ -92,3 +95,4 @@ Licensed under [MIT](LICENSE).
[releases]: https://github.com/ikeq/hexo-theme-inside/releases
[travis]: https://travis-ci.org/ikeq/hexo-theme-inside
[documentation]: https://blog.oniuo.com/theme-inside
[hexo-image]: https://img.shields.io/badge/hexo-%3E%3D%204.0-blue.svg?longCache=true&style=flat-square
6 changes: 5 additions & 1 deletion README_zh-Hans.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Inside

[![build-img]][travis] [![release-img]][releases] [![license-img]](LICENSE)
[![build-img]][travis]
[![release-img]][releases]
[![license-img]](LICENSE)
[![hexo-image]][hexo]

❤️ SPA, flat and clean theme for [Hexo].

Expand Down Expand Up @@ -91,3 +94,4 @@ Licensed under [MIT](LICENSE).
[releases]: https://github.com/ikeq/hexo-theme-inside/releases
[travis]: https://travis-ci.org/ikeq/hexo-theme-inside
[documentation]: https://blog.oniuo.com/theme-inside
[hexo-image]: https://img.shields.io/badge/hexo-%3E%3D%204.0-blue.svg?longCache=true&style=flat-square
51 changes: 0 additions & 51 deletions languages/default.yml

This file was deleted.

30 changes: 0 additions & 30 deletions layout/index.ejs

This file was deleted.

33 changes: 33 additions & 0 deletions layout/index.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html lang="{{ config.language }}">
<head>
<meta charset="utf-8">
<title>{{ title }}</title>
<base href="{{ config.root }}">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="canonical" href="{{ url_trim(url) }}">
<link rel="icon" type="image/x-icon" href="{{ url_for(theme.favicon) }}">
{% if theme.pwa.manifest %}
<link rel="manifest" href="{{ url_for('manifest.json') }}">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
{% endif %}
{{ open_graph({ image: page.thumbnail || theme.profile.avatar }) | safe }}
{% if theme.seo.structured_data %}
{{ structured_data(page) | safe }}
{% endif %}
{% if config.feed and config.feed.path %}
<link rel="alternate" type="application/atom+xml" title="{{ config.title }}" href="{{ url_for(config.feed.path) }}">
{% endif %}
{{ theme.styles | safe }}
{{ css('theme.' + theme.runtime.themeHash) | safe }}
{{ js('config.' + theme.runtime.configHash) | safe }}
{% if theme.ga %}
{{ ga(theme.ga) | safe }}
{% endif %}
</head>
<body lang="{{ config.language }}">
<{{ theme.runtime.selector }}></{{ theme.runtime.selector }}>
{{ theme.scripts | safe }}
</body>
</html>
3 changes: 1 addition & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ module.exports = function (hexo) {
// plugins comes first to ensure that their libs is ready when executing dynamic code.
...(result.plugins || []),
...resources.styles,
...resources.scripts,
resources.locales[site.language]
...resources.scripts
];

if (theme.appearance.font && theme.appearance.font.url)
Expand Down
7 changes: 6 additions & 1 deletion lib/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
"background": { "type": "string" },
"sidebar_background": { "type": "string" },
"card_background": { "type": "string" },
"content_width": { "type": "number", "minimum": 320 },
"content_width": {
"oneOf": [
{ "type": "number" },
{ "type": "string" }
]
},
"font": {
"type": "object",
"properties": {
Expand Down
20 changes: 18 additions & 2 deletions lib/filter/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const { date } = require('hexo/lib/plugins/helper/date');
const bounded = '<div class="article-bounded"></div>';
const table = '<div class="article-table"></div>';
const { snippet, parseToc, isObject, isEmptyObject, localeId, pick, trimHtml } = require('../utils');
const date_formats = [
'll', // Sep 4, 1986
'L', // 09/04/1986
'MM-DD' // 06-17
]

// cache
let hasComments, hasReward, hasToc, copyright, dateHelper, uriReplacer;
Expand Down Expand Up @@ -36,6 +41,12 @@ module.exports = function (data) {
(s, p) => /\//.test(s) ? s : `/${p}/${s}` :
s => s;

// pre format date for i18n
data.date_formatted = date_formats.reduce((ret, format) => {
ret[format] = dateHelper(data.date, format)
return ret
}, {})

// relative link
data.link = trimHtml(data.path);
// permalink link
Expand Down Expand Up @@ -112,8 +123,13 @@ module.exports = function (data) {
const $img = $(this);
const src = $img.attr('src');

// assets & post_asset_folder
src && $img.attr('src', uriReplacer(src, assetPath));
if (src) {
// assets & post_asset_folder
$img.attr('src', uriReplacer(src, assetPath));

// native lazyload
// $img.attr('loading', 'lazy')
}

if (
this.root // {% img %}
Expand Down
78 changes: 40 additions & 38 deletions lib/generator/entries/archives.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { flattenDeep } = require('lodash');
const { pick } = require('../../utils');
const { date } = require('hexo/lib/plugins/helper/date');
const { pick, localeId } = require('../../utils');
const { archive: archiveProps } = require('./properties');

module.exports = function ({ theme, locals, helpers }) {
module.exports = function ({ site, theme, locals, helpers }) {
const posts = locals.posts.map(pick(archiveProps));
const config = theme.archive;
const dateHelper = date.bind({ page: { lang: localeId(site.language, true) }, config })

if (!posts.length) return [];

Expand All @@ -14,49 +16,49 @@ module.exports = function ({ theme, locals, helpers }) {
{ type: 'html', extend: { type: 'archives' } },
])
);
}

/**
* Classify posts with `year` and `month`
*
* @param {object} data
* @returns {data}
*/
function classify(data) {
const posts = data.data;
/**
* Classify posts with `year` and `month`
*
* @param {object} data
* @returns {data}
*/
function classify(data) {
const posts = data.data;

if (!posts.length) return [];
if (!posts.length) return [];

const desc = (a, b) => parseInt(a) < parseInt(b) ? 1 : -1;
const cfyPosts = {};
const desc = (a, b) => parseInt(a) < parseInt(b) ? 1 : -1;
const cfyPosts = {};

posts.forEach(post => {
const date = post.date.clone(),
year = date.year(),
month = date.month() + 1;
posts.forEach(post => {
const date = post.date.clone(),
year = date.year(),
month = date.month() + 1;

if (cfyPosts[year]) {
if (cfyPosts[year][month]) cfyPosts[year][month].push(post)
else cfyPosts[year][month] = [post]
} else {
cfyPosts[year] = {
[month]: [post]
if (cfyPosts[year]) {
if (cfyPosts[year][month]) cfyPosts[year][month].push(post)
else cfyPosts[year][month] = [post]
} else {
cfyPosts[year] = {
[month]: [post]
}
}
}

});
});

data.data = Object.keys(cfyPosts).sort(desc).map(year => {
return {
year: year,
months: Object.keys(cfyPosts[year]).sort(desc).map(month => {
return {
month: month,
entries: cfyPosts[year][month]
}
})
}
})
data.data = Object.keys(cfyPosts).sort(desc).map(year => {
return {
year: year,
months: Object.keys(cfyPosts[year]).sort(desc).map(month => {
return {
month: dateHelper(month, 'MMM'),
entries: cfyPosts[year][month]
}
})
}
})

return data;
return data;
}
}
10 changes: 5 additions & 5 deletions lib/generator/entries/properties.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const listProps = ['title', 'date', 'link'];
const listProps = ['title', 'date', 'date_formatted', 'link'];

module.exports = {
archive: listProps,
categoryPosts: listProps,
tagPosts: listProps,
page: ['title', 'date', 'updated', 'content', 'link', 'comments', 'dropcap', 'plink', 'toc', 'reward', 'copyright', 'meta'],
post: ['title', 'date', 'author', 'thumbnail', 'color', 'link', 'comments', 'dropcap', 'tags', 'categories', 'updated', 'content', 'prev', 'next', 'plink', 'toc', 'reward', 'copyright'],
postList: ['title', 'date', 'author', 'thumbnail', 'color', 'excerpt', 'link', 'tags', 'categories'],
search: ['title', 'date', 'author', 'updated', 'content', 'thumbnail', 'color', 'plink']
page: ['title', 'date', 'date_formatted', 'updated', 'content', 'link', 'comments', 'dropcap', 'plink', 'toc', 'reward', 'copyright', 'meta'],
post: ['title', 'date', 'date_formatted', 'author', 'thumbnail', 'color', 'link', 'comments', 'dropcap', 'tags', 'categories', 'updated', 'content', 'prev', 'next', 'plink', 'toc', 'reward', 'copyright'],
postList: ['title', 'date', 'date_formatted', 'author', 'thumbnail', 'color', 'excerpt', 'link', 'tags', 'categories'],
search: ['title', 'date', 'date_formatted', 'author', 'updated', 'content', 'thumbnail', 'color', 'plink']
}
3 changes: 0 additions & 3 deletions lib/theme-processor/index.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/theme-processor/localized-script.js

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-inside",
"version": "2.4.2",
"version": "2.5.0",
"description": "❤️ SPA, flat and clean theme for Hexo.",
"scripts": {
"test": "jasmine --config=test/jasmine.json"
Expand All @@ -26,8 +26,8 @@
"devDependencies": {
"babel-core": "6.26.3",
"babel-preset-env": "1.7.0",
"hexo": "3.9.0",
"hexo": "4.0.0",
"jasmine": "3.5.0",
"uglify-js": "3.6.2"
"uglify-js": "3.6.7"
}
}
1 change: 0 additions & 1 deletion scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ require('../lib/helper')(hexo);
require('../lib/generator')(hexo);
require('../lib/filter')(hexo);
require('../lib/tag')(hexo);
require('../lib/theme-processor')(hexo);
2 changes: 1 addition & 1 deletion source/_resources.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":"is-a","styles":["styles.d1f4718a192abf1f2afd.css"],"scripts":["runtime.caef73fae70e33459c5a.js","polyfills.28555e618578fe61f50a.js"],"locales":{"zh-Hant":"main.5ac6b548dbff945e028b.zh-Hant.js","zh-Hans":"main.7773219322474154c9eb.zh-Hans.js","en":"main.a6ef31dc523c76e5118c.js","ja":"main.c145738ea9113b8ce68e.ja.js"}}
{"root":"is-a","styles":["styles.6d727dade1159bc77736.css"],"scripts":["runtime.ee6f73bc31187f12810a.js","polyfills.14df1390f4da8e838f05.js","main.0c926d87f8cb6ab96db0.js"]}
Loading

0 comments on commit 78b7aca

Please sign in to comment.