momo-jun commented on code in PR #481:
URL: https://github.com/apache/pulsar-site/pull/481#discussion_r1144513470


##########
src/theme/DocPage/index.tsx:
##########
@@ -0,0 +1,74 @@
+import React from 'react';
+import clsx from 'clsx';
+import {HtmlClassNameProvider, PageMetadata, ThemeClassNames,} from 
'@docusaurus/theme-common';
+import {
+  DocsSidebarProvider,
+  DocsVersionProvider,
+  docVersionSearchTag,
+  useDocRouteMetadata,
+} from '@docusaurus/theme-common/internal';
+import DocPageLayout from '@theme/DocPage/Layout';
+import NotFound from '@theme/NotFound';
+import SearchMetadata from '@theme/SearchMetadata';
+import type {Props} from '@theme/DocPage';
+import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
+import useBaseUrl from "@docusaurus/useBaseUrl";
+
+function createCanonicalHref(props: Props): string {
+  const {siteConfig} = useDocusaurusContext();
+  const {versionMetadata, location, match} = props;
+  if (versionMetadata.version === 'current') {
+    // 1. The NEXT version docs should not forward to the latest stable version
+    // 2. Other plugins-doc instance (contribute, release-note, ...) happens 
to keep the link
+    return siteConfig.url + useBaseUrl(location.pathname);
+  }
+  const basename = location.pathname.replace(match.path, '');
+  return siteConfig.url + useBaseUrl(`/docs/${basename}`);
+}
+function DocPageMetadata(props: Props): JSX.Element {
+  const {versionMetadata} = props;
+  return (
+    <>
+      <SearchMetadata
+        version={versionMetadata.version}
+        tag={docVersionSearchTag(
+          versionMetadata.pluginId,
+          versionMetadata.version,
+        )}
+      />
+      <PageMetadata>
+        {versionMetadata.noIndex && (

Review Comment:
   @tisonkun, thanks for your contribution. It's really helpful and takes 
effect when I retry several search items.
   
   Just wondering about the second indented search result in the following 
case. Is it because we still index all versions?
   
   <img width="966" alt="image" 
src="https://user-images.githubusercontent.com/60642177/226866312-6c8fe949-8aa2-4824-8018-dce1d35b42df.png";>
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to