Skip to content

Commit af32adf

Browse files
committed
Create JavadocLink.js
1 parent 762d78b commit af32adf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/theme/JavadocLink.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { useActiveVersion } from '@docusaurus/plugin-content-docs/client';
3+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4+
5+
export default function JavadocLink({ packageName, path, className }) {
6+
const { siteConfig } = useDocusaurusContext();
7+
const activeVersion = useActiveVersion();
8+
9+
// Retrieve className from siteConfig based on the active version.
10+
const docsClassName =
11+
siteConfig.presets?.[0]?.[1]?.docs?.versions?.[activeVersion.name]?.className;
12+
13+
// Log for debugging
14+
console.log('Active Version:', activeVersion?.name);
15+
console.log('Docs ClassName:', docsClassName);
16+
17+
// The link in the <a> code below is generated based on the following JavadocLink component that must be added in place of a static Javadoc link in the doc:
18+
// <JavadocLink packageName="scalardl-common" path="com/scalar/dl/ledger/config" className="LedgerConfig" />
19+
return (
20+
<a
21+
href={`https://javadoc.io/static/com.scalar-labs/${packageName}/${docsClassName}/${path}/${className}.html`}
22+
target="_blank"
23+
rel="noopener noreferrer"
24+
>
25+
{className}
26+
</a>
27+
);
28+
}

0 commit comments

Comments
 (0)