Skip to content

Commit

Permalink
feat(wip): render dinamic pages
Browse files Browse the repository at this point in the history
  • Loading branch information
TrofimovAnton85 committed Sep 13, 2024
1 parent 3a99bf2 commit 62edf60
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
8 changes: 8 additions & 0 deletions services/reference/linea/json-rpc-methods-new/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
description: json-rpc-methods-new
---

# json-rpc-methods-new

custom

20 changes: 20 additions & 0 deletions src/CustomPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Layout from "@theme/Layout";
import { NETWORK_NAMES } from "@site/src/plugins/plugin-json-rpc";
import ParserOpenRPC from "@site/src/components/ParserOpenRPC";
import React from "react";


const CustomPage = (props) => {
const customData = props.route.customData;
return (
<Layout>

<ParserOpenRPC
network={NETWORK_NAMES.linea}
method={customData.name}
/>
</Layout>
);
};

export default CustomPage;
43 changes: 42 additions & 1 deletion src/plugins/plugin-json-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,59 @@ const requests = [
},
];



export default function useNetworksMethodPlugin() {
return {
name: "plugin-json-rpc",
async contentLoaded({ actions }) {
const { setGlobalData } = actions;
const { setGlobalData, createData, addRoute } = actions;

await fetchMultipleData(requests)
.then((responseArray) => {

setGlobalData({ netData: responseArray });

return Promise.all(responseArray[0].data.methods.map(async (page) => {

const methodMDXContent = generateMethodMDX(page);

const filePath = await createData(
`services/reference/linea/json-rpc-methods-new/${page.name}.mdx`,
methodMDXContent
);

return addRoute({
path: `/services/reference/linea/json-rpc-methods-new/${page.name}`,
component: require.resolve("../CustomPage.tsx"),
exact: true,
modules: {
methodFile: filePath,
},
customData: { ...page }
});
}));
})
.catch(() => {
setGlobalData({ netData: [] });
});
},
};
}


function generateMethodMDX(page) {
return `---
title: '${page.name}'
---
# ${page.name}
`;
}



0 comments on commit 62edf60

Please sign in to comment.