diff --git a/src/docConfig.js b/src/docConfig.js index 12d53e22d..94aa4cf81 100644 --- a/src/docConfig.js +++ b/src/docConfig.js @@ -462,6 +462,10 @@ function filterByCategoryAndSoftware(category, software) { return docs.filter((doc) => doc.category === category && doc.software === software); } +function hasActiveDocs(category, software) { + return docs.some((doc) => doc.category === category && doc.software === software && doc.active === true); +} + function getInactiveDocLocations() { return docs.filter((doc) => doc.active === false && doc.doc_location).map((doc) => doc.doc_location); } @@ -483,6 +487,7 @@ function shouldExcludeFromBuild(docsRelativePath) { module.exports = { docs, filterByCategoryAndSoftware, + hasActiveDocs, getInactiveDocLocations, getDraftDocLocations, shouldExcludeFromBuild, diff --git a/src/pages/index.js b/src/pages/index.js index b29949de5..e959c8cb0 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -17,6 +17,7 @@ import SystemResponseIcon from '../components/icons/SystemResponseIcon'; import ToolboxIcon from '../components/icons/ToolboxIcon'; import WebAppIcon from '../components/icons/WebAppIcon'; import TourButton from '../components/TourButton'; +import { hasActiveDocs } from '../docConfig'; import '../css/custom.css'; export default function Home() { @@ -123,28 +124,28 @@ export default function Home() { title: 'Rainfall Runoff Frequency Tool', description: 'Rapid risk framework', href: addBaseUrl('web-applications/rrft'), - active: false, + active: hasActiveDocs('web-applications', 'rrft'), }, { IconComponent: LSTIcon, title: 'Levee Screening Tool', description: 'Levee risk screening and assessment', href: addBaseUrl('web-applications/lst'), - active: false, + active: hasActiveDocs('web-applications', 'lst'), }, { IconComponent: DSTIcon, title: 'Dam Screening Tool', description: 'Dam risk screening', href: addBaseUrl('web-applications/dst'), - active: false, + active: hasActiveDocs('web-applications', 'dst'), }, { IconComponent: SystemResponseIcon, title: 'System Response Library', description: 'System response models for screening', href: addBaseUrl('web-applications/system-response'), - active: false, + active: hasActiveDocs('web-applications', 'system-response'), }, ], }, diff --git a/src/theme/Layout/buildNavLinks.js b/src/theme/Layout/buildNavLinks.js index 301ffab33..3657b27ca 100644 --- a/src/theme/Layout/buildNavLinks.js +++ b/src/theme/Layout/buildNavLinks.js @@ -1,3 +1,5 @@ +import { hasActiveDocs } from '../../docConfig'; + /** * Build the nested "links" structure for . * Pass in useBaseUrl (hook result) and the latestVersions object. @@ -328,18 +330,21 @@ export default function buildNavLinks(useBaseUrl, latestVersions = {}) { children: [ { id: 'dst', - text: 'Dam Screening Tool (Coming Soon)', - /*href: dstHref,*/ + ...(hasActiveDocs('web-applications', 'dst') + ? { text: 'Dam Screening Tool', href: dstHref } + : { text: 'Dam Screening Tool (Coming Soon)' }), }, { id: 'system-response', - text: 'System Response Library (Coming Soon)', - /*href: systemResponseHref,*/ + ...(hasActiveDocs('web-applications', 'system-response') + ? { text: 'System Response Library', href: systemResponseHref } + : { text: 'System Response Library (Coming Soon)' }), }, { id: 'lst', - text: 'Levee Screening Tool (Coming Soon)', - /*href: lstHref,*/ + ...(hasActiveDocs('web-applications', 'lst') + ? { text: 'Levee Screening Tool', href: lstHref } + : { text: 'Levee Screening Tool (Coming Soon)' }), /*children: [ { id: 'users-guide', @@ -350,8 +355,9 @@ export default function buildNavLinks(useBaseUrl, latestVersions = {}) { }, { id: 'rrft', - text: 'Rainfall Runoff Frequency Tool (Coming Soon)', - /*href: rrftHref,*/ + ...(hasActiveDocs('web-applications', 'rrft') + ? { text: 'Rainfall Runoff Frequency Tool', href: rrftHref } + : { text: 'Rainfall Runoff Frequency Tool (Coming Soon)' }), }, ], },