Skip to content

Commit

Permalink
Merge pull request #1 from ai4agi/dev
Browse files Browse the repository at this point in the history
feat: add nextra framework
  • Loading branch information
AmbroseX authored Feb 6, 2024
2 parents 8852507 + 1b2ddad commit 6659b64
Show file tree
Hide file tree
Showing 29 changed files with 3,237 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.next
node_modules
124 changes: 124 additions & 0 deletions README.install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
## Awesome-AIGC-Info




# Start as New Project
## Install
```shell
yarn add next react react-dom nextra nextra-theme-docs
```

> If you already have Next.js installed in your project, you only need to install nextra and nextra-theme-docs as the add-ons.
Add the following scripts in package.json:
```json
package.json
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
```

You can either start the server with, for example if you use npm, npm run dev, which will run in development mode or npm run build && npm run start for production mode.


## Add Next.js Config

Create the following `next.config.ts` file in your project’s root directory:

```ts
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx'
})

module.exports = withNextra()

// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })
```

With the above configuration, Nextra can handle Markdown files in your Next.js project, with the specified theme. Other Nextra configurations can be found in [Guide](https://nextra.site/docs/guide).


## Create Docs Theme Config
Lastly, create the corresponding `theme.config.jsx` file in your project’s root directory. This will be used to configure the Nextra Docs theme:

```jsx
export default {
logo: <span>My Nextra Documentation</span>,
project: {
link: 'https://github.com/shuding/nextra'
}
// ... other theme options
}
```
Full theme configurations can be found here.

## Ready to Go!
Now, you can create your first MDX page as `pages/index.mdx`:

```mdx
# Welcome to Nextra

Hello, world!
```
And run the next or next dev command specified in package.jsonto start developing the project! 🎉

# Add I18n Config
## Add Config
To add multi-language pages to your Nextra application, you need to config i18n in `next.config.js` first:

```js
next.config.js
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx'
})

module.exports = withNextra({
i18n: {
locales: ['en-US', 'zh-CN', 'de-DE'],
defaultLocale: 'en-US'
}
})
```

## Add Middleware
Then, you need to add a `middleware.js` file in the root of your project (related Next.js docs):
```js
export { locales as middleware } from 'nextra/locales'
```
If you already have the middleware defined, you can do this instead:

```js
import { withLocales } from 'nextra/locales'

export const middleware = withLocales(request => {
// Your middleware code...
})
```
Add Locale to Filenames
Then, add the locale codes to your file extensions (required for the default locale too):

/pages
_meta.en-US.json
_meta.zh-CN.json
_meta.de-DE.json
index.en-US.md
index.zh-CN.md
index.de-DE.md
...

Configure the Docs Theme
Finally, add the i18n option to your theme.config.jsx to configure the language dropdown:

theme.config.jsx
i18n: [
{ locale: 'en-US', text: 'English' },
{ locale: 'zh-CN', text: '中文' },
{ locale: 'de-DE', text: 'Deutsch' },
{ locale: 'ar-SA', text: 'العربية', direction: 'rtl' }
]
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
## Awesome-AIGC-Info

15 changes: 15 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
## 前言

[![Awesome](https://camo.githubusercontent.com/64f8905651212a80869afbecbf0a9c52a5d1e70beab750dea40a994fa9a9f3c6/68747470733a2f2f617765736f6d652e72652f62616467652e737667)](https://github.com/ai4agi/Awesome-AIGC-Info)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
![](https://img.shields.io/github/last-commit/luban-agi/Awesome-AIGC-Tutorials?color=green)
[![GitHub Repo stars](https://img.shields.io/github/stars/ai4agi/Awesome-AIGC-Info?style=social)](https://github.com/ai4agi/Awesome-AIGC-Info)


English | [中文版](README_ZH.md)

使用协议
本仓库遵循 FastGPT Open Source License 开源协议。

允许作为后台服务直接商用,但不允许提供 SaaS 服务。
未经商业授权,任何形式的商用服务均需保留相关版权信息。
完整请查看 FastGPT Open Source License
联系方式:[email protected],点击查看商业版定价策略
5 changes: 5 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { withLocales } from 'nextra/locales'

export const middleware = withLocales(request => {
// Your middleware code...
})
24 changes: 24 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
latex: true
})

module.exports = withNextra({
i18n: {
locales: ['zh-CN', 'en-US'],
defaultLocale: 'zh-CN'
},
// domains: [{
// domain: 'info.ai4agi.org',
// defaultLocale: 'zh-CN'
// },
// {
// domain: 'info.ai4agi.cn',
// defaultLocale: 'zh-CN'
// }
// ]
}
)
// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^14.1.0",
"nextra": "^2.13.3",
"nextra-theme-docs": "^2.13.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions pages/_meta.en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"index": "Homepage",
"contact": "Contact Us",
"about": "About Us"
}
32 changes: 32 additions & 0 deletions pages/_meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"index": {
"title": "首页",
"theme": {
"breadcrumb": false,
"footer": true,
"sidebar": false,
"toc": true,
"pagination": false
}
},
"official_account": {
"title": "公众号",
"type": "page"
},
"----": {
"type": "separator"
},
"aigc-job": {
"title": "AIGC 求职",
"type": "page"
},
"---": {
"type": "separator"
},
"about": "关于我们",
"contact": "联系我们",
"github_link": {
"title": "Github",
"href": "https://github.com/ai4agi/Awesome-AIGC-Info"
}
}
File renamed without changes.
Empty file added pages/aigc-job.zh-CN.mdx
Empty file.
3 changes: 3 additions & 0 deletions pages/aigc-job/_meta.en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"index": "AIGC Job Homepage"
}
8 changes: 8 additions & 0 deletions pages/aigc-job/_meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"index": "AIGC 求职",
"aigc_knowledge": {
"title": "AIGC 知识库",
"type": "page"
},
"interview_experience": "AIGC 面试经验"
}
Empty file.
3 changes: 3 additions & 0 deletions pages/aigc-job/aigc_knowledge/_meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"index": "AIGC 知识点"
}
1 change: 1 addition & 0 deletions pages/aigc-job/aigc_knowledge/index.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# AIGC知识点
3 changes: 3 additions & 0 deletions pages/aigc-job/index.en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Welcome to Awesome AIGC Info

Hello, world!
1 change: 1 addition & 0 deletions pages/aigc-job/index.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 关于AIGC求职
Empty file.
9 changes: 9 additions & 0 deletions pages/aigc-job/interview_experience/_meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"index": "AIGC 面经",
"----": {
"type": "separator"
},
"resume_template": {
"title": "简历模板"
}
}
1 change: 1 addition & 0 deletions pages/aigc-job/interview_experience/index.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# AIGC面经
Empty file.
Empty file added pages/contact.zh-CN.mdx
Empty file.
3 changes: 3 additions & 0 deletions pages/index.en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Welcome to Awesome AIGC Info

Hello, world!
7 changes: 7 additions & 0 deletions pages/index.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 欢迎来到 Awesome AIGC Info

Hello, world!



The **Pythagorean equation**: $a=\sqrt{b^2 + c^2}$.
Empty file.
Loading

0 comments on commit 6659b64

Please sign in to comment.