diff --git a/docs/nightly/fuel-specs b/docs/nightly/fuel-specs index aece3d369..799d6aec5 160000 --- a/docs/nightly/fuel-specs +++ b/docs/nightly/fuel-specs @@ -1 +1 @@ -Subproject commit aece3d369e93210aa318e3d9a0366792d28e3ec1 +Subproject commit 799d6aec5eb4725e268d841264f9d8ebc45b7469 diff --git a/scripts/generate-links/getSortedLinks.mjs b/scripts/generate-links/getSortedLinks.mjs index 430b66fc1..b78e8190d 100644 --- a/scripts/generate-links/getSortedLinks.mjs +++ b/scripts/generate-links/getSortedLinks.mjs @@ -344,6 +344,7 @@ function handleSubmenu( ]; return { + slug, subpath, label: thisCategory, isExternal, diff --git a/scripts/generate-links/index.mjs b/scripts/generate-links/index.mjs index 7564d7168..996818b2a 100644 --- a/scripts/generate-links/index.mjs +++ b/scripts/generate-links/index.mjs @@ -20,21 +20,15 @@ async function main() { const final = slugs.map(({ slug }) => getDocBySlug(slug, slugs)); let sortedLinks = getSortedLinks(orders[key], final); - if (key === 'intro') { - sortedLinks.push({ - slug: '/guides', - label: 'Guides', - isExternal: false, - }); - } if (key.includes('guides')) { const newLinks = {}; - sortedLinks.forEach((link) => { - newLinks[ - link.label.toLowerCase().replaceAll(' ', '_').replaceAll('-', '_') - ] = link; + sortedLinks = sortedLinks.map((link) => { + link.key = link.label + .toLowerCase() + .replaceAll(' ', '_') + .replaceAll('-', '_'); + return link; }); - sortedLinks = newLinks; } if (Array.isArray(sortedLinks)) { sortedLinks = sortedLinks.map((link) => { @@ -49,10 +43,10 @@ async function main() { fs.mkdirSync(folderPath, { recursive: true }); } fs.writeFileSync(`${folderPath}/${key}.json`, json, 'utf-8'); - if (!key.includes('guides') && key !== 'contributing') { + if (key !== 'contributing') { if ( key.includes('nightly') || - ['intro', 'contributing'].includes(key) + ['guides', 'intro', 'contributing'].includes(key) ) { const cleanKey = key.replace('nightly-', ''); allNightlyOrders.push({ @@ -106,6 +100,9 @@ function getSidebarName(key) { case 'migrations-and-disclosures': newKey = 'Migrations & Disclosures'; break; + case 'guides': + newKey = 'Guides'; + break; case 'integration-docs': newKey = 'Integrations'; break; @@ -119,6 +116,7 @@ function handleAllOrders(allOrders, folderPath, filename) { const correctOrder = [ 'migrations-and-disclosures', 'intro', + 'guides', 'sway', 'sway-libs', 'sway-standards', diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 05bc5870e..378834ab4 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -59,13 +59,25 @@ export function Sidebar({ {allNavs && ( <> {/* DOCS */} - {allNavs.map((navOrder) => { const catIndex = versionSet === 'default' ? 1 : 2; - let key = navOrder.links[0].slug.split('/')[catIndex]; + + let slug = navOrder.links[0]?.slug; + + if (!slug && navOrder.links[0]?.submenu?.[0]?.slug) { + slug = navOrder.links[0].submenu[0].slug; + } + + if (!slug) { + console.warn(`No slug found for navOrder.key: ${navOrder.key}`); + return null; + } + + let key = slug.split('/')[catIndex]; if (key === 'sway') { key = 'forc'; } + return ( ( - book === 'guides' || + (book.toLowerCase() === 'guides' && docSlug?.includes('guides')) || docSlug?.includes(`/${book.toLowerCase()}/`) || docSlug === `docs/${book.toLowerCase()}` || (book === 'Intro' && !docSlug) @@ -58,6 +58,9 @@ export function SidebarSection({ case 'Migrations-and-disclosures': githubLink = 'https://github.com/FuelLabs/migrations-and-disclosures'; break; + case 'Guides': + githubLink = 'https://github.com/FuelLabs/docs-hub'; + break; case 'Integration-docs': githubLink = 'https://github.com/FuelLabs/integration-docs'; break; @@ -94,22 +97,22 @@ export function SidebarSection({ {/* biome-ignore lint/suspicious/noExplicitAny: */} {links.map((link: any, index: number) => { - if (link.slug) { + if (link.submenu) { return ( - ); } - if (link.submenu) { + if (link.slug) { return ( - ); } diff --git a/src/lib/getActiveNav.ts b/src/lib/getActiveNav.ts index 645a5ba11..3d34b6dfa 100644 --- a/src/lib/getActiveNav.ts +++ b/src/lib/getActiveNav.ts @@ -7,11 +7,7 @@ export function getActiveNav( doc?: DocType ) { let navs = undefined; - if ( - !doc || - (!doc.originalSlug.includes('guides') && - !doc.originalSlug.includes('docs/contributing')) - ) { + if (!doc || !doc.originalSlug.includes('docs/contributing')) { if (versionSet === 'nightly') { navs = allNightlyNavs; } else { diff --git a/src/lib/md-doc.ts b/src/lib/md-doc.ts index d4d4565a1..7e4bc0bf3 100644 --- a/src/lib/md-doc.ts +++ b/src/lib/md-doc.ts @@ -71,6 +71,7 @@ export class Doc { .replace('docs/sway/', '') .replace('docs/sway-standards/', '') .replace('docs/sway-by-example-lib/', '') + .replace('docs/guides/', '') .replace('docs/fuel-specs/', '')}`; let pageLink = `${config.repository}${actualPath.replace( @@ -212,9 +213,15 @@ export class Doc { .replace(`${guideName}/`, '') .replace('/index', ''); - const key = slug.split('/')[0].replaceAll('-', '_'); - const guideLinks = [links[key]]; - return guideLinks as SidebarLinkItem[]; + const key = slug.split('/')[0].replace(/-/g, '_'); + + const guideLink = links.find((link) => link.key === key); + + if (guideLink?.submenu) { + return guideLink.submenu as SidebarLinkItem[]; + } + console.warn(`No guide link found for key: ${key}`); + return []; } return links as SidebarLinkItem[]; }