fix theme import

This commit is contained in:
techknowlogick
2023-11-10 13:01:41 -05:00
parent 9c94c41125
commit d669bc9720
+301 -299
View File
@@ -1,299 +1,301 @@
// @ts-check // @ts-check
// Note: type annotations allow type checking and IDEs autocompletion // Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github'); import {themes as prismThemes} from 'prism-react-renderer';
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const lightCodeTheme = prismThemes.github;
// order usage directory by type first const darkCodeTheme = prismThemes.dracula;
function sortItemsByCategory(items) {
// type with "category" (directory) first // order usage directory by type first
const sortedItems = items.sort(function(a, b) { function sortItemsByCategory(items) {
return a.type.localeCompare(b.type); // type with "category" (directory) first
}) const sortedItems = items.sort(function(a, b) {
return sortedItems; return a.type.localeCompare(b.type);
} })
return sortedItems;
const renderApiSSR = process.env.API_SSR !== 'false'; }
const apiConfig = [ const renderApiSSR = process.env.API_SSR !== 'false';
'redocusaurus',
{ const apiConfig = [
// Plugin Options for loading OpenAPI files 'redocusaurus',
specs: renderApiSSR ? [ {
{ // Plugin Options for loading OpenAPI files
spec: 'static/swagger-latest.json', specs: renderApiSSR ? [
route: '/api/next/', {
}, spec: 'static/swagger-latest.json',
{ route: '/api/next/',
route: '/api/1.21/', },
spec: 'static/swagger-21.json', {
}, route: '/api/1.21/',
{ spec: 'static/swagger-21.json',
route: '/api/1.20/', },
spec: 'static/swagger-20.json', {
}, route: '/api/1.20/',
{ spec: 'static/swagger-20.json',
route: '/api/1.19/', },
spec: 'static/swagger-19.json', {
}, route: '/api/1.19/',
]: [], spec: 'static/swagger-19.json',
// Theme Options for modifying how redoc renders them },
theme: { ]: [],
// Change with your site colors // Theme Options for modifying how redoc renders them
primaryColor: '#1890ff', theme: {
}, // Change with your site colors
}, primaryColor: '#1890ff',
] },
},
const pageConfig = renderApiSSR ? { ]
exclude: [
'api/**', const pageConfig = renderApiSSR ? {
], exclude: [
}: {} 'api/**',
],
/** @type {import('@docusaurus/types').Config} */ }: {}
const config = {
title: 'Gitea Documentation', /** @type {import('@docusaurus/types').Config} */
tagline: 'Git with a cup of tea', const config = {
url: 'https://docs.gitea.com', title: 'Gitea Documentation',
baseUrl: '/', tagline: 'Git with a cup of tea',
onBrokenLinks: 'warn', url: 'https://docs.gitea.com',
onBrokenMarkdownLinks: 'warn', baseUrl: '/',
favicon: 'img/favicon.png', onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
plugins: [ favicon: 'img/favicon.png',
[
'docusaurus-plugin-plausible', plugins: [
{ [
domain: 'docs.gitea.com', 'docusaurus-plugin-plausible',
}, {
] domain: 'docs.gitea.com',
], },
]
i18n: { ],
defaultLocale: 'en-us',
locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales i18n: {
localeConfigs: { defaultLocale: 'en-us',
'en-us': { locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
label: 'English', localeConfigs: {
}, 'en-us': {
'zh-cn': { label: 'English',
label: '中文', },
}, 'zh-cn': {
}, label: '中文',
}, },
},
presets: [ },
[
'@docusaurus/preset-classic', presets: [
//'classic', [
/** @type {import('@docusaurus/preset-classic').Options} */ '@docusaurus/preset-classic',
({ //'classic',
docs: { /** @type {import('@docusaurus/preset-classic').Options} */
sidebarPath: require.resolve('./sidebars.js'), ({
routeBasePath: '/', // Serve the docs at the site's root docs: {
editUrl: ({versionDocsDirPath, docPath, locale, version, permalink}) => { sidebarPath: require.resolve('./sidebars.js'),
let fileName = `${docPath.replace('.md', '')}.${locale}.md`; routeBasePath: '/', // Serve the docs at the site's root
// intro.md has different name from upstream, need to handle this here editUrl: ({versionDocsDirPath, docPath, locale, version, permalink}) => {
if (docPath.includes('intro.md')) { let fileName = `${docPath.replace('.md', '')}.${locale}.md`;
fileName = `page/index.${locale}.md`; // intro.md has different name from upstream, need to handle this here
} if (docPath.includes('intro.md')) {
return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`; fileName = `page/index.${locale}.md`;
}, }
versions: { return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`;
current: { },
label: '1.22-dev', // path is kept as next for dev (so users can always find "nightly" docs) versions: {
banner: 'unreleased', current: {
}, label: '1.22-dev', // path is kept as next for dev (so users can always find "nightly" docs)
'1.21': { banner: 'unreleased',
label: '1.21.0-rc1', },
}, '1.21': {
'1.20': { label: '1.21.0-rc1',
label: '1.20.5' },
}, '1.20': {
'1.19': { label: '1.20.5'
label: '1.19.4', },
} '1.19': {
}, label: '1.19.4',
lastVersion: '1.20', }
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) { },
const {item} = args; lastVersion: '1.20',
// Use the provided data to generate a custom sidebar slice async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const sidebarItems = await defaultSidebarItemsGenerator(args); const {item} = args;
if (item.dirName !== 'usage') { // Use the provided data to generate a custom sidebar slice
return sidebarItems; const sidebarItems = await defaultSidebarItemsGenerator(args);
} else { if (item.dirName !== 'usage') {
return sortItemsByCategory(sidebarItems); return sidebarItems;
} } else {
}, return sortItemsByCategory(sidebarItems);
}, }
blog: false, },
theme: { },
customCss: require.resolve('./src/css/custom.css'), blog: false,
}, theme: {
pages: pageConfig, customCss: require.resolve('./src/css/custom.css'),
}), },
], pages: pageConfig,
apiConfig, }),
], ],
themes: [ apiConfig,
[ ],
"@easyops-cn/docusaurus-search-local", themes: [
{ [
hashed: false, "@easyops-cn/docusaurus-search-local",
language: ["en", "zh"], {
highlightSearchTermsOnTargetPage: true, hashed: false,
explicitSearchResultPath: true, language: ["en", "zh"],
indexBlog: false, highlightSearchTermsOnTargetPage: true,
docsRouteBasePath: "/" explicitSearchResultPath: true,
} indexBlog: false,
] docsRouteBasePath: "/"
], }
]
themeConfig: ],
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({ themeConfig:
colorMode: { /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
defaultMode: 'light', ({
disableSwitch: false, colorMode: {
respectPrefersColorScheme: true, defaultMode: 'light',
}, disableSwitch: false,
announcementBar: { respectPrefersColorScheme: true,
id: 'announcementBar-3', // Increment on change },
content: `This documentation site is fairly new. If you find any issues, please <a target="_blank" rel="noopener noreferrer" href="https://gitea.com/gitea/gitea-docusaurus/issues">let us know</a>. We are currently working on translating the documentation into other languages.`, announcementBar: {
}, id: 'announcementBar-3', // Increment on change
navbar: { content: `This documentation site is fairly new. If you find any issues, please <a target="_blank" rel="noopener noreferrer" href="https://gitea.com/gitea/gitea-docusaurus/issues">let us know</a>. We are currently working on translating the documentation into other languages.`,
title: 'Gitea', },
logo: { navbar: {
alt: 'Gitea Logo', title: 'Gitea',
src: 'img/gitea.svg', logo: {
href: 'https://about.gitea.com/', alt: 'Gitea Logo',
target: '_self', src: 'img/gitea.svg',
}, href: 'https://about.gitea.com/',
items: [ target: '_self',
{ },
type: 'doc', items: [
docId: 'intro', {
position: 'left', type: 'doc',
label: 'Docs', docId: 'intro',
}, position: 'left',
{ label: 'Docs',
to: '/api/1.20/', },
label: 'API', {
position: 'left', to: '/api/1.20/',
activeBaseRegex: 'api/(1.19|1.20|1.21|next)/', label: 'API',
}, position: 'left',
{ activeBaseRegex: 'api/(1.19|1.20|1.21|next)/',
position: 'left', },
label: 'Blog', {
href: 'https://blog.gitea.com', position: 'left',
className: 'internal-href', label: 'Blog',
target: '_self', href: 'https://blog.gitea.com',
}, className: 'internal-href',
{ target: '_self',
type: 'custom-apiDropdown', },
label: 'API Version', {
position: 'right', type: 'custom-apiDropdown',
items: [ label: 'API Version',
{to: '/api/next/', label: '1.22-dev' }, position: 'right',
{to: '/api/1.21/', label: '1.21.0-rc0' }, items: [
{to: '/api/1.20/', label: '1.20.4' }, {to: '/api/next/', label: '1.22-dev' },
{to: '/api/1.19/', label: '1.19.4' }, {to: '/api/1.21/', label: '1.21.0-rc0' },
], {to: '/api/1.20/', label: '1.20.4' },
}, {to: '/api/1.19/', label: '1.19.4' },
{ ],
href: 'https://github.com/go-gitea/gitea', },
label: 'Code', {
position: 'left', href: 'https://github.com/go-gitea/gitea',
}, label: 'Code',
{ position: 'left',
type: 'search', },
position: 'right', {
}, type: 'search',
{ position: 'right',
type: 'localeDropdown', },
position: 'right', {
}, type: 'localeDropdown',
{ position: 'right',
type: 'docsVersionDropdown', },
position: 'right', {
dropdownActiveClassDisabled: true, type: 'docsVersionDropdown',
}, position: 'right',
{ dropdownActiveClassDisabled: true,
to: 'help/support', },
position: 'right', {
label: 'Support', to: 'help/support',
activeBaseRegex: 'help/support', position: 'right',
}, label: 'Support',
{ activeBaseRegex: 'help/support',
href: 'https://gitea.com/user/login', },
label: 'Sign In', {
position: 'right', href: 'https://gitea.com/user/login',
className: 'internal-href signin-button', label: 'Sign In',
target: '_self', position: 'right',
}, className: 'internal-href signin-button',
], target: '_self',
}, },
footer: { ],
style: 'dark', },
links: [ footer: {
{ style: 'dark',
title: 'Community', links: [
items: [ {
{ title: 'Community',
label: 'Awesome Gitea', items: [
to: '/awesome', {
}, label: 'Awesome Gitea',
{ to: '/awesome',
label: 'Stack Overflow', },
href: 'https://stackoverflow.com/questions/tagged/gitea', {
}, label: 'Stack Overflow',
{ href: 'https://stackoverflow.com/questions/tagged/gitea',
label: 'Discord', },
href: 'https://discord.gg/gitea', {
}, label: 'Discord',
{ href: 'https://discord.gg/gitea',
label: 'Matrix', },
href: 'https://matrix.to/#/#gitea-space:matrix.org', {
}, label: 'Matrix',
{ href: 'https://matrix.to/#/#gitea-space:matrix.org',
label: 'Forum', },
href: 'https://forum.gitea.com/', {
}, label: 'Forum',
{ href: 'https://forum.gitea.com/',
label: 'Twitter', },
href: 'https://twitter.com/giteaio', {
}, label: 'Twitter',
{ href: 'https://twitter.com/giteaio',
label: 'Mastodon', },
href: 'https://social.gitea.io/@gitea', {
}, label: 'Mastodon',
], href: 'https://social.gitea.io/@gitea',
}, },
{ ],
title: 'Code', },
items: [ {
{ title: 'Code',
label: 'GitHub', items: [
href: 'https://github.com/go-gitea/gitea', {
}, label: 'GitHub',
{ href: 'https://github.com/go-gitea/gitea',
label: 'Gitea', },
href: 'https://gitea.com/gitea', {
}, label: 'Gitea',
{ href: 'https://gitea.com/gitea',
label: 'Tea CLI', },
href: 'https://gitea.com/gitea/tea', {
}, label: 'Tea CLI',
], href: 'https://gitea.com/gitea/tea',
}, },
], ],
}, },
prism: { ],
theme: lightCodeTheme, },
darkTheme: darkCodeTheme, prism: {
}, theme: lightCodeTheme,
}), darkTheme: darkCodeTheme,
}; },
}),
module.exports = config; };
module.exports = config;