Improve performance by disabling custom search requests when native search is enabled

This commit is contained in:
Eduardo Gomez 2022-12-11 14:14:11 +01:00
parent 263d7938c6
commit b2705f9d83
5 changed files with 14 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -75,7 +75,7 @@
{{!-- This #block helper will inject a stylesheet for a specific page --}}
{{{block "styles"}}}
{{!-- This #block helper will pull data from the hero partial
{{!-- This #block helper will pull data from the hero partial
to inject styles of the hero image to make it responsive --}}
{{{block "herobackground"}}}
@ -96,6 +96,12 @@
// @license-end
</script>
{{#if @custom.enable_native_search}}
<script>
const nativeSearchEnabled = true
</script>
{{/if}}
{{#if @custom.search_api_key}}
<script>
const ghostSearchApiKey = "{{@custom.search_api_key}}"
@ -129,7 +135,9 @@
{{{body}}}
{{!-- Search form --}}
{{> search}}
{{^if @custom.enable_native_search}}
{{> search}}
{{/if}}
{{!-- The footer --}}
{{> footer}}

View File

@ -87,5 +87,5 @@
"desktop": "assets/screenshot-desktop.jpg",
"mobile": "assets/screenshot-mobile.jpg"
},
"version": "2.1.1"
"version": "2.1.2"
}

View File

@ -2,7 +2,7 @@ version: "3"
services:
ghost:
image: ghost:5.22.1
image: ghost:5.22.10
container_name: ghost
volumes:
- ./..:/var/lib/ghost/content/themes/liebling:Z

View File

@ -66,7 +66,7 @@ $(() => {
};
const trySearchFeature = () => {
if (typeof ghostSearchApiKey !== 'undefined') {
if (typeof ghostSearchApiKey !== 'undefined' && typeof nativeSearchEnabled === 'undefined') {
getAllPosts(ghostHost, ghostSearchApiKey);
} else {
$openSearch.css('visibility', 'hidden');