eddiesigner / liebling

Beautiful and clean Ghost theme that is easy and comfortable to use. To get the latest version please head over the releases page 👉🏼
https://github.com/eddiesigner/liebling/releases
MIT License
1.27k stars 602 forks source link

Support Native Search (Ghost V5) #465

Closed shincurry closed 2 years ago

shincurry commented 2 years ago

Support Ghost official Native Search feature. #462

screenshot 2022-08-16 5 23 16pm
eddiesigner commented 2 years ago

Thanks!

This looks good, however, there are a couple of things that can be changed in order to merge this PR:

  1. The code added in the file default.hbs is not really necessary, you can remove it

  2. In the file partials/header.hbs the search button will be rendered twice in case the new custom setting is enabled because the current button will be still there:

<button class="m-icon-button in-mobile-topbar js-open-search" aria-label="{{t "Open search"}}">
  <span class="icon-search" aria-hidden="true"></span>
</button>
{{#if @custom.enable_native_search}}
  <button class="m-icon-button in-mobile-topbar" data-ghost-search aria-label="{{t "Open search"}}">
    <span class="icon-search" aria-hidden="true"></span>
  </button>
{{/if}}

I would suggest to do something like this:

<button class="m-icon-button in-mobile-topbar {{^if @custom.enable_native_search}}js-open-search{{/if}}" {{#if @custom.enable_native_search}}data-ghost-search{{/if}} aria-label="{{t "Open search"}}">
  <span class="icon-search" aria-hidden="true"></span>
</button>

This way you avoid duplicated code and the button will be rendered only once.