-
+ return
+
+
{__('donate.' + type)}
-
+
;
}
}
diff --git a/layout/search/baidu.ejs b/layout/search/baidu.ejs
deleted file mode 100644
index 3cc40aa..0000000
--- a/layout/search/baidu.ejs
+++ /dev/null
@@ -1,29 +0,0 @@
-<%- _css('css/search') %>
-
-
\ No newline at end of file
diff --git a/layout/search/baidu.jsx b/layout/search/baidu.jsx
new file mode 100644
index 0000000..77097f2
--- /dev/null
+++ b/layout/search/baidu.jsx
@@ -0,0 +1,50 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class Baidu extends Component {
+ render() {
+ const { url, __, url_for } = this.props;
+
+ const js = `(function ($) {
+ $('.search-form').on('submit', function (e) {
+ var keyword = $('.searchbox-input[name="wd"]').val();
+ window.location = 'https://www.baidu.com/s?wd=site:${url.replace(/http(s)*:\/\//, '')} ' + keyword;
+ return false;
+ });
+ })(jQuery);
+ (function (document, $) {
+ $(document).on('click', '.navbar-main .search', function () {
+ $('.searchbox').toggleClass('show');
+ }).on('click', '.searchbox .searchbox-mask', function () {
+ $('.searchbox').removeClass('show');
+ }).on('click', '.searchbox-close', function () {
+ $('.searchbox').removeClass('show');
+ });
+ })(document, jQuery);`;
+
+ return
+
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(Baidu, 'search.baidu', props => {
+ return {
+ url: props.config.url,
+ __: props.__,
+ url_for: props.url_for
+ };
+});
diff --git a/layout/search/baidu.locals.js b/layout/search/baidu.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/search/baidu.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/search/google-cse.ejs b/layout/search/google-cse.ejs
deleted file mode 100644
index 9126f9a..0000000
--- a/layout/search/google-cse.ejs
+++ /dev/null
@@ -1,67 +0,0 @@
-<%- _css('css/search') %>
-
-
-
-
-
-
- <% if (has_config('search.cx')) { %>
-
-
-
- <% } else { %>
-
- It seems that you forget to set the cx
value for the Google CSE. Please set it in _config.yml
.
-
- <% } %>
-
- <% if (has_config('search.cx')) { %>
-
- <% } %>
-
-
\ No newline at end of file
diff --git a/layout/search/google-cse.jsx b/layout/search/google-cse.jsx
new file mode 100644
index 0000000..3ba0b17
--- /dev/null
+++ b/layout/search/google-cse.jsx
@@ -0,0 +1,88 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class Google extends Component {
+ render() {
+ const { cx, __, url_for } = this.props;
+
+ const js1 = `(function() {
+ var cx = '${cx}';
+ var gcse = document.createElement('script');
+ gcse.type = 'text/javascript';
+ gcse.async = true;
+ gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(gcse, s);
+ })();`;
+
+ const js2 = `(function (document, $) {
+ function debounce(func, wait, immediate) {
+ var timeout;
+ return function() {
+ var context = this, args = arguments;
+ var later = function() {
+ timeout = null;
+ if (!immediate) func.apply(context, args);
+ };
+ var callNow = immediate && !timeout;
+ clearTimeout(timeout);
+ timeout = setTimeout(later, wait);
+ if (callNow) func.apply(context, args);
+ };
+ };
+
+ $(document).on('click', '.navbar-main .search', function () {
+ $('.searchbox').toggleClass('show');
+ }).on('click', '.searchbox .searchbox-mask', function () {
+ $('.searchbox').removeClass('show');
+ }).on('click', '.searchbox-close', function () {
+ $('.searchbox').removeClass('show');
+ }).on('keydown', '.searchbox-input', debounce(function () {
+ var value = $(this).val();
+ try {
+ var element = google.search.cse.element.getElement('searchresults-only0');
+ if (value.trim() === '') {
+ element.clearAllResults();
+ } else {
+ element.execute(value);
+ }
+ } catch (e) {}
+ }, 300));
+ })(document, jQuery);`;
+
+ return
+
+
+
+
+
+
+
+ {(() => {
+ if (cx) {
+ const innerHtml = '
';
+ return
;
+ }
+ return
+ It seems that you forget to set the cx
value for the Google CSE.
+ Please set it in _config.yml
.
+
;
+
+ })()}
+
+ {cx ? : null}
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(Google, 'search.google', props => {
+ return {
+ cx: props.cx,
+ __: props.__,
+ url_for: props.url_for
+ };
+});
diff --git a/layout/search/google-cse.locals.js b/layout/search/google-cse.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/search/google-cse.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/search/insight.ejs b/layout/search/insight.ejs
deleted file mode 100644
index b522b62..0000000
--- a/layout/search/insight.ejs
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-<%- _js('js/insight', true) %>
-<%- _css('css/search') %>
-<%- _css('css/insight') %>
\ No newline at end of file
diff --git a/layout/search/insight.jsx b/layout/search/insight.jsx
new file mode 100644
index 0000000..757510a
--- /dev/null
+++ b/layout/search/insight.jsx
@@ -0,0 +1,49 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class Insight extends Component {
+ render() {
+ const { __, url_for } = this.props;
+
+ const js = `(function (window) {
+ var INSIGHT_CONFIG = {
+ TRANSLATION: {
+ POSTS: '${__('insight.posts')}',
+ PAGES: '${__('insight.pages')}',
+ CATEGORIES: '${__('insight.categories')}',
+ TAGS: '${__('insight.tags')}',
+ UNTITLED: '${__('insight.untitled')}',
+ },
+ CONTENT_URL: '${url_for('/content.json')}',
+ };
+ window.INSIGHT_CONFIG = INSIGHT_CONFIG;
+ })(window);`;
+
+ return
+
+
+
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(Insight, 'search.insight', props => {
+ return {
+ __: props.__,
+ url_for: props.url_for
+ };
+});
diff --git a/layout/search/insight.locals.js b/layout/search/insight.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/search/insight.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/share/addthis.ejs b/layout/share/addthis.ejs
deleted file mode 100644
index cd21118..0000000
--- a/layout/share/addthis.ejs
+++ /dev/null
@@ -1,8 +0,0 @@
-<% if (!has_config('share.install_url')) { %>
-
- You need to set install_url
to use AddThis. Please set it in _config.yml
.
-
-<% } else { %>
-
-
-<% } %>
\ No newline at end of file
diff --git a/layout/share/addthis.jsx b/layout/share/addthis.jsx
new file mode 100644
index 0000000..224057e
--- /dev/null
+++ b/layout/share/addthis.jsx
@@ -0,0 +1,26 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class AddThis extends Component {
+ render() {
+ const { installUrl } = this.props;
+ if (!installUrl) {
+ return
+ You need to set install_url
to use AddThis.
+ Please set it in _config.yml
.
+
;
+ }
+ return
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(AddThis, 'share.addthis', props => {
+ return {
+ installUrl: props.install_url
+ };
+});
diff --git a/layout/share/addthis.locals.js b/layout/share/addthis.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/share/addthis.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/share/addtoany.ejs b/layout/share/addtoany.ejs
deleted file mode 100644
index 8ec37a2..0000000
--- a/layout/share/addtoany.ejs
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
diff --git a/layout/share/addtoany.jsx b/layout/share/addtoany.jsx
new file mode 100644
index 0000000..e91a182
--- /dev/null
+++ b/layout/share/addtoany.jsx
@@ -0,0 +1,24 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class AddToAny extends Component {
+ render() {
+ return
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(AddToAny, 'share.addtoany', props => {
+ return {};
+});
diff --git a/layout/share/addtoany.locals.js b/layout/share/addtoany.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/share/addtoany.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/share/bdshare.ejs b/layout/share/bdshare.ejs
deleted file mode 100644
index efaa5e6..0000000
--- a/layout/share/bdshare.ejs
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
\ No newline at end of file
diff --git a/layout/share/bdshare.jsx b/layout/share/bdshare.jsx
new file mode 100644
index 0000000..0d9a07a
--- /dev/null
+++ b/layout/share/bdshare.jsx
@@ -0,0 +1,25 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class BdShare extends Component {
+ render() {
+ const js = `window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];`;
+ return
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(BdShare, 'share.bdshare', props => {
+ return {};
+});
diff --git a/layout/share/bdshare.locals.js b/layout/share/bdshare.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/share/bdshare.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file
diff --git a/layout/share/sharejs.ejs b/layout/share/sharejs.ejs
deleted file mode 100644
index 35d141c..0000000
--- a/layout/share/sharejs.ejs
+++ /dev/null
@@ -1,3 +0,0 @@
-
-<%- _css(cdn('social-share.js', '1.0.16', 'dist/css/share.min.css')) %>
-<%- _js(cdn('social-share.js', '1.0.16', 'dist/js/social-share.min.js')) %>
\ No newline at end of file
diff --git a/layout/share/sharejs.jsx b/layout/share/sharejs.jsx
new file mode 100644
index 0000000..e6a2e37
--- /dev/null
+++ b/layout/share/sharejs.jsx
@@ -0,0 +1,23 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class ShareJs extends Component {
+ render() {
+ const { cdn } = this.props;
+ return
+
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(ShareJs, 'share.sharejs', props => {
+ return {
+ cdn: props.cdn,
+ // for cache purpose only
+ _providers: props.providers.cdn
+ };
+});
diff --git a/layout/share/sharejs.locals.js b/layout/share/sharejs.locals.js
deleted file mode 100644
index 705fadb..0000000
--- a/layout/share/sharejs.locals.js
+++ /dev/null
@@ -1,9 +0,0 @@
-module.exports = (ctx, locals) => {
- const { get_config } = ctx;
- return Object.assign(locals, {
- // just for diff detection
- _providers: {
- _cdn: get_config('providers.cdn')
- }
- });
-}
\ No newline at end of file
diff --git a/layout/share/sharethis.ejs b/layout/share/sharethis.ejs
deleted file mode 100644
index 6a77c57..0000000
--- a/layout/share/sharethis.ejs
+++ /dev/null
@@ -1,8 +0,0 @@
-<% if (!has_config('share.install_url')) { %>
-
- You need to set install_url
to use ShareThis. Please set it in _config.yml
.
-
-<% } else { %>
-
-
-<% } %>
\ No newline at end of file
diff --git a/layout/share/sharethis.jsx b/layout/share/sharethis.jsx
new file mode 100644
index 0000000..66c7aaf
--- /dev/null
+++ b/layout/share/sharethis.jsx
@@ -0,0 +1,26 @@
+'use strict';
+
+const { Component, Fragment } = require('inferno');
+const { cacheComponent } = require('../util/cache');
+
+class ShareThis extends Component {
+ render() {
+ const { installUrl } = this.props;
+ if (!installUrl) {
+ return
+ You need to set install_url
to use ShareThis.
+ Please set it in _config.yml
.
+
;
+ }
+ return
+
+
+ ;
+ }
+}
+
+module.exports = cacheComponent(ShareThis, 'share.sharethis', props => {
+ return {
+ installUrl: props.install_url
+ };
+});
diff --git a/layout/share/sharethis.locals.js b/layout/share/sharethis.locals.js
deleted file mode 100644
index bec3126..0000000
--- a/layout/share/sharethis.locals.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = (ctx, locals) => {
- return locals;
-}
\ No newline at end of file