feat: add search widget plugin adaptation support

This commit is contained in:
Ryan Wang
2022-11-08 22:56:44 +08:00
parent afde519538
commit 56a13cddbb
4 changed files with 13 additions and 4 deletions

1
env.d.ts vendored
View File

@@ -6,5 +6,6 @@ export {};
declare global {
interface Window {
Alpine: Alpine;
SearchWidget: any;
}
}

View File

@@ -34,3 +34,11 @@ export function generateToc() {
scrollSmoothOffset: -100,
});
}
// 此主题的搜索依赖 https://github.com/halo-sigs/plugin-search-widget 插件,在 Halo 支持主题依赖插件之前,使用 alert 以提示使用者。
export function openSearch() {
if(!window.SearchWidget) {
alert("未安装或启用搜索插件无法使用搜索功能。https://github.com/halo-sigs/plugin-search-widget");
}
window.SearchWidget.open()
}

File diff suppressed because one or more lines are too long

View File

@@ -87,7 +87,7 @@
</a>
</li>
<li>
<a href="#" class="text-gray-600 hover:text-blue-600">
<a href="javascript:main.openSearch()" class="text-gray-600 hover:text-blue-600">
<span data-icon="tabler:search" class="iconify text-lg"></span>
</a>
</li>