Last active
April 9, 2018 18:33
-
-
Save mikeisonthenets/17f1ece455646194d9e7aacc4388eb1d to your computer and use it in GitHub Desktop.
Standard Embed Template Override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){ | |
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t); | |
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e); | |
})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st'); | |
_st('install','YOUR_INSTALL_KEY','2.0.0', { | |
install: { | |
web: { | |
templates: { | |
default: { | |
search: { | |
result_item: { | |
page: "<a onclick='event.preventDefault(); window.open(\"{{ full_result.url | escapeUrl }}\");' class='st-ui-result' data-st-result-doc-id='{{result.doc_id}}'> <span class='st-ui-type-detail' title='{{ result.title }});'> </span> <span class='st-ui-type-heading'>{{ result.title }}</span> <span class='st-ui-type-detail'> {{ result.body }} </span> </a> " | |
} | |
}, | |
autocomplete: { | |
result_item: { | |
page: "<a onclick='event.preventDefault(); window.open(\"{{ full_result.url | escapeUrl }}\");' class='st-ui-result' data-st-result-doc-id='{{result.doc_id}}'> <span class='st-ui-type-detail' title='{{ result.title }});'> </span> <span class='st-ui-type-heading'>{{ result.title }}</span> <span class='st-ui-type-detail'> {{ result.body }} </span> </a> " | |
} | |
} | |
} | |
} | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above templates are still the standard embed HTML markup but with the inclusion of the
window.open()
method to automatically open clicked results into a new tab.It's important to note that it's still possible for the end user's browser configuration to be set to ignore or handle the
window.open
instruction differently.To Use:
Update the template above to replace
YOUR_INSTALL_KEY
with your embed scripts install key value, and configure the HTML templates as desired.