Skip to content

Commit

Permalink
Fix docs archive build (#1392)
Browse files Browse the repository at this point in the history
* fix: docs archive build

* fix: modules details paths
  • Loading branch information
SvMak committed Sep 22, 2024
1 parent 66cafc5 commit 8f77721
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ const config: Config = {
editUrl: 'https://github.com/jhipster/jhipster.github.io/tree/main/',
routeBasePath: '/',
showLastUpdateTime: true,
versions: {
current: {
path: '/',
},
},
onlyIncludeVersions: ['current'],
},
blog: false,
theme: {
Expand Down
15 changes: 12 additions & 3 deletions src/components/plugins-pages/MarketplaceDetailsPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import Layout from '@theme/Layout';
import { Redirect, useLocation } from '@docusaurus/router';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';

import MarketplaceDetailsHero from '@site/src/components/sections/marketplace/MarketplaceDetailsHero';
import MarketplaceDetails from '@site/src/components/sections/marketplace/MarketplaceDetails';

import { useMarketplaceDetails } from '@site/src/hooks/use-marketplace';

export default function MarketplaceDetailsPage() {
const { siteConfig } = useDocusaurusContext();
const location = useLocation();
const moduleName = getModuleNameFromPath(location.pathname);
const moduleName = getModuleNameFromPath(
location.pathname,
siteConfig.baseUrl,
);

const { details, downloads, isLoading, isValidRoute } =
useMarketplaceDetails(moduleName);
Expand Down Expand Up @@ -37,8 +42,12 @@ export default function MarketplaceDetailsPage() {
);
}

function getModuleNameFromPath(pathname: string) {
const pathParts = pathname.split('/');
function getModuleNameFromPath(pathname: string, baseUrl: string) {
const normalPathName =
baseUrl === '/'
? pathname
: pathname.replace(new RegExp(`^${baseUrl}`), '/');
const pathParts = normalPathName.split('/');

if (pathParts[4].startsWith('@')) {
return pathParts
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/module-details.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { LoadContext } from '@docusaurus/types';
import { NPM_SEARCH_MODULES_URL } from '../constants';

import modulesConfig from '../data/modules-config.json';
Expand All @@ -12,7 +13,7 @@ function getModulesNames(modules: any): string[] {
}, []);
}

export default function moduleDetailsPlugin() {
export default function moduleDetailsPlugin(context: LoadContext) {
return {
name: 'docusaurus-module-details',
async loadContent() {
Expand All @@ -33,7 +34,7 @@ export default function moduleDetailsPlugin() {

content.forEach((moduleName: string) => {
addRoute({
path: `/modules/marketplace/details/${moduleName}`,
path: `${context.baseUrl}modules/marketplace/details/${moduleName}`,
component:
'@site/src/components/plugins-pages/MarketplaceDetailsPage/index.tsx',
});
Expand Down

0 comments on commit 8f77721

Please sign in to comment.