Skip to content

Commit

Permalink
feat(docs): added handling for category links
Browse files Browse the repository at this point in the history
  • Loading branch information
aednikanov committed Sep 23, 2024
1 parent 1adab32 commit dce12cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Note: type annotations allow type checking and IDEs autocompletion

require("dotenv").config();
const { fetchAndGenerateSidebarItems } = require("./src/helpers");
const { fetchAndGenerateDynamicSidebarItems } = require("./src/helpers");
import { NETWORK_NAMES } from "./src/lib/constants.ts";
const upperFirst = require("lodash.upperfirst");
const { themes } = require("prism-react-renderer");
Expand Down Expand Up @@ -131,7 +131,7 @@ const config = {
sidebarItemsGenerator: async function ({ defaultSidebarItemsGenerator, ...args }) {
config.customFields.sidebarData = args;
let sidebarItems = await defaultSidebarItemsGenerator(args);
const dynamicSidebarItems = await fetchAndGenerateSidebarItems(NETWORK_NAMES.linea);
const dynamicSidebarItems = await fetchAndGenerateDynamicSidebarItems(NETWORK_NAMES.linea);
config.customFields.dynamicData = dynamicSidebarItems;
const updatedItems = sidebarItems.map(item => {
if (item?.label === upperFirst(NETWORK_NAMES.linea) && item?.items) {
Expand Down
6 changes: 2 additions & 4 deletions src/components/CustomReferencePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ function generateSidebarItems(docs) {
label: upperFirst(doc.frontMatter?.sidebar_label || doc.frontMatter?.title || part),
collapsed: false,
collapsible: true,
link: {
type: 'generated-index',
slug: pathParts.slice(0, index + 1).join('/')
},
href: `/services/reference`,
items: []
};
} else {
currentCategory[part] = {
type: 'category',
label: upperFirst(part),
href: `/services/${doc.sourceDirName}`,
collapsed: part !== "Get started",
collapsible: true,
items: []
Expand Down
6 changes: 5 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RPC_NETWORK_URL } from "../lib/constants";

export const fetchAndGenerateSidebarItems = async (networkName) => {
export const fetchAndGenerateDynamicSidebarItems = async (networkName) => {
try {
const response = await fetch(`${RPC_NETWORK_URL}/${networkName}`);
const data = await response.json();
Expand All @@ -13,6 +13,10 @@ export const fetchAndGenerateSidebarItems = async (networkName) => {
{
type: "category",
label: "JSON-RPC Methods NEW",
link: {
type: 'generated-index',
slug: "/services/reference/linea/json-rpc-methods-new/"
},
collapsed: true,
collapsible: true,
items: dynamicItems,
Expand Down

0 comments on commit dce12cf

Please sign in to comment.