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