diff --git a/docusaurus.config.ts b/docusaurus.config.ts index c5d4ee7c..6c22f667 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -1,15 +1,9 @@ +import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; import remarkMath from 'remark-math'; import rehypeKatex from 'rehype-katex'; -// @ts-check -// Note: type annotations allow type checking and IDEs autocompletion - -const {themes} = require('prism-react-renderer'); -const lightTheme = themes.github; -const darkTheme = themes.dracula; - const config: Config = { title: 'Apache TVM 中文站', tagline: 'Apache TVM 是一个端到端的深度学习编译框架,适用于 CPU、GPU 和各种机器学习加速芯片。', @@ -34,7 +28,7 @@ const config: Config = { '@docusaurus/preset-classic', { docs: { - sidebarPath: require.resolve('./sidebars.js'), + sidebarPath: './sidebars.ts', // Please change this to your repo. editUrl: 'https://github.com/hyperai/tvm-cn/edit/master/', showLastUpdateAuthor: true, @@ -57,7 +51,7 @@ const config: Config = { 'https://github.com/facebook/docusaurus/edit/main/website/blog/', }, theme: { - customCss: require.resolve('./src/css/app.scss'), + customCss: './src/css/app.scss', }, } satisfies Preset.Options, ], @@ -116,8 +110,8 @@ const config: Config = { copyright: `© ${new Date().getFullYear()} Apache Software Foundation and Hyper.AI for Chinese Simplified mirror`, }, prism: { - theme: lightTheme, - darkTheme: darkTheme, + theme: prismThemes.github, + darkTheme: prismThemes.dracula, // https://docusaurus.io/docs/migration/v3#prism-react-renderer-v20 additionalLanguages: ['bash', 'diff', 'json', 'python'], }, @@ -144,7 +138,7 @@ const config: Config = { plugins: [ 'docusaurus-plugin-sass', - require.resolve('./src/plugins/typekit/'), + './src/plugins/typekit/', ], scripts: [ { diff --git a/sidebars.js b/sidebars.ts similarity index 96% rename from sidebars.js rename to sidebars.ts index 8a755716..19799700 100644 --- a/sidebars.js +++ b/sidebars.ts @@ -1,3 +1,5 @@ +import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; + /** * Creating a sidebar enables you to: - create an ordered group of docs @@ -9,10 +11,7 @@ Create as many sidebars as you want. */ -// @ts-check - -/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ -const sidebars = { +const sidebars: SidebarsConfig = { // By default, Docusaurus generates a sidebar from the docs folder structure /* tutorialSidebar: [ @@ -143,4 +142,4 @@ const sidebars = { ] }; -module.exports = sidebars; +export default sidebars;