Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update #425

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions docs/guides/docs/guides.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,61 @@
"title": "Predicates 101: Building Stateless DeFi Applications",
"description": "Learn about predicates by building a MultiSig",
"featured": true,
"tags": ["Full Stack"]
"tags": [
"Full Stack"
]
},
"intro_to_sway": {
"title": "Introduction to Sway for JavaScript developers",
"description": "Learn Sway fundamentals by building a marketplace React dApp.",
"featured": true,
"tags": ["Full Stack", "React"]
"tags": [
"Full Stack",
"React"
]
},
"contract-quickstart": {
"title": "Smart Contract Quickstart",
"description": "Get started by generating a counter contract in Sway.",
"featured": false,
"tags": ["Getting Started"]
"tags": [
"Getting Started"
]
},
"frontend-quickstart": {
"title": "Next.js Fullstack Quickstart",
"description": "Get started by generating a full-stack counter dapp on Fuel.",
"featured": false,
"tags": ["Getting Started", "Full Stack", "Next.js"]
"tags": [
"Getting Started",
"Full Stack",
"Next.js"
]
},
"counter-dapp": {
"title": "Counter React Dapp",
"description": "Step-by-step guide to build a counter dApp on Fuel",
"featured": false,
"tags": ["Getting Started", "Full Stack", "React"]
"tags": [
"Getting Started",
"Full Stack",
"React"
]
},
"running_a_node": {
"title": "Running a Node",
"description": "Run a local Fuel node.",
"featured": false,
"tags": ["fuel-core"]
"tags": [
"fuel-core"
]
},
"installation": {
"title": "Toolchain Installation",
"description": "Install the Fuel toolchain and binaries.",
"featured": false,
"tags": ["Getting Started"]
"tags": [
"Getting Started"
]
}
}
}
19 changes: 14 additions & 5 deletions docs/guides/docs/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
"Counter Dapp",
"Running a Node",
"Installation",
"Intro to Sway"
"Intro to Sway",
"Intro to Predicates"
],
"installation": [
"Fuel Github Codespace"
],
"counter-dapp": [
"Building a Smart Contract",
"Building a Frontend"
],
"installation": ["Fuel Github Codespace"],
"counter-dapp": ["Building a Smart Contract", "Building a Frontend"],
"contract-quickstart": [],
"frontend-quickstart": [],
"running_a_node": ["Running a Local Node", "Running a Testnet Node"],
"running_a_node": [
"Running a Local Node",
"Running a Testnet Node"
],
"intro_to_sway": [
"Introduction to Sway",
"Prerequisites",
Expand Down Expand Up @@ -40,4 +49,4 @@
"Logging in Rust tests",
"Rust Testing"
]
}
}
6 changes: 6 additions & 0 deletions scripts/generate-links/getDocs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ export async function getDocs(key, order) {
'./guides/docs/**/*.mdx'
];
break;
case 'nightly-guides':
paths = [
// GUIDES
'./guides/docs/**/*.mdx'
];
break;
case 'intro':
paths = [
// INTRO
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate-links/getSortedLinks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ function handleSubmenu(
},
];

console.log(title, slug);
return {
slug,
subpath,
label: thisCategory,
isExternal,
Expand Down
33 changes: 19 additions & 14 deletions scripts/generate-links/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ 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 === 'guides') {
// 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) => {
Expand All @@ -49,7 +49,8 @@ async function main() {
fs.mkdirSync(folderPath, { recursive: true });
}
fs.writeFileSync(`${folderPath}/${key}.json`, json, 'utf-8');
if (!key.includes('guides') && key !== 'contributing') {
// if (!key.includes('guides') && key !== 'contributing') {
if (key !== 'contributing') {
if (
key.includes('nightly') ||
['intro', 'contributing'].includes(key)
Expand Down Expand Up @@ -106,6 +107,9 @@ function getSidebarName(key) {
case 'migrations-and-disclosures':
newKey = 'Migrations & Disclosures';
break;
case 'guides':
newKey = 'Guides';
break;
default:
}

Expand All @@ -116,6 +120,7 @@ function handleAllOrders(allOrders, folderPath, filename) {
const correctOrder = [
'migrations-and-disclosures',
'intro',
'guides',
'sway',
'sway-libs',
'sway-standards',
Expand Down
1 change: 1 addition & 0 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function Sidebar({

{allNavs.map((navOrder) => {
const catIndex = versionSet === 'default' ? 1 : 2;
// console.log("hello", navOrder.links)
let key = navOrder.links[0].slug.split('/')[catIndex];
if (key === 'sway') {
key = 'forc';
Expand Down
3 changes: 3 additions & 0 deletions src/components/SidebarSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
default:
break;
}
Expand Down
20 changes: 16 additions & 4 deletions src/lib/md-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -201,6 +202,7 @@ export class Doc {
`../src/generated/sidebar-links/${configSlug}.json`
);
const links = JSON.parse(readFileSync(linksPath, 'utf8'));

if (
(configSlug === 'guides' || configSlug === 'nightly-guides') &&
guideName
Expand All @@ -212,17 +214,27 @@ 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, '_');

// Updated code: Find the link with matching key
const guideLink = links.find((link) => link.key === key);

if (guideLink && guideLink.submenu) {
return guideLink.submenu as SidebarLinkItem[];
} else {
console.warn(`No guide link found for key: ${key}`);
return [];
}
}
return links as SidebarLinkItem[];
}

get navLinks() {
const slug = this.#parseSlug(this.item.originalSlug);
const links = this.sidebarLinks(this.item.originalSlug);

console.log(slug);
console.log(links);
console.log(this.item);
const result = [];
for (const link of links) {
if (link.submenu) {
Expand Down
Loading