Skip to content

Commit d299793

Browse files
committed
Add config to prep step
1 parent d84a43f commit d299793

File tree

2 files changed

+87
-36
lines changed

2 files changed

+87
-36
lines changed

docs/config/gatsby-config.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
module.exports = {
3+
pathPrefix: "",
4+
siteMetadata: {
5+
title: 'Ethereum JSON-RPC Specification',
6+
description: 'A specification of the standard interface for Ethereum clients.',
7+
siteUrl: 'https://open-rpc.org',
8+
logoUrl: 'https://raw.githubusercontent.com/open-rpc/design/master/icons/open-rpc-logo-noText/open-rpc-logo-noText%20(PNG)/256x256.png',
9+
primaryColor: '#3f51b5', //material-ui primary color
10+
secondaryColor: '#f50057', //material-ui secondary color
11+
author: '',
12+
menuLinks: [ {
13+
name: 'Contributors Guide',
14+
link: '/making-changes',
15+
ignoreNextPrev: true
16+
},
17+
{
18+
name: 'API Documentation',
19+
link: '/api-documentation'
20+
}
21+
],
22+
footerLinks: [
23+
{
24+
name: 'OpenRPC',
25+
link: 'https://open-rpc.org'
26+
}
27+
]
28+
},
29+
plugins: [
30+
{
31+
resolve: 'gatsby-plugin-mdx',
32+
options: {
33+
extensions: ['.mdx', '.md'],
34+
gatsbyRemarkPlugins: [
35+
{
36+
resolve: 'gatsby-remark-autolink-headers',
37+
options: {
38+
icon: false,
39+
},
40+
},
41+
],
42+
},
43+
},
44+
"gatsby-openrpc-theme",
45+
{
46+
resolve: 'gatsby-plugin-manifest',
47+
options: {
48+
name: 'pristine-site',
49+
short_name: 'pristine-site',
50+
start_url: '/',
51+
background_color: 'transparent',
52+
theme_color: '#3f51b5',
53+
display: 'minimal-ui',
54+
icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
55+
},
56+
},
57+
"gatsby-plugin-image",
58+
"gatsby-plugin-sharp",
59+
"gatsby-transformer-sharp",
60+
{
61+
resolve: "gatsby-source-filesystem",
62+
options: {
63+
name: "images",
64+
path: __dirname + '/src/images',
65+
},
66+
},
67+
{
68+
resolve: "gatsby-source-filesystem",
69+
options: {
70+
name: "docs",
71+
path: __dirname + '/src/docs',
72+
},
73+
},
74+
],
75+
}

scripts/prepare-docs.js

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,23 @@ function copyMarkdownFiles() {
3535
});
3636
}
3737

38-
// Function to update menu links
39-
function updateMenuLinks() {
40-
const configPath = path.join(__dirname, '..', 'build', 'docs', 'gatsby', 'gatsby-config.js');
41-
42-
// Read the config file
43-
let configContent = fs.readFileSync(configPath, 'utf8');
44-
45-
// Find the menuLinks array
46-
const menuLinksRegex = /menuLinks:\s*\[([\s\S]*?)\]/;
47-
const match = configContent.match(menuLinksRegex);
48-
49-
if (match) {
50-
// Add the new menu link
51-
const newMenuLink = ` {
52-
name: 'Contributors Guide',
53-
link: '/making-changes',
54-
ignoreNextPrev: true
55-
},`;
56-
57-
// Remove the 'home' menu link and add the new one
58-
const menuLinksContent = match[1]
59-
.replace(/,\s*{\s*name:\s*'home',[^}]*},/g, '');
60-
61-
// Insert the new menu link before the closing bracket
62-
const updatedContent = configContent.replace(
63-
menuLinksRegex,
64-
`menuLinks: [${newMenuLink}${menuLinksContent}]`
65-
);
66-
67-
// Write the updated content back to the file
68-
fs.writeFileSync(configPath, updatedContent);
69-
console.log('Updated menu links in gatsby-config.js');
70-
} else {
71-
console.error('Could not find menuLinks array in gatsby-config.js');
72-
}
38+
// Function to copy Gatsby config file
39+
function copyGatsbyConfig() {
40+
const sourcePath = path.join(__dirname, '..', 'docs', 'config', 'gatsby-config.js');
41+
const targetPath = path.join(__dirname, '..', 'build', 'docs', 'gatsby', 'gatsby-config.js');
42+
43+
// Ensure target directory exists
44+
ensureDirectoryExists(path.dirname(targetPath));
45+
46+
// Copy the file
47+
fs.copyFileSync(sourcePath, targetPath);
48+
console.log(`Copied gatsby-config.js to ${targetPath}`);
7349
}
7450

7551
// Execute the functions
7652
try {
7753
copyMarkdownFiles();
78-
updateMenuLinks();
54+
copyGatsbyConfig();
7955
console.log('Documentation preparation completed successfully!');
8056
} catch (error) {
8157
console.error('Error preparing documentation:', error);

0 commit comments

Comments
 (0)