Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
try this method of turning docs into external links
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotFriend committed Feb 21, 2024
1 parent 1df0d4d commit 3666430
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/developer-tools.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
sidebar_position: 75
title: Developer Tools
sidebar_custom_props:
migration:
href: https://developers.stellar.org/docs/tools/developer-tools
label: Developer Tools
---

:::info
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/sdks/build-your-own-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
sidebar_position: 30
title: Build Your Own SDK
description: A guide to developing Soroban SDKs for languages other than Rust.
sidebar_custom_props:
migration:
href: https://developers.stellar.org/docs/tools/sdks/build-your-own
label: Build Your Own SDK
---

Soroban currently has one SDK for writing contracts in Rust, which can be found [here][soroban-sdk].
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/sdks/interact-with-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
sidebar_position: 20
title: Interact with Contracts
description: SDKs support writing Soroban applications in many languages.
sidebar_custom_props:
migration:
href: https://developers.stellar.org/docs/tools/sdks/library
label: Interact with Contracts
---

## JavaScript SDK
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/sdks/write-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
sidebar_position: 10
title: Write Contracts
description: SDKs support writing Soroban contracts in Rust and AssemblyScript.
sidebar_custom_props:
migration:
href: https://developers.stellar.org/docs/tools/sdks/library
label: Write Contracts
---

## Soroban Rust SDK
Expand Down
20 changes: 19 additions & 1 deletion src/sidebar-generator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
const fs = require('fs')
const path = require('path')

const migrationLinksRecursive = (sidebarItems) => {
const result = sidebarItems.map((sidebarItem) => {
if (sidebarItem.type === 'category') {
return {...sidebarItem, items: migrationLinksRecursive(sidebarItem.items)}
}

if (sidebarItem.customProps?.migration?.href && sidebarItem.customProps?.migration?.label) {
sidebarItem = {
type: 'link',
href: sidebarItem.customProps.migration.href,
label: sidebarItem.customProps.migration.label,
}
}
return sidebarItem
})
return result
}

module.exports = async ({ defaultSidebarItemsGenerator, ...args }) => {

if (args.version.contentPath.endsWith('docs')) {
Expand Down Expand Up @@ -31,5 +49,5 @@ module.exports = async ({ defaultSidebarItemsGenerator, ...args }) => {
}

const sidebarItems = await defaultSidebarItemsGenerator({ ...args })
return sidebarItems
return migrationLinksRecursive(sidebarItems)
}

0 comments on commit 3666430

Please sign in to comment.