-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a2b543
commit dd93c28
Showing
10 changed files
with
228 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,179 @@ | ||
import starlightTypeDoc, { typeDocSidebarGroup } from 'starlight-typedoc'; | ||
|
||
export const sidebarConfig = [ | ||
{ | ||
label: 'Getting Started', | ||
items: [{ label: 'Getting Started Guide', link: '/getting-started/getting-started/' }], | ||
}, | ||
{ | ||
label: 'Learn', | ||
items: [ | ||
{ label: 'Clients', link: '/learn/clients/' }, | ||
{ label: 'Actions', link: '/learn/actions/' }, | ||
{ label: 'Low-level API', link: '/learn/low-level-api/' }, | ||
{ label: 'JSON RPC', link: '/learn/json-rpc/' }, | ||
{ label: 'Contracts', link: '/learn/contracts/' }, | ||
{ label: 'Bundler', link: '/learn/solidity-imports/' }, | ||
{ label: 'Advanced Scripting', link: '/learn/scripting/' }, | ||
{ label: 'Reference', link: '/learn/reference/' }, | ||
], | ||
}, | ||
typeDocSidebarGroug, | ||
]; | ||
"label": "Learn", | ||
"items": [ | ||
{ | ||
"label": "getting-started", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Getting started guide", | ||
"link": "/getting-started/getting-started/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "why", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Slow waterfall calls", | ||
"link": "/why/avoid-waterfalls/" | ||
}, | ||
{ | ||
"label": "Advanced gas estimation", | ||
"link": "/why/advanced-gas-estimation/" | ||
}, | ||
{ | ||
"label": "Writing tests", | ||
"link": "/why/writing-tests/" | ||
}, | ||
{ | ||
"label": "Writing UI in solidity", | ||
"link": "/why/write-ui-in-solidity/" | ||
}, | ||
{ | ||
"label": "Optimistic UI", | ||
"link": "/why/reuse-solidity/" | ||
}, | ||
{ | ||
"label": "Why Tevm", | ||
"link": "/why/" | ||
}, | ||
{ | ||
"label": "Optimistic UI", | ||
"link": "/why/optimistic-updates/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "learn", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "solidity-imports", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Bundler Guide", | ||
"link": "/learn/solidity-imports/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "reference", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Tevm reference", | ||
"link": "/learn/reference/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "actions", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Actions", | ||
"link": "/learn/actions/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "viem", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Tevm clients guide", | ||
"link": "/learn/viem/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "cli", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Cli", | ||
"link": "/learn/cli/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "json-rpc", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "JSON-RPC", | ||
"link": "/learn/json-rpc/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "contracts", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Contract action creators", | ||
"link": "/learn/contracts/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "tevm-node", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/vm/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/installation/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/txpool/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/create-tevm-node/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/receipts-manager/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/filters/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/copying-or-forking/" | ||
}, | ||
{ | ||
"label": "TevmNode api", | ||
"link": "/learn/tevm-node/using-jsonrpc/" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "scripting", | ||
"link": "", | ||
"items": [ | ||
{ | ||
"label": "Advanced scripting guide", | ||
"link": "/learn/scripting/" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,76 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import matter from 'gray-matter'; | ||
import { glob } from 'glob'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const docsDir = path.join(__dirname, '../src/content/docs'); | ||
const sidebarConfigPath = path.join(__dirname, '../astro.sidebar.config.mjs'); | ||
|
||
interface SidebarItem { | ||
label: string; | ||
link: string; | ||
items?: SidebarItem[]; | ||
} | ||
|
||
interface SidebarConfig { | ||
label: string; | ||
items: SidebarItem[]; | ||
} | ||
|
||
function generateSidebarConfig(dir: string): SidebarItem[] { | ||
function generateSidebarConfig(): SidebarItem[] { | ||
const items: SidebarItem[] = []; | ||
|
||
fs.readdirSync(dir).forEach(file => { | ||
const fullPath = path.join(dir, file); | ||
const stat = fs.statSync(fullPath); | ||
// Use glob to find all markdown and mdx files, excluding specific directories and files | ||
const files = glob.sync('**/*.{md,mdx}', { | ||
cwd: docsDir, | ||
ignore: ['reference/**', 'blog/**', 'index.mdx'], | ||
}); | ||
|
||
console.log(`Found markdown and mdx files: ${files}`); | ||
|
||
files.forEach(file => { | ||
const fullPath = path.join(docsDir, file); | ||
const { data } = matter(fs.readFileSync(fullPath, 'utf8')); | ||
const fileName = path.basename(file, path.extname(file)); | ||
const dirName = path.dirname(file); | ||
|
||
if (stat.isDirectory()) { | ||
const indexPath = path.join(fullPath, 'index.md'); | ||
if (fs.existsSync(indexPath)) { | ||
const { data } = matter(fs.readFileSync(indexPath, 'utf8')); | ||
items.push({ label: data.title || file, link: `/learn/${file}/` }); | ||
// Split the directory path to create nested structure | ||
const pathParts = dirName.split(path.sep); | ||
|
||
// Create a nested structure based on the directory path | ||
let currentLevel = items; | ||
pathParts.forEach((part) => { | ||
let existingItem = currentLevel.find(item => item.label === part); | ||
if (!existingItem) { | ||
existingItem = { label: part, link: '', items: [] }; | ||
currentLevel.push(existingItem); | ||
} | ||
if (existingItem.items) { | ||
currentLevel = existingItem.items; | ||
} | ||
} else if (file.endsWith('.md')) { | ||
const { data } = matter(fs.readFileSync(fullPath, 'utf8')); | ||
const fileName = path.basename(file, '.md'); | ||
items.push({ label: data.title || fileName, link: `/learn/${fileName}/` }); | ||
} | ||
}); | ||
|
||
// Add the file to the appropriate level | ||
const linkPath = fileName === 'index' ? `/${dirName}/` : `/${dirName}/${fileName}/`; | ||
currentLevel.push({ label: data.title || fileName, link: linkPath }); | ||
console.log(`Added item: ${data.title || fileName} with link: ${linkPath}`); | ||
}); | ||
|
||
console.log(`Generated items: ${JSON.stringify(items, null, 2)}`); | ||
return items; | ||
} | ||
|
||
const sidebarConfig: SidebarConfig[] = [ | ||
{ | ||
label: 'Learn', | ||
items: generateSidebarConfig(docsDir), | ||
items: generateSidebarConfig(), | ||
}, | ||
]; | ||
|
||
fs.writeFileSync(sidebarConfigPath, `export const sidebarConfig = ${JSON.stringify(sidebarConfig, null, 4)};`); | ||
|
||
console.log('Sidebar configuration generated successfully.'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
title: Why Tevm | ||
description: Explanation of Tevm and it's use case | ||
position: 0 | ||
--- | ||
|
||
# Why Tevm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
title: Writing tests | ||
description: Using Tevm to write tests | ||
position: 6 | ||
--- | ||
## Problem | ||
|
||
|