Skip to content

Commit

Permalink
docs(docusaurus.config): add "Typedoc" link
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Oct 5, 2023
1 parent e0c0bc8 commit be5a9eb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ coverage
.nyc_output
package-lock.json
build
typedoc
typedoc_out
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"readme:toc": "doctoc ./README.md",
"postinstall": "husky install",
"website": "yarn --cwd website/ run start",
"typedoc": "typedoc packages/mongodb-memory-server-core/src/index.ts --out typedoc --tsconfig packages/mongodb-memory-server-core/tsconfig.build.json"
"typedoc": "typedoc packages/mongodb-memory-server-core/src/index.ts --out typedoc_out --tsconfig packages/mongodb-memory-server-core/tsconfig.build.json"
}
}
4 changes: 2 additions & 2 deletions scripts/ghPagesDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require('node:path');
/* Constants / Config */

/** keep ".git", ".github", "website" and "scripts" */
const keepRegex = /^(?:\.git|website|scripts|versions|typedoc)/;
const keepRegex = /^(?:\.git|website|scripts|versions|typedoc_out)/;
/** Regex to filter and get versions output from git ls-tree */
const versionsFilter = /^versions\/(\d+\.x|beta)\/?$/;
/** Which branch to deploy to */
Expand Down Expand Up @@ -98,7 +98,7 @@ function main() {

// move typedoc to "deployAs"
{
const from = 'typedoc';
const from = 'typedoc_out';
const to = path.join(deployInfo.deployPath, 'typedoc');
console.log('rename', from, '->', to); // always log what is renamed
fs.renameSync(from, to);
Expand Down
7 changes: 7 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ module.exports = {
label: 'API',
position: 'right',
},
{
type: 'custom-link',
href: 'typedoc/index.html',
prependBaseUrlToHref: true,
label: 'Typedoc',
position: 'right',
},
{
href: 'https://github.com/nodkz/mongodb-memory-server/blob/master/CHANGELOG.md',
label: 'Changelog',
Expand Down
15 changes: 15 additions & 0 deletions website/src/components/NavbarExternalLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import useBaseUrl from '@docusaurus/useBaseUrl';

// this is a workaround, because without this non-absolute links will be seen as routable links by react
// see https://github.com/facebook/docusaurus/discussions/9376

export default function NavbarLinkNoReact({ href, label }) {
const normalizedHref = useBaseUrl(href, { forcePrependBaseUrl: true });

return (
<a href={normalizedHref} class="navbar__item navbar__link">
{label}
</a>
);
}
2 changes: 2 additions & 0 deletions website/src/theme/NavbarItem/ComponentTypes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import OriginalComponentTypes from '@theme-original/NavbarItem/ComponentTypes';
import NavbarVersionsSelector from '../../components/NavbarVersionsSelector';
import NavbarBetaNotice from '../../components/NavbarBetaNotice';
import NavbarLinkNoReact from '../../components/NavbarExternalLink';

const ComponentTypes = {
...OriginalComponentTypes,
'custom-versions-selector': NavbarVersionsSelector,
'custom-beta-notice': NavbarBetaNotice,
'custom-link': NavbarLinkNoReact,
};
export default ComponentTypes;

0 comments on commit be5a9eb

Please sign in to comment.