-
-
- <%- list_categories(post.categories(), { - show_count: false, - class: 'has-link-grey ', - depth:2, - style: 'none', - separator: ' / '}) %> -
-diff --git a/layout/.eslintrc b/layout/.eslintrc index 952e99b..00f715b 100644 --- a/layout/.eslintrc +++ b/layout/.eslintrc @@ -26,7 +26,9 @@ { "allowModules": [ "inferno", - "inferno-create-element" + "inferno-create-element", + "hexo-util", + "cheerio" ] } ] diff --git a/layout/plugin/back-to-top.jsx b/layout/plugin/back_to_top.jsx similarity index 100% rename from layout/plugin/back-to-top.jsx rename to layout/plugin/back_to_top.jsx diff --git a/layout/plugin/baidu-analytics.jsx b/layout/plugin/baidu_analytics.jsx similarity index 100% rename from layout/plugin/baidu-analytics.jsx rename to layout/plugin/baidu_analytics.jsx diff --git a/layout/plugin/google-analytics.jsx b/layout/plugin/google_analytics.jsx similarity index 100% rename from layout/plugin/google-analytics.jsx rename to layout/plugin/google_analytics.jsx diff --git a/layout/plugin/outdated-browser.jsx b/layout/plugin/outdated_browser.jsx similarity index 100% rename from layout/plugin/outdated-browser.jsx rename to layout/plugin/outdated_browser.jsx diff --git a/layout/util/cache.jsx b/layout/util/cache.jsx index 3994b94..97e1e48 100644 --- a/layout/util/cache.jsx +++ b/layout/util/cache.jsx @@ -20,13 +20,16 @@ module.exports = { * @param {string} prefix Cache ID prefix * @param {Function} transform Transform the input props to target props and * its result is used to compute cache ID - * @returns Cached JSX element if cache ID is found. - * Return null if the props transform result is empty, which means the props + * @returns A cache-enabled component. + * It returns cached JSX element when called if cache ID is found. + * It returns null if the props transform result is empty, which means the props * passed to the createElement() indicates the element does not need to be created. - * Otherwise, create a new element and cache it if the transform function is provided. + * Otherwise, it creates a new element and caches it if the transform function is provided. + * The original component can be accessed from the `_type` property of the return value. + * The props transform function can be accessed from the `_transform` property of the return value. */ cacheComponent(type, prefix, transform) { - return props => { + const component = props => { const targetProps = transform(props); if (!targetProps) { return null; @@ -40,5 +43,8 @@ module.exports = { } return cache[cacheId]; }; + component._type = type; + component._transform = transform; + return component; } }; diff --git a/layout/widget/archive.ejs b/layout/widget/archive.ejs deleted file mode 100644 index 20298e0..0000000 --- a/layout/widget/archive.ejs +++ /dev/null @@ -1,23 +0,0 @@ -
\ No newline at end of file diff --git a/layout/widget/archive.locals.js b/layout/widget/archive.locals.js deleted file mode 100644 index bec3126..0000000 --- a/layout/widget/archive.locals.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = (ctx, locals) => { - return locals; -} \ No newline at end of file diff --git a/layout/widget/archives.jsx b/layout/widget/archives.jsx new file mode 100644 index 0000000..92d5cd8 --- /dev/null +++ b/layout/widget/archives.jsx @@ -0,0 +1,99 @@ +'use strict'; + +const { Component } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class Archives extends Component { + render() { + const { + items, + title, + showCount + } = this.props; + + return