diff --git a/layout/archive.ejs b/layout/archive.ejs deleted file mode 100644 index ace6b41..0000000 --- a/layout/archive.ejs +++ /dev/null @@ -1,56 +0,0 @@ -<% function buildArchive(posts, year, month = null) { - const time = moment([page.year, page.month ? page.month - 1 : null].filter(i => i !== null)); %> -
-
- -
- <% posts.each(post => { %> -
- <% if (has_thumbnail(post)) { %> - -

- <%= post.title %> -

-
- <% } %> -
-
- - <%= post.title %> - -
-
-
- <% }) %> -
-
-
-<% } -if (!page.year) { - let years = {}; - page.posts.each(p => years[p.date.year()] = null); - for (let year of Object.keys(years).sort((a, b) => b - a)) { - let posts = page.posts.filter(p => p.date.year() == year); %> - <%- buildArchive(posts, year, null) %> - <% } -} else { %> -<%- buildArchive(page.posts, page.year, page.month) %> -<% } %> -<% if (page.total > 1) { %> - <%- _partial('common/paginator') %> -<% } %> \ No newline at end of file diff --git a/layout/archive.jsx b/layout/archive.jsx new file mode 100644 index 0000000..ddca928 --- /dev/null +++ b/layout/archive.jsx @@ -0,0 +1,84 @@ +'use strict'; + +const moment = require('moment'); +const { Component, Fragment } = require('inferno'); +const Paginator = require('./misc/paginator'); + +module.exports = class extends Component { + render() { + const { page } = this.props; + // TODO + const helper = {}; + const config = {}; + const { url_for, __, has_thumbnail, get_thumbnail, date_xml, date } = helper; + + const language = page.lang || page.language || config.language; + + function renderArticleList(posts, year, month = null) { + const time = moment([page.year, page.month ? page.month - 1 : null].filter(i => i !== null)); + + return
+
+ +
+ {posts.map(post => { + const categories = []; + post.categories.forEach((category, i) => { + categories.push({category.name}); + if (i < post.categories.length - 1) { + categories.push('/'); + } + }); + return
+ {has_thumbnail(post) ? +

+ {post.title +

+
: null} +
+
+ + {post.title} + +
+
+
+ })} +
+
+
; + } + + let articleList; + if (!page.year) { + const years = {}; + page.posts.each(p => years[p.date.year()] = null); + articleList = Object.keys(years).sort((a, b) => b - a).map(year => { + let posts = page.posts.filter(p => p.date.year() == year); + return renderArticleList(posts, year, null); + }); + } else { + articleList = renderArticleList(page.posts, page.year, page.month); + } + + return + {articleList} + {page.total > 1 ? : null} + ; + } +} \ No newline at end of file diff --git a/layout/categories.ejs b/layout/categories.ejs deleted file mode 100644 index 09655f8..0000000 --- a/layout/categories.ejs +++ /dev/null @@ -1,30 +0,0 @@ -<% function build_list(categories) { - return categories.map(category => { - let result = `
  • - - - ${category.name} - - - ${category.count} - - `; - if (category.hasOwnProperty('children')) { - result += ''; - } - return result + '
  • '; - }).join(''); -} -%> -
    -
    - -
    -
    \ No newline at end of file diff --git a/layout/categories.jsx b/layout/categories.jsx new file mode 100644 index 0000000..04ce414 --- /dev/null +++ b/layout/categories.jsx @@ -0,0 +1,14 @@ +'use strict'; + +const { Component } = require('inferno'); +const Categories = require('./widget/categories'); + +module.exports = class extends Component { + render() { + const { site, page } = this.props; + // TODO + const helper = {}; + + return ; + } +} \ No newline at end of file diff --git a/layout/category.ejs b/layout/category.ejs deleted file mode 100644 index 3822544..0000000 --- a/layout/category.ejs +++ /dev/null @@ -1,14 +0,0 @@ -
    -
    - -
    -
    -<%- _partial('index', { page }) %> \ No newline at end of file diff --git a/layout/category.jsx b/layout/category.jsx new file mode 100644 index 0000000..65bd4b3 --- /dev/null +++ b/layout/category.jsx @@ -0,0 +1,30 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const Index = require('./index'); + +module.exports = class extends Component { + render() { + const { page } = this.props; + // TODO + const helper = {}; + const { url_for, _p } = helper; + + return +
    +
    + +
    +
    + +
    ; + } +} \ No newline at end of file diff --git a/layout/common/article.jsx b/layout/common/article.jsx index ae0efb5..d73d040 100644 --- a/layout/common/article.jsx +++ b/layout/common/article.jsx @@ -7,7 +7,7 @@ const Donates = require('./donates'); const Comment = require('./comment'); /** - * Get the word count of a paragraph. + * Get the word count of text. */ function getWordCount(content) { content = content.replace(/<\/?[a-z][^>]*>/gi, ''); diff --git a/layout/common/head.jsx b/layout/common/head.jsx index ba4d08c..bd23809 100644 --- a/layout/common/head.jsx +++ b/layout/common/head.jsx @@ -21,6 +21,8 @@ module.exports = class extends Component { highlight } = config; + const language = page.lang || page.language || config.language; + let hlTheme, images; if (highlight && highlight.enable === false) { hlTheme = null; @@ -64,7 +66,7 @@ module.exports = class extends Component { url={url} images={page.photos || images} siteName={config.title} - language={page.lang || page.language || config.language} + language={language} twitterId={open_graph.twitter} googlePlus={open_graph.google_plus} facebookAdmins={open_graph.fb_admins} diff --git a/layout/common/navbar.jsx b/layout/common/navbar.jsx index 0eb70f4..90c63b4 100644 --- a/layout/common/navbar.jsx +++ b/layout/common/navbar.jsx @@ -66,7 +66,7 @@ class Navbar extends Component { } module.exports = cacheComponent(Navbar, 'common.navbar', props => { - const { config, helper, page } = this.props; + const { config, helper, page } = props; const { url_for, _p, __ } = helper; const { logo, title, navbar, widgets, search } = config; diff --git a/layout/common/search.jsx b/layout/common/search.jsx new file mode 100644 index 0000000..e719589 --- /dev/null +++ b/layout/common/search.jsx @@ -0,0 +1,22 @@ +'use strict'; + +const logger = require('hexo-log'); +const { Component } = require('inferno'); + +module.exports = class extends Component { + render() { + const { config, helper } = this.props; + const { search } = config; + if (!search || typeof search.type !== 'string') { + return null; + } + + try { + const Search = require('../search/' + search.type); + return ; + } catch (e) { + logger.warn(`Icarus cannot load search "${search.type}"`); + return null; + } + } +}; diff --git a/layout/index.ejs b/layout/index.ejs deleted file mode 100644 index 4305b6c..0000000 --- a/layout/index.ejs +++ /dev/null @@ -1,6 +0,0 @@ -<% page.posts.each(function(post){ %> - <%- _partial('common/article', { post, index: true }) %> -<% }); %> -<% if (page.total > 1) { %> - <%- _partial('common/paginator') %> -<% } %> \ No newline at end of file diff --git a/layout/index.jsx b/layout/index.jsx new file mode 100644 index 0000000..3ff2676 --- /dev/null +++ b/layout/index.jsx @@ -0,0 +1,26 @@ +'use strict'; + +const { Component, Fragment } = require('inferno'); +const Article = require('./common/article'); +const Paginator = require('./misc/paginator'); + +module.exports = class extends Component { + render() { + const { page } = this.props; + // TODO + const helper = {}; + const config = {}; + + return + {page.posts.each(post =>
    )} + {page.total > 1 ? : null} + ; + } +} \ No newline at end of file diff --git a/layout/layout.ejs b/layout/layout.ejs deleted file mode 100644 index 7370c98..0000000 --- a/layout/layout.ejs +++ /dev/null @@ -1,35 +0,0 @@ - -> - - <%- _partial('common/head') %> - - - <%- _partial('common/navbar') %> - <% function main_column_class() { - switch (column_count()) { - case 1: - return 'is-12'; - case 2: - return 'is-8-tablet is-8-desktop is-8-widescreen'; - case 3: - return 'is-8-tablet is-8-desktop is-6-widescreen' - } - return ''; - } %> -
    -
    -
    -
    <%- body %>
    - <%- _partial('common/widget', { position: 'left' }) %> - <%- _partial('common/widget', { position: 'right' }) %> -
    -
    -
    - <%- _partial('common/footer') %> - <%- _partial('common/scripts') %> - - <% if (has_config('search.type')) { %> - <%- _partial('search/' + get_config('search.type')) %> - <% } %> - - \ No newline at end of file diff --git a/layout/layout.jsx b/layout/layout.jsx new file mode 100644 index 0000000..147d9cf --- /dev/null +++ b/layout/layout.jsx @@ -0,0 +1,49 @@ +'use strict'; + +const { Component } = require('inferno'); +const Head = require('./common/head'); +const Navbar = require('./common/navbar'); +const Widgets = require('./common/widgets'); +const Footer = require('./common/footer'); +const Scripts = require('./common/scripts'); +const Search = require('./common/search'); + +module.exports = class extends Component { + render() { + const { env, site, page, body } = this.props; + // TODO + const helper = {}; + const config = {}; + + const language = page.lang || page.language || config.language; + const columnCount = Widgets.getColumnCount(config.widgets); + + return + + + + + +
    +
    +
    +
    + + +
    +
    +
    +