Files
gitea-docs/docusaurus.config.js
HesterG 1ba3ac7c99 Add outdated component to outdated documents (#25)
- `git log` needs all commit history to compare latest commit of files, so changed `git clone --depth=1` to `git clone`. This will make the step take longer, so might be improved if there is a better way.

- `src/theme/MDXContent/index.js` is from [ejecting of the component](https://docusaurus.io/docs/swizzling#ejecting) inside `@docusaurus/theme-classic` plugin, and this one is safe to eject according to docusaurus

    ![Screen Shot 2023-06-06 at 12.12.28](/attachments/17a3a84b-cec0-4849-8bd6-9e0471d9536f)

    ![Screen Shot 2023-06-06 at 12.12.15](/attachments/58bba321-3cfb-4a8b-8aeb-84422a06c472)

- [Outdated component style reference](https://mui.com/material-ui/react-alert/)

- Added [`Translate` component](https://docusaurus.io/docs/next/docusaurus-core#translate) to `Outdated` so it can be localized. [reference](https://docusaurus.io/docs/next/i18n/tutorial#translate-your-react-code)

- One way to check for the specific outdated documents:

    search for `lastest commit timestamp` in [prepare nightly docs and prepare 1.19 docs steps](https://gitea.com/gitea/gitea-docusaurus/actions/runs/74)

# After

The Chinese documents that are outdated (latest commit is ealier than laster commit of English version):

![Screen Shot 2023-06-06 at 13.04.24](/attachments/e5d16267-d8d8-434e-89b1-138d04ec92a3)

![Screen Shot 2023-06-06 at 13.05.07](/attachments/af8f996a-5318-4f89-841f-b27a4903a27d)

![Screen Shot 2023-06-06 at 13.05.14](/attachments/e6aba31b-46ba-4a32-ad81-81007e0f711e)

Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/25
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: HesterG <hestergong@gmail.com>
Co-committed-by: HesterG <hestergong@gmail.com>
2023-06-08 03:34:23 +00:00

194 lines
5.4 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-us',
locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
localeConfigs: {
'en-us': {
label: 'English',
},
'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: ({versionDocsDirPath, docPath, locale, version, permalink}) => {
let fileName = `doc/${docPath.replace('.md', '')}.${locale}.md`;
// intro.md has different name from upstream, need to handle this here
if (docPath.includes('intro.md')) {
fileName = `page/index.${locale}.md`;
}
return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`;
},
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;