mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Support absolute path for search DB
This commit is contained in:
parent
460087d6f0
commit
c1a2073a10
@ -8,12 +8,12 @@ const { parse } = require('url');
|
||||
* Export theme config to js
|
||||
*/
|
||||
hexo.extend.helper.register('next_config', function() {
|
||||
const { config, theme, next_version, __ } = this;
|
||||
const { config, theme, __ } = this;
|
||||
const exportConfig = {
|
||||
hostname : parse(config.url).hostname || config.url,
|
||||
root : config.root,
|
||||
scheme : theme.scheme,
|
||||
version : next_version,
|
||||
version : this.next_version,
|
||||
exturl : theme.exturl,
|
||||
sidebar : theme.sidebar,
|
||||
copycode : theme.codeblock.copy_button.enable,
|
||||
@ -41,7 +41,7 @@ hexo.extend.helper.register('next_config', function() {
|
||||
};
|
||||
}
|
||||
if (config.search && theme.local_search && theme.local_search.enable) {
|
||||
exportConfig.path = config.search.path;
|
||||
exportConfig.path = this.url_for(config.search.path);
|
||||
exportConfig.localsearch = theme.local_search;
|
||||
}
|
||||
return `<script class="hexo-configurations">
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
if (!CONFIG.path) {
|
||||
// Search DB path
|
||||
console.warn('`hexo-generator-searchdb` plugin is not installed!');
|
||||
return;
|
||||
}
|
||||
@ -196,10 +197,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
};
|
||||
|
||||
const fetchData = () => {
|
||||
// Search DB path
|
||||
const searchPath = CONFIG.root + CONFIG.path;
|
||||
const isXml = !CONFIG.path.endsWith('json');
|
||||
fetch(searchPath)
|
||||
fetch(CONFIG.path)
|
||||
.then(response => response.text())
|
||||
.then(res => {
|
||||
// Get the contents from search data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user