Skip to content

Commit

Permalink
Attempt to use TS sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Oct 12, 2023
1 parent b9a12d3 commit 6932057
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ export async function loadSidebarsFileUnsafe(
}

// We don't want sidebars to be cached because of hot reloading.
return jiti(__filename, {
const sidebars = jiti(__filename, {
cache: false,
interopDefault: true,
debug: true,
})(sidebarFilePath);

sidebarFilePath.endsWith('.ts') &&
console.log({sidebarFilePath}, JSON.stringify(sidebars, null, 2));

return sidebars;
}

export async function loadSidebars(
Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/docs/sidebar/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ module.exports = async function createConfigAsync() {
docs: {
// routeBasePath: '/',
path: 'docs',
sidebarPath: 'sidebars.js',
sidebarPath: 'sidebars.ts',
// sidebarCollapsible: false,
// sidebarCollapsed: true,
editUrl: ({locale, docPath}) => {
Expand Down
7 changes: 3 additions & 4 deletions website/sidebars.js → website/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

// @ts-check
import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';

/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
const sidebars: SidebarsConfig = {
docs: [
'introduction',
{
Expand Down Expand Up @@ -153,4 +152,4 @@ const sidebars = {
],
};

module.exports = sidebars;
export default sidebars;
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ A real-world example from the Docusaurus site:
```mdx-code-block
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
<CodeBlock language="js" title="sidebars.ts">
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A real-world example from the Docusaurus site:
import CodeBlock from '@theme/CodeBlock';
<CodeBlock language="js" title="sidebars.js">
{require('!!raw-loader!@site/sidebars.js')
{require('!!raw-loader!@site/sidebars.ts')
.default
.split('\n')
// remove comments
Expand Down

0 comments on commit 6932057

Please sign in to comment.