Skip to content

Commit

Permalink
chore: change search result domain (#840)
Browse files Browse the repository at this point in the history
Signed-off-by: rogerogers <[email protected]>
  • Loading branch information
rogerogers authored Oct 24, 2023
1 parent e39fc29 commit 5f85111
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions layouts/partials/hooks/body-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,47 @@

<script type="text/javascript">
let siteLang = window.location.pathname.startsWith("/zh/") ? "zh" : "en";
if (!["cloudwego.cn", "www.cloudwego.cn"].includes(location.host)) {
docsearch({
appId: "V7I042F992",
apiKey: "8380a7ac88106841cb43fb000fa2edb4",
indexName: "cloudwego",
container: "#docsearch",
searchParameters: {
hitsPerPage: 5,
facetFilters: [`lang:${siteLang}`],
},
//debug: true, // Set debug to true if you want to inspect the modal
//resultsFooterComponent({ state }) {
// return {
// // The HTML `tag`
// type: 'a',
// ref: undefined,
// constructor: undefined,
// key: state.query,
// // Its props
// props: {
// href: '',
// target: '_blank',
// onClick: (event) => {
// console.log(event);
// },
// // Raw text rendered in the HTML element
// children: `${state.context.nbHits} hits found!`,
// },
// __v: null,
// };
//},
});
}
docsearch({
appId: "V7I042F992",
apiKey: "8380a7ac88106841cb43fb000fa2edb4",
indexName: "cloudwego",
container: "#docsearch",
searchParameters: {
hitsPerPage: 5,
facetFilters: [`lang:${siteLang}`],
},
transformItems(items) {
return items.map((item) => {
return {
...item,
url: item.url
.replace("www.cloudwego.io", location.host)
.replace("https:", location.protocol),
};
});
},
//debug: true, // Set debug to true if you want to inspect the modal
//resultsFooterComponent({ state }) {
// return {
// // The HTML `tag`
// type: 'a',
// ref: undefined,
// constructor: undefined,
// key: state.query,
// // Its props
// props: {
// href: '',
// target: '_blank',
// onClick: (event) => {
// console.log(event);
// },
// // Raw text rendered in the HTML element
// children: `${state.context.nbHits} hits found!`,
// },
// __v: null,
// };
//},
});
</script>

{{ end }}
Expand Down

1 comment on commit 5f85111

@vercel
Copy link

@vercel vercel bot commented on 5f85111 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.