fix: load script synchronously (#482)
* fix: constant path * fix: load script synchronously
This commit is contained in:
parent
6679dbd07b
commit
692f1fda5a
|
@ -6,10 +6,7 @@
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
utils.css('<%- theme.comments.artalk.css %>');
|
utils.css('<%- theme.comments.artalk.css %>');
|
||||||
utils.js('<%- theme.comments.artalk.js %>', {defer: true}).then(function () {
|
utils.js('<%- theme.comments.artalk.js %>', {defer: true}).then(function () {
|
||||||
const path = el.getAttribute('comment_id');
|
const path = el.getAttribute('comment_id') ?? decodeURI(window.location.pathname);
|
||||||
if (!path) {
|
|
||||||
path = decodeURI(window.location.pathname);
|
|
||||||
}
|
|
||||||
const artalk = Artalk.init({
|
const artalk = Artalk.init({
|
||||||
el: '#artalk_container',
|
el: '#artalk_container',
|
||||||
pageKey: path,
|
pageKey: path,
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const el = document.getElementById('artalk_container');
|
const el = document.getElementById('twikoo_container');
|
||||||
util.viewportLazyload(el, load_twikoo, <%= theme.comments.lazyload ?? false %>);
|
util.viewportLazyload(el, load_twikoo, <%= theme.comments.lazyload ?? false %>);
|
||||||
|
|
||||||
function load_twikoo() {
|
function load_twikoo() {
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
utils.js('<%- theme.comments.twikoo.js %>', {defer: true}).then(function () {
|
utils.js('<%- theme.comments.twikoo.js %>', {defer: true}).then(function () {
|
||||||
const path = el.getAttribute('comment_id');
|
const path = el.getAttribute('comment_id') ?? decodeURI(window.location.pathname);
|
||||||
if (!path) {
|
|
||||||
path = decodeURI(window.location.pathname);
|
|
||||||
}
|
|
||||||
twikoo.init(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
|
twikoo.init(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
|
||||||
el: '#twikoo_container',
|
el: '#twikoo_container',
|
||||||
path: path,
|
path: path,
|
||||||
|
|
|
@ -10,11 +10,7 @@
|
||||||
utils.css('<%- theme.comments.waline.css %>');
|
utils.css('<%- theme.comments.waline.css %>');
|
||||||
utils.css('<%- theme.comments.waline.meta_css %>');
|
utils.css('<%- theme.comments.waline.meta_css %>');
|
||||||
|
|
||||||
const path = el.getAttribute('comment_id');
|
const path = el.getAttribute('comment_id') ?? decodeURI(window.location.pathname);
|
||||||
if (!path) {
|
|
||||||
path = decodeURI(window.location.pathname);
|
|
||||||
}
|
|
||||||
|
|
||||||
const waline = init(Object.assign(<%- JSON.stringify(theme.comments.waline) %>, {
|
const waline = init(Object.assign(<%- JSON.stringify(theme.comments.waline) %>, {
|
||||||
el: '#waline_container',
|
el: '#waline_container',
|
||||||
path: path,
|
path: path,
|
||||||
|
|
|
@ -21,7 +21,7 @@ function custom_inject() {
|
||||||
<%- partial('scripts/tagtree') %>
|
<%- partial('scripts/tagtree') %>
|
||||||
|
|
||||||
<!-- required -->
|
<!-- required -->
|
||||||
<script src="<%- `${theme.stellar.main_js}?v=${stellar_info('version')}` %>" async></script>
|
<script src="<%- `${theme.stellar.main_js}?v=${stellar_info('version')}` %>" defer></script>
|
||||||
|
|
||||||
<%- partial('scripts/theme') %>
|
<%- partial('scripts/theme') %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue