Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Last active July 31, 2016 13:43
Show Gist options
  • Save fdaciuk/53207bdb787e41ec0fa7 to your computer and use it in GitHub Desktop.
Save fdaciuk/53207bdb787e41ec0fa7 to your computer and use it in GitHub Desktop.

Hexo with Google search bar

;(function( $ ) {
$(function() {
$( '[data-js="google-search-form"]' ).on( 'submit', function( e ) {
e.preventDefault();
var inputVal = $( '[data-js="google-search-input"]' ).val();
window.location.href = $( this ).attr( 'data-action' ) + ' ' + inputVal;
});
});
})( jQuery );
<div class="search">
<form action=""
method="get"
data-action="https://google.com.br/search?q=site:<%- config.url.replace( /^https?:\/\//, '' ) %>"
accept-charset="utf-8"
data-js="google-search-form">
<input type="search" name="q" results="0" placeholder="<%= __('search') %>" data-js="google-search-input">
</form>
</div>
@romuloctba
Copy link

eita o form eh esse mesmo neh, vou soh adicionar o JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment