Hey - such an easy fix! Thats amazing, thank you for your support - and thank you for building such a useful tool for Ghost.
OMG! This. Is. EVERYTHING.
Thank you! This is exactly what I was looking for and it is
Here it is in action: https://www.womenconquerbiz.com/
I used the Set a menu search âiconâ and even though I have a custom theme (thankfully) it worked PERFECTLY.
Thanks again! Iâve already shared it with a colleague who struggled with GhostHunter. And Iâll let others know as well.
Jen
It is really simple to add it into website, but I have an issue on the Chinese searching, do you think is that possible can i tune it ?
Hi,
How to add Russian (Cyrillic if Iâm right) symbols to search?
Thank you forward.
Hello!
For any non-latin language, you have to add an extra configuration parameter. Please, refer to the underlying âsearchinghostâ documentation on Github.
For chinese only content, you can use this configuration:
{
contentApiKey: '<your_api_key>',
searchinghostOptions: {
indexOptions: {
encode: false,
tokenize: function(str) {
return str.replace(/[\x00-\x7F]/g, "").split("");
}
}
}
}
For cyrillic only, that configuration:
{
contentApiKey: '<your_api_key>',
searchinghostOptions: {
indexOptions: {
encode: false,
split: /\s+/
}
}
}
And if you want to use a mix of chinese/cyrillic + any latin language, you should go with:
{
contentApiKey: '<your_api_key>',
searchinghostOptions: {
indexOptions: {
split: /\s+/,
encode: function (str) {
var regexp_replacements = {
"a": /[à åùãÀÄ]/g,
"e": /[ÚéĂȘĂ«]/g,
"i": /[ĂŹĂßï]/g,
"o": /[ĂČóÎÔöĆ]/g,
"u": /[ĂčĂșĂ»ĂŒĆ±]/g,
"y": /[ĂœĆ·Ăż]/g,
"n": /ñ/g,
"c": /[ç]/g,
"s": /Ă/g,
" ": /[-/]/g,
"": /['!"#$%&\\()\*+,-./:;<=>?@[\]^_`{|}~]/g,
" ": /\s+/g,
}
str = str.toLowerCase();
for (var key of Object.keys(regexp_replacements)) {
str = str.replace(regexp_replacements[key], key);
}
return str === " " ? "" : str;
}
}
}
}
I hope it will be clear enough to help you solve these issues.
Hi,
I am using SearchinGhostEASY with the code below at insert footer, it seems only latin & number works for the search, do you see am I missing anything here?
<script src="https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@latest/dist/searchinghost-easy-backpack.js"></script>
<script>
new SearchinGhostEasy({
contentApiKey: 'xxxxx',
indexOptions: {
split: /\s+/,
encode: function(str) {
var regexp_replacements = {
"a": /[à åùãÀÄ]/g,
"e": /[ÚéĂȘĂ«]/g,
"i": /[ĂŹĂßï]/g,
"o": /[ĂČóÎÔöĆ]/g,
"u": /[ĂčĂșĂ»ĂŒĆ±]/g,
"y": /[ĂœĆ·Ăż]/g,
"n": /ñ/g,
"c": /[ç]/g,
"s": /Ă/g,
" ": /[-/]/g,
"": /['!"#$%&\\()\*+,-./:;<=>?@[\]^_`{|}~]/g,
" ": /\s+/g,
}
str = str.toLowerCase();
for (var key of Object.keys(regexp_replacements)) {
str = str.replace(regexp_replacements[key], key);
}
return str === " " ? "" : str;
}
},
});
</script>
@yong, the âsearchinghostOptionsâ object declaration is missing. Please copy/paste the following code:
<script src="https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@latest/dist/searchinghost-easy-backpack.js"></script>
<script>
new SearchinGhostEasy({
contentApiKey: 'xxxxx',
searchinghostOptions: {
indexOptions: {
split: /\s+/,
encode: function (str) {
var regexp_replacements = {
"a": /[à åùãÀÄ]/g,
"e": /[ÚéĂȘĂ«]/g,
"i": /[ĂŹĂßï]/g,
"o": /[ĂČóÎÔöĆ]/g,
"u": /[ĂčĂșĂ»ĂŒĆ±]/g,
"y": /[ĂœĆ·Ăż]/g,
"n": /ñ/g,
"c": /[ç]/g,
"s": /Ă/g,
" ": /[-/]/g,
"": /['!"#$%&\\()\*+,-./:;<=>?@[\]^_`{|}~]/g,
" ": /\s+/g,
}
str = str.toLowerCase();
for (var key of Object.keys(regexp_replacements)) {
str = str.replace(regexp_replacements[key], key);
}
return str === " " ? "" : str;
}
}
}
});
</script>
Then, when you will do some testing, ensure to always use a âprivate navâ tab or to clear all the data stored for your website domain.
Thank you! That was my bad, I was not attentive and didnât saw that indexOptions was inside searchinghostOptions:
Thank you again!
Hello @gmfmi
Thank you for making our lives easier with this easy to install plugin! I have some questions and hope you can help me with it.
I am currently using
Ghost version - 4.47.1
Theme - Edition NEWSLETTER
-
Does SearchinGhostEASY allow us to search by tags? For example, right now my blog only has 1 tag which is Google Cloud Platform. So when I search for Google Cloud Platform, it should show all the articles related to this tag? I tried to search by tags but it doesnât seem to return all the article related to the tag.
-
I also did this code injection at the Site Footer following your guide at https://github.com/gmfmi/searchinGhost#options
I have used version 1.1.2 which is the latest version as of now for consistency sake in the future.
<script src="https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@1.1.2/dist/searchinghost-easy-basic.js"></script>
<script>
new SearchinGhostEasy({
contentApiKey: '',
searchinghostOptions: {
template: function (post) {
return `<a href="${post.url}">#${post.tags} - ${post.published_at} - ${post.title}</a>`
}
}
});
</script>
When I tried to search, it show me this instead
It seems that itâs not able to index the post.tags? Not sure what I did wrong.
I did further testing by editing above code into below code, but still could not make it work. I suppose the default postsFields, postExtraFields and indexedFields have already included everything.
<script src="https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@1.1.2/dist/searchinghost-easy-basic.js"></script>
<script>
new SearchinGhostEasy({
contentApiKey: '',
searchinghostOptions: {
postsFields:['title', 'url', 'excerpt', 'custom_excerpt', 'published_at', 'feature_image'],
postExtraFields: ['tags'],
indexedFields: ['title', 'string_tags', 'excerpt', 'plaintext'],
template: function (post) {
return `<a href="${post.url}">#${post.tags} - ${post.published_at} - ${post.title}</a>`
}
}
});
</script>
Hope you could help to clarify my doubts and thank you in advance!
today this has helped me again with the insert an icon into nav menu feature. thanks @gmfmi for your contribution and continued work. merci
Hey @cmy113,
You code sample is close to something that work. You issue is the âtagsâ element is an array of objects. Here is how it looks like in your case:
[{id: "626542270e81830001dfac57", name: "Google Cloud Platform", slug: "google-cloud-platform", âŠ}]
To display the 1st tagâs name, you can for example, use ${post.tags[0].name}
.
Hope it will help you.
Hi,
great package, thanks!
Just one question: Is there a way to self host your script? Even if i self-host https://cdn.jsdelivr.net/gh/gmfmi/searchinghost-easy@latest/dist/searchinghost-easy-backpack.js , this one will load another .js file from jsdelivr.
Hi @marius1!
Sure, you can totally self-host this script and it will automatically load the 2nd one from JSdelivr. A better option would be to host both the âeasyâ and the âsearchâ scripts. This way you do not rely on any CDN.
Please note that this plugin is no longer maintained as Ghost V5 natively support a search feature. If you are not on the V5 yet, you should probably consider the migration (if possible).
Hi there,
is there any chance I can realize this use case with this SearchinGhost:
Show only search results from the current logged-in userâs tier
Context: I want users to be able to search only for posts of their actual tier. Posts from other tiers shouldnât come up in the search results at all (really, I want to hide them!).
Besides having the postsâ access restricted to the tiers, I additionally have all posts marked with a special tag (tier1, tier2, tier3, âŠ).
If user1 (subscribed to tier1) now hits the search button, I want her to see only search results for posts that have the tag #tier1.
Thanks in advance and best regards
This is possible, but it would require theme customization.
I figured out that this here could solve my use case:
searchOptions: {
where: {
string_tags: "tag1"
}
}
I will offer the search form only on specific pages. Since all my pages have a url like âŠcom/tag_name/âŠ, Iâd like to dynamically include that âtag_nameâ in the above mentioned search options, so:
searchOptions: {
where: {
string_tags: "{{dynamic_tag_name_of_current_page}}"
}
}
Does anybody know how I can get this info?
Iâm assuming this is built into the theme. (It wonât work as code injection.)
You can use {{page.slug}} or {{slug}} if youâre already in the page context.
Yeah, thought the same, but both didnât work.
Itâd be helpful to see the code of the page. :)