Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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