Skip to content

Commit

Permalink
[fix] 子目录部署 loadScript, search (#264)
Browse files Browse the repository at this point in the history
* 优化子目录部署资源问题

---------

Co-authored-by: 钟意 <thatcoder@163.com>
  • Loading branch information
ThatCoders and ThatCoders committed Feb 13, 2023
1 parent d883483 commit e0ee1d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions layout/_partial/scripts/index.ejs
Expand Up @@ -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)) {
Expand Down Expand Up @@ -100,6 +103,7 @@
day: '<%- __('meta.date_suffix.day') %>',
month: '<%- __('meta.date_suffix.month') %>',
},
root : '<%- config.root %>',
};
// required plugins (only load if needs)
Expand Down
5 changes: 3 additions & 2 deletions source/js/main.js
Expand Up @@ -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');
});
Expand Down

0 comments on commit e0ee1d8

Please sign in to comment.