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

View File

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

View File

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

View File

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