Skip to content

Commit

Permalink
Improve performance by disabling custom search requests when native s…
Browse files Browse the repository at this point in the history
…earch is enabled
  • Loading branch information
eddiesigner committed Dec 11, 2022
1 parent 263d793 commit b2705f9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}

Expand All @@ -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}}"
Expand Down Expand Up @@ -129,7 +135,9 @@
{{{body}}}

{{!-- Search form --}}
{{> search}}
{{^if @custom.enable_native_search}}
{{> search}}
{{/if}}

{{!-- The footer --}}
{{> footer}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@
"desktop": "assets/screenshot-desktop.jpg",
"mobile": "assets/screenshot-mobile.jpg"
},
"version": "2.1.1"
"version": "2.1.2"
}
2 changes: 1 addition & 1 deletion src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit b2705f9

Please sign in to comment.