-
-
-
-
-
+
+
+
-
+
+
+
+
);
}
diff --git a/src/components/VersionedLink/VersionedLink.test.tsx b/src/components/VersionedLink/VersionedLink.test.tsx
index 61b824cd5b..3fcd0500e9 100644
--- a/src/components/VersionedLink/VersionedLink.test.tsx
+++ b/src/components/VersionedLink/VersionedLink.test.tsx
@@ -20,6 +20,19 @@ describe("Versioned link", () => {
expect(link).toBe(url);
});
+ it("latest version with component", () => {
+ prevVersionPath = "";
+ const componentText = "Component text";
+ const component =
{componentText}
;
+ const url = "/path/url";
+ render(
);
+ const componentRender = screen.getByText(componentText);
+ expect(componentRender).not.toBeNull();
+ const link = screen.getByRole("link").getAttribute("href");
+ expect(link).not.toBeNull();
+ expect(link).toBe(url);
+ });
+
it("previous version", () => {
prevVersionPath = "/v4.3.1";
const text = "Test link";
@@ -30,6 +43,19 @@ describe("Versioned link", () => {
expect(link).toBe(prevVersionPath.concat(url));
});
+ it("previous version with component", () => {
+ prevVersionPath = "/v4.3.1";
+ const componentText = "Component text";
+ const component =
{componentText}
;
+ const url = "/path/url";
+ render(
);
+ const componentRender = screen.getByText(componentText);
+ expect(componentRender).not.toBeNull();
+ const link = screen.getByRole("link").getAttribute("href");
+ expect(link).not.toBeNull();
+ expect(link).toBe(prevVersionPath.concat(url));
+ });
+
it("url with back dots", () => {
prevVersionPath = "";
const text = "Test link";
diff --git a/src/components/VersionedLink/VersionedLink.tsx b/src/components/VersionedLink/VersionedLink.tsx
index ee67c639ed..5f1235f364 100644
--- a/src/components/VersionedLink/VersionedLink.tsx
+++ b/src/components/VersionedLink/VersionedLink.tsx
@@ -2,7 +2,9 @@ import React from "react";
import GetVersionPath from "./CheckVersion";
interface ComponentProperties {
- [key: string]: string;
+ text?: string;
+ url: string;
+ component?: React.ReactElement;
}
export default function VersionedLink(props: ComponentProperties) {
@@ -17,10 +19,24 @@ export default function VersionedLink(props: ComponentProperties) {
"Versioned links should not be used for external URLs. Please use the default markdown syntax instead."
);
}
+
+ // Versioning detected
if (path != "") {
const versionedURL = path.concat(props.url);
+
+ // Component Mode detected
+ if (props.component != null) {
+ return
{props.component};
+ }
+
+ // Text mode detected
return
{props.text};
}
+ // Component mode of versioned link detected without versioning
+ if (props.component != null) {
+ return
{props.component};
+ }
+
return
{props.text};
}
diff --git a/static/assets/docs/images/hide_copy_button.webp b/static/assets/docs/images/hide_copy_button.webp
new file mode 100644
index 0000000000..eb7afe852e
Binary files /dev/null and b/static/assets/docs/images/hide_copy_button.webp differ
diff --git a/static/assets/docs/images/hide_copy_button_example.webp b/static/assets/docs/images/hide_copy_button_example.webp
new file mode 100644
index 0000000000..5b9176cade
Binary files /dev/null and b/static/assets/docs/images/hide_copy_button_example.webp differ