258 lines
6.7 KiB
TypeScript
258 lines
6.7 KiB
TypeScript
import { defineConfig } from 'vitepress';
|
|
import { withMermaid } from 'vitepress-plugin-mermaid';
|
|
import typedocSidebar from '../api/typedoc-sidebar.json';
|
|
|
|
// Special cases map for acronyms and exceptions
|
|
const SPECIAL_CASES = {
|
|
hd: 'HD',
|
|
indexeddb: 'IndexedDB',
|
|
inmemory: 'InMemory',
|
|
json: 'JSON',
|
|
p2p: 'P2P',
|
|
p2pkh: 'P2PKH',
|
|
p2sh: 'P2SH',
|
|
p2sh20: 'P2SH20',
|
|
p2sh32: 'P2SH32',
|
|
sse: 'SSE',
|
|
utxo: 'UTXO',
|
|
};
|
|
|
|
function toPascalCase(str: string) {
|
|
// Handle special cases first
|
|
const lowerStr = str.toLowerCase();
|
|
|
|
if (lowerStr.startsWith('@')) {
|
|
return str;
|
|
}
|
|
|
|
// Split by common delimiters (hyphen, space, underscore)
|
|
return str
|
|
.split(/[-\s_]/)
|
|
.map((word) => {
|
|
if (word.length === 0) return '';
|
|
|
|
if (SPECIAL_CASES[word]) {
|
|
return SPECIAL_CASES[word];
|
|
}
|
|
|
|
// Capitalize first letter, lowercase rest
|
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
})
|
|
.join('');
|
|
}
|
|
|
|
function convertNavToPascalCase(nav: Array<any>) {
|
|
return nav.map((item) => {
|
|
const result = { ...item };
|
|
|
|
// Convert the text field
|
|
if (result.text) {
|
|
// If there was a @ prefix, preserve it
|
|
result.text = item.text.startsWith('@')
|
|
? result.text
|
|
: toPascalCase(result.text);
|
|
}
|
|
|
|
// Recursively process nested items
|
|
if (result.items && Array.isArray(result.items)) {
|
|
result.items = convertNavToPascalCase(result.items);
|
|
}
|
|
|
|
return result;
|
|
});
|
|
}
|
|
|
|
// https://vitepress.dev/reference/site-config
|
|
export default withMermaid({
|
|
outDir: '../dist',
|
|
title: 'XO Stack',
|
|
description:
|
|
'XO Stack: Building smart applications on the Bitcoin Cash Network',
|
|
head: [
|
|
// Favicon.
|
|
['link', { rel: 'icon', href: '/favicon.png' }],
|
|
// Basic OpenGraph tags
|
|
['meta', { property: 'og:type', content: 'website' }],
|
|
['meta', { property: 'og:title', content: 'XO Stack' }],
|
|
[
|
|
'meta',
|
|
{
|
|
property: 'og:description',
|
|
content:
|
|
'XO Stack: Building smart applications on the Bitcoin Cash Network',
|
|
},
|
|
],
|
|
[
|
|
'meta',
|
|
{
|
|
property: 'og:image',
|
|
content: 'https://stack.xo.cash/stack-opengraph.jpg',
|
|
},
|
|
],
|
|
['meta', { property: 'og:url', content: 'https://stack.xo.cash/' }],
|
|
|
|
// Optional additional tags
|
|
['meta', { property: 'og:site_name', content: 'XO Stack' }],
|
|
|
|
// Twitter Card tags (optional but recommended)
|
|
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
|
|
['meta', { name: 'twitter:site', content: '@yourtwitterhandle' }],
|
|
],
|
|
themeConfig: {
|
|
// Set the logo
|
|
logo: {
|
|
light: '/logo-light.svg',
|
|
dark: '/logo-dark.svg',
|
|
},
|
|
|
|
// Enable search functionality.
|
|
// TODO: Re-enable once we release documentation.
|
|
/*
|
|
search: {
|
|
provider: 'local',
|
|
},
|
|
*/
|
|
|
|
// https://vitepress.dev/reference/default-theme-config
|
|
nav: [
|
|
{ text: 'Home', link: '/' },
|
|
// TODO: Re-enable once we release documentation
|
|
// { text: 'Documentation', link: '/quick-start' },
|
|
{ text: 'Tools', link: '/tools/primitives' },
|
|
],
|
|
|
|
sidebar: {
|
|
// Default Side Menu.
|
|
'/': [
|
|
{
|
|
text: 'Guide',
|
|
items: [
|
|
{ text: 'Quick Start', link: '/quick-start' },
|
|
{ text: 'Architecture', link: '/architecture' },
|
|
{ text: 'Best Practices', link: '/api-examples' },
|
|
],
|
|
},
|
|
{
|
|
text: 'Frameworks',
|
|
items: [
|
|
{ text: 'Vue', link: '/frameworks/vue' },
|
|
{ text: 'React', link: '/frameworks/react' },
|
|
{ text: 'Svelte', link: '/frameworks/svelte' },
|
|
],
|
|
},
|
|
{
|
|
text: 'API',
|
|
items: convertNavToPascalCase(typedocSidebar),
|
|
},
|
|
],
|
|
// Side-menu for all routes under /tools/
|
|
'/tools/': [
|
|
{
|
|
text: 'XO Tools',
|
|
items: [
|
|
{
|
|
text: 'Primitives',
|
|
link: '/tools/primitives',
|
|
collapsed: false,
|
|
items: [
|
|
{ text: 'Address', link: '/tools/primitives#address' },
|
|
{
|
|
text: 'Block Header',
|
|
link: '/tools/primitives#block-header',
|
|
},
|
|
{ text: 'Bytes', link: '/tools/primitives#bytes' },
|
|
{
|
|
text: 'Encrypter',
|
|
link: '/tools/primitives#encrypter',
|
|
},
|
|
{
|
|
text: 'Hasher',
|
|
link: '/tools/primitives#hasher',
|
|
},
|
|
{
|
|
text: 'HD Private Node',
|
|
link: '/tools/primitives#hd-private-node',
|
|
},
|
|
{
|
|
text: 'HD Public Node',
|
|
link: '/tools/primitives#hd-public-node',
|
|
},
|
|
{
|
|
text: 'Mnemonic',
|
|
link: '/tools/primitives#mnemonic',
|
|
},
|
|
{
|
|
text: 'Private Key',
|
|
link: '/tools/primitives#private-key',
|
|
},
|
|
{
|
|
text: 'Public Key',
|
|
link: '/tools/primitives#public-key',
|
|
},
|
|
{
|
|
text: 'Satoshis',
|
|
link: '/tools/primitives#satoshis',
|
|
},
|
|
{
|
|
text: 'Script',
|
|
link: '/tools/primitives#script',
|
|
},
|
|
{
|
|
text: 'Transaction',
|
|
link: '/tools/primitives#transaction',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
text: 'Stack',
|
|
collapsed: false,
|
|
items: [
|
|
{
|
|
text: 'Blockchain',
|
|
link: '/tools/stack/blockchain',
|
|
items: [
|
|
{
|
|
text: 'Electrum',
|
|
link: '/tools/stack/blockchain#electrum',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
/*
|
|
|
|
*/
|
|
|
|
socialLinks: [
|
|
// { icon: 'github', link: 'https://gitlab.com/GeneralProtocols/xo/stack' },
|
|
{ icon: 'x', link: 'https://x.com/xo_bitcoincash' },
|
|
],
|
|
|
|
// This is the outline on the right-hand side of the page.
|
|
outline: {
|
|
level: [2, 4],
|
|
label: 'On this page',
|
|
},
|
|
},
|
|
|
|
// Set the dev and build targets to "esnext"
|
|
// NOTE: We do this so that we can support top-level-await.
|
|
vite: {
|
|
esbuild: {
|
|
target: 'esnext',
|
|
},
|
|
build: {
|
|
target: 'esnext',
|
|
},
|
|
optimizeDeps: {
|
|
esbuildOptions: {
|
|
target: 'esnext',
|
|
},
|
|
},
|
|
},
|
|
});
|