mirror of
https://gitea.com/gitea/docs.git
synced 2026-03-27 14:11:03 +07:00
# Main changes and Some notices - Chines Docs should be put into corresponding versions' folders under `i18n/zh-cn/docusaurus-plugin-content-docs`. See [translate-markdown-files](https://docusaurus.io/docs/i18n/tutorial#translate-markdown-files) for reference. And also [srs-docs](https://github.com/ossrs/srs-docs) is a project that can be used as a reference. So changed the related paths in `loop_docs*` scripts. - The markdown files under `docs/<version>` and `i18n/zh-cn/docusaurus-plugin-content-docs/<version>` must have the same name to be referred as translated. Files inside docs are corresponding to `current` version. For example, `docs/administration/mail-templates.md` and `i18n/zh-cn/docusaurus-plugin-content-docs/current/administration/mail-templates.md`. Filename of `mail-templates.md` must be the same (cannot be `mail-templates.zh-cn.md` and `mail-templates.us-en.md`) So trim the `.en-us.md` and `.zh-cn.md` to `.md` to ensure the same names inside `loop_docs*` scripts. - Used `npx docusaurus write-translations --locale zh-cn` to do sidebar, footer, and header translations, so no need to keep `sideBarCN` anymore. [reference](https://docusaurus.io/docs/cli#docusaurus-write-translations-sitedir) - Local Tests for `en` and `zh-cn` are separeted, run the following on local respectly to test them ```bash # test en version npm run start # test zh-cn version npm run start -- --locale zh-cn ``` - If wants to test `en` and `zh-cn` both at the same time, run build and serve ``` npm run build npm run serve ``` - Added some indexed page, for example:   Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/13 Co-authored-by: HesterG <hestergong@gmail.com> Co-committed-by: HesterG <hestergong@gmail.com>
190 lines
5.0 KiB
JavaScript
190 lines
5.0 KiB
JavaScript
// @ts-check
|
|
// Note: type annotations allow type checking and IDEs autocompletion
|
|
|
|
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
|
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
|
|
|
// order usage directory by type first
|
|
function sortItemsByCategory(items) {
|
|
// type with "category" (directory) first
|
|
const sortedItems = items.sort(function(a, b) {
|
|
return a.type.localeCompare(b.type);
|
|
})
|
|
return sortedItems;
|
|
}
|
|
|
|
/** @type {import('@docusaurus/types').Config} */
|
|
const config = {
|
|
title: 'Gitea Documentation',
|
|
tagline: 'Git with a cup of tea',
|
|
url: 'https://docs.gitea.com',
|
|
baseUrl: '/',
|
|
onBrokenLinks: 'warn',
|
|
onBrokenMarkdownLinks: 'warn',
|
|
favicon: 'img/favicon.png',
|
|
|
|
i18n: {
|
|
defaultLocale: 'en',
|
|
locales: ['en', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
|
|
localeConfigs: {
|
|
'en': {
|
|
label: 'English',
|
|
htmlLang: 'en-US',
|
|
},
|
|
'zh-cn': {
|
|
label: '中文',
|
|
},
|
|
},
|
|
},
|
|
|
|
presets: [
|
|
[
|
|
'@docusaurus/preset-classic',
|
|
//'classic',
|
|
/** @type {import('@docusaurus/preset-classic').Options} */
|
|
({
|
|
docs: {
|
|
sidebarPath: require.resolve('./sidebars.js'),
|
|
routeBasePath: '/', // Serve the docs at the site's root
|
|
editUrl: ({locale, versionDocsDirPath, docPath}) => {
|
|
return `https://github.com/go-gitea/gitea/tree/main/docs/content/doc/${docPath}`
|
|
},
|
|
versions: {
|
|
current: {
|
|
label: '1.20-dev', // path is kept as next for dev (so users can always find "nightly" docs)
|
|
},
|
|
1.19 : {
|
|
label: '1.19.3'
|
|
}
|
|
},
|
|
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
|
|
const {item} = args;
|
|
// Use the provided data to generate a custom sidebar slice
|
|
const sidebarItems = await defaultSidebarItemsGenerator(args);
|
|
if (item.dirName !== 'usage') {
|
|
return sidebarItems;
|
|
} else {
|
|
return sortItemsByCategory(sidebarItems);
|
|
}
|
|
},
|
|
},
|
|
blog: false,
|
|
theme: {
|
|
customCss: require.resolve('./src/css/custom.css'),
|
|
},
|
|
}),
|
|
],
|
|
],
|
|
themes: [
|
|
[
|
|
"@easyops-cn/docusaurus-search-local",
|
|
{
|
|
hashed: false,
|
|
language: ["en", "zh"],
|
|
highlightSearchTermsOnTargetPage: true,
|
|
explicitSearchResultPath: true,
|
|
indexBlog: false,
|
|
docsRouteBasePath: "/"
|
|
}
|
|
]
|
|
],
|
|
|
|
themeConfig:
|
|
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
|
({
|
|
colorMode: {
|
|
defaultMode: 'light',
|
|
disableSwitch: false,
|
|
respectPrefersColorScheme: true,
|
|
},
|
|
announcementBar: {
|
|
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.`,
|
|
},
|
|
navbar: {
|
|
title: 'Gitea',
|
|
logo: {
|
|
alt: 'Gitea Logo',
|
|
src: 'img/gitea.svg',
|
|
},
|
|
items: [
|
|
{
|
|
to: '/',
|
|
position: 'left',
|
|
label: 'Docs',
|
|
},
|
|
{
|
|
href: 'https://github.com/go-gitea/gitea',
|
|
label: 'Code',
|
|
position: 'left',
|
|
},
|
|
{
|
|
type: 'search',
|
|
position: 'right',
|
|
},
|
|
{
|
|
type: 'localeDropdown',
|
|
position: 'right',
|
|
},
|
|
{
|
|
type: 'docsVersionDropdown',
|
|
position: 'right',
|
|
dropdownActiveClassDisabled: true,
|
|
},
|
|
{
|
|
to: 'help/seek-help',
|
|
position: 'right',
|
|
label: 'Support',
|
|
activeBaseRegex: 'help/seek-help',
|
|
}
|
|
],
|
|
},
|
|
footer: {
|
|
style: 'dark',
|
|
links: [
|
|
{
|
|
title: 'Docs',
|
|
items: [
|
|
{
|
|
label: 'Tutorial',
|
|
to: '/',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: 'Community',
|
|
items: [
|
|
{
|
|
label: 'Stack Overflow',
|
|
href: 'https://stackoverflow.com/questions/tagged/gitea',
|
|
},
|
|
{
|
|
label: 'Discord',
|
|
href: 'https://discord.gg/gitea',
|
|
},
|
|
{
|
|
label: 'Twitter',
|
|
href: 'https://twitter.com/giteaio',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: 'More',
|
|
items: [
|
|
{
|
|
label: 'Code',
|
|
href: 'https://github.com/go-gitea/gitea',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
prism: {
|
|
theme: lightCodeTheme,
|
|
darkTheme: darkCodeTheme,
|
|
},
|
|
}),
|
|
};
|
|
|
|
module.exports = config;
|