-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add new leaderboards Signed-off-by: frank-zsy <[email protected]> * fix: fix dynamic router Signed-off-by: frank-zsy <[email protected]> * fix: fix leaderboard router Signed-off-by: frank-zsy <[email protected]> * fix: fix router Signed-off-by: frank-zsy <[email protected]> * fix: fix router Signed-off-by: frank-zsy <[email protected]> --------- Signed-off-by: frank-zsy <[email protected]>
- Loading branch information
Showing
8 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = (context: any, options: any) => { | ||
const defaultLocale = context.i18n.defaultLocale; | ||
const currentLocal = context.i18n.currentLocale; | ||
if (defaultLocale !== currentLocal) { | ||
// handle i18n | ||
options.routes[0].path = `/${currentLocal}${options.routes[0].path}`; | ||
} | ||
if (process.env.PULL_NUM) { | ||
// handle preview | ||
options.routes[0].path = `/pull_${process.env.PULL_NUM}${options.routes[0].path}`; | ||
} | ||
console.log(options.routes[0].path); | ||
return { | ||
name: 'plugin-dynamic-routes', | ||
async contentLoaded({ _content, actions }) { | ||
const { routes } = options; | ||
const { addRoute } = actions; | ||
routes.map(route => addRoute(route)); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import Layout from '@theme/Layout'; | ||
import { useLocation } from '@docusaurus/router'; | ||
import SimpleTable from '../../components/SimpleTable'; | ||
import { translate } from '@docusaurus/Translate'; | ||
import axios from 'axios'; | ||
import styles from './styles.module.css'; | ||
|
||
function OpenLeaderboard() { | ||
const location = useLocation(); | ||
const leaderboardId = location.pathname.split('/').pop(); | ||
|
||
const [title, setTitle] = useState('Ranking List Title'); | ||
const [data, setData] = useState([]); | ||
const [options, setOptions] = useState([]); | ||
|
||
useEffect(() => { | ||
axios.get(`https://oss.open-digger.cn/leaderboards/${leaderboardId}.json`).then(resp => { | ||
const data = resp.data; | ||
setTitle(translate({ id: 'leaderboards.projects.title' })); | ||
setData(data.data); | ||
switch (leaderboardId) { | ||
case 'projects': | ||
setOptions([ | ||
{ name: '#', type: 'String', fields: ['rank'], width: 80 }, | ||
{ name: translate({ id: 'leaderboards.projects.name' }), type: 'StringWithIcon', fields: ['name', 'logo'], width: 250 }, | ||
{ name: 'OpenRank', type: 'String', fields: ['openrank'], width: 150 }, | ||
{ name: translate({ id: 'leaderboards.projects.initiator' }), type: 'StringWithIcon', fields: ['initiator', 'initiatorLogo'], width: 250 }, | ||
{ name: translate({ id: 'leaderboards.projects.country' }), type: 'String', fields: ['country'], width: 250 }, | ||
]); | ||
break; | ||
} | ||
}).catch(e => { | ||
console.log(e); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<Layout> | ||
<div className={styles.mainRankingList} > | ||
<SimpleTable title={title} data={data} options={options} | ||
/> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default OpenLeaderboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
html, | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
overflow-y: hidden; | ||
} | ||
|
||
.mainRankingList { | ||
width: 1200px; | ||
height: 80vh; | ||
margin: auto; | ||
overflow: hidden; | ||
} |