diff --git a/layout/_partial/scripts/index.ejs b/layout/_partial/scripts/index.ejs index 8eabc29..02cdded 100644 --- a/layout/_partial/scripts/index.ejs +++ b/layout/_partial/scripts/index.ejs @@ -62,6 +62,9 @@ // 从 butterfly 和 volantis 获得灵感 loadScript: (src, opt) => new Promise((resolve, reject) => { var script = document.createElement('script'); + if (src.startsWith('/')){ + src = stellar.config.root + src.substring(1); + } script.src = src; if (opt) { for (let key of Object.keys(opt)) { @@ -100,6 +103,7 @@ day: '<%- __('meta.date_suffix.day') %>', month: '<%- __('meta.date_suffix.month') %>', }, + root : '<%- config.root %>', }; // required plugins (only load if needs) diff --git a/source/js/main.js b/source/js/main.js index 4196ff6..0ad4eed 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -334,9 +334,10 @@ if (stellar.search.service) { var $resultArea = document.querySelector("div#search-result"); $inputArea.focus(function() { var path = stellar.search[stellar.search.service]?.path || '/search.json'; - if (!path.startsWith('/')) { - path = '/' + path; + if (path.startsWith('/')) { + path = path.substring(1); } + path = stellar.config.root + path; const filter = $inputArea.attr('data-filter') || ''; searchFunc(path, filter, 'search-input', 'search-result'); });