diff --git a/include/schema/common/plugins.json b/include/schema/common/plugins.json
index ad5671d..3b70e34 100644
--- a/include/schema/common/plugins.json
+++ b/include/schema/common/plugins.json
@@ -43,6 +43,9 @@
"outdated_browser": {
"$ref": "/plugin/outdated_browser.json"
},
+ "pjax": {
+ "$ref": "/plugin/pjax.json"
+ },
"progressbar": {
"$ref": "/plugin/progressbar.json"
},
diff --git a/include/schema/plugin/pjax.json b/include/schema/plugin/pjax.json
new file mode 100644
index 0000000..b72693b
--- /dev/null
+++ b/include/schema/plugin/pjax.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "$id": "/plugin/pjax.json",
+ "description": "Enable PJAX",
+ "type": "boolean",
+ "default": true
+}
\ No newline at end of file
diff --git a/layout/common/head.jsx b/layout/common/head.jsx
index 5ccf42d..6285476 100644
--- a/layout/common/head.jsx
+++ b/layout/common/head.jsx
@@ -166,9 +166,9 @@ module.exports = class extends Component {
{rss ? : null}
{favicon ? : null}
- {hlTheme ? : null}
+ {hlTheme ? : null}
-
+
{adsenseClientId ? }
-
+
-
+
;
}
};
diff --git a/layout/plugin/back_to_top.jsx b/layout/plugin/back_to_top.jsx
index c3b6e8d..4581815 100644
--- a/layout/plugin/back_to_top.jsx
+++ b/layout/plugin/back_to_top.jsx
@@ -9,7 +9,7 @@ class BackToTop extends Component {
-
+
;
}
diff --git a/layout/plugin/pjax.jsx b/layout/plugin/pjax.jsx
new file mode 100644
index 0000000..18cf401
--- /dev/null
+++ b/layout/plugin/pjax.jsx
@@ -0,0 +1,18 @@
+const { Component, Fragment } = require('inferno');
+
+class Pjax extends Component {
+ render() {
+ if (this.props.head) {
+ return null;
+ }
+ const { helper } = this.props;
+ const { url_for, cdn } = helper;
+
+ return
+
+
+ ;
+ }
+}
+
+module.exports = Pjax;
diff --git a/source/js/pjax.js b/source/js/pjax.js
new file mode 100644
index 0000000..82d9ae8
--- /dev/null
+++ b/source/js/pjax.js
@@ -0,0 +1,38 @@
+(function() {
+ // eslint-disable-next-line no-unused-vars
+ let pjax;
+
+ function initPjax() {
+ try {
+ const Pjax = window.Pjax || function() {};
+ pjax = new Pjax({
+ selectors: [
+ 'head title',
+ '.columns',
+ '.navbar-start',
+ '.navbar-end',
+ '.searchbox',
+ '#back-to-top',
+ '[data-pjax]',
+ '.pjax-reload'
+ ]
+ });
+ } catch (e) {
+ console.warn('PJAX error: ' + e);
+ }
+ }
+
+ // // Listen for start of Pjax
+ // document.addEventListener('pjax:send', function() {
+ // return;
+ // // TODO pace start loading animation
+ // })
+
+ // // Listen for completion of Pjax
+ // document.addEventListener('pjax:complete', function() {
+ // return;
+ // // TODO pace stop loading animation
+ // })
+
+ document.addEventListener('DOMContentLoaded', () => initPjax());
+}());