diff --git a/packages/ui-scripts/src/fetchers.ts b/packages/ui-scripts/src/fetchers.ts
index 1b9fd719..292c429f 100644
--- a/packages/ui-scripts/src/fetchers.ts
+++ b/packages/ui-scripts/src/fetchers.ts
@@ -4,6 +4,7 @@ import {stringify} from 'qs'
let ACCOUNTS_BASE = '/_/sso'
let BLOG_BASE = '/_/blog'
let ASKTUG_BASE = ''
+let HOME_BASE = 'https://tidb.net'
declare global {
interface Window {
@@ -54,6 +55,8 @@ const accounts: Fetcher = (key: string) => {
switch (key) {
case 'me':
return fetch(`${ACCOUNTS_BASE}${meUrl}`, { credentials: 'include' }).then(processResponse)
+ case 'accounts.points.me':
+ return fetch(`${ACCOUNTS_BASE}/api/points/me`, { credentials: 'include' }).then(processResponse)
case 'accounts.points.top':
return fetch(`${ACCOUNTS_BASE}/api/points/top`, { credentials: 'include' }).then(processResponse)
default:
@@ -96,6 +99,12 @@ const asktug: Fetcher = (key: string, params: any) => {
case 'asktug.site':
// @ts-ignore
return fetch(`${ASKTUG_BASE}/site.json`, { headers: { accept: 'application/json' }, credentials: 'include' }).then(processResponse)
+ case 'asktug.badges':
+ // @ts-ignore
+ return fetch(`${ASKTUG_BASE}/badges.json`, { headers: { accept: 'application/json' }, credentials: 'include' }).then(processResponse)
+ case 'asktug.user.summary':
+ // @ts-ignore
+ return fetch(`${ASKTUG_BASE}/u/${params.username}/summary`, { headers: { accept: 'application/json' }, credentials: 'include' }).then(processResponse)
default:
throw new Error('not implemented')
}
@@ -114,6 +123,20 @@ const blog: Fetcher = (key: string, params: any) => {
return fetch(`${BLOG_BASE}/api/notifications/${params}/read`, { method: 'PATCH', credentials: 'include' })
case 'blog.getRecommend':
return fetch(`${BLOG_BASE}/api/posts/recommend`, {})
+ case 'blog.users.posts':
+ return fetch(`${BLOG_BASE}/blog/api/users/username/${params.username}/posts`, {})
+ default:
+ throw new Error('not implemented')
+ }
+}
+
+const home: Fetcher = (key: string, params: any) => {
+ if (typeof params === 'string') {
+ params = tryJson(params)
+ }
+ switch (key) {
+ case 'home.events':
+ return fetch(`${HOME_BASE}/next-api/cms/tidbio-homepage-main-activities`, {})
default:
throw new Error('not implemented')
}
@@ -129,5 +152,5 @@ const getAsktugCsrf = () => {
}
export default {
- accounts, asktug, blog
+ accounts, asktug, blog, home
}
diff --git a/packages/ui-scripts/src/index.asktug.tsx b/packages/ui-scripts/src/index.asktug.tsx
index 83226f4b..2e36e8e5 100644
--- a/packages/ui-scripts/src/index.asktug.tsx
+++ b/packages/ui-scripts/src/index.asktug.tsx
@@ -5,6 +5,7 @@ import {
Env,
Footer,
Header,
+ Sidebar,
Site,
SiteComponentsContext
} from '@pingcap-inc/tidb-community-site-components'
@@ -46,6 +47,14 @@ const context = {
fetchers,
}
+const AsktugSidebar = () => {
+ const element = document.getElementById('asktug-sidebar')
+ if (!element) {
+ return null
+ }
+ return ReactDOM.createPortal(, element)
+}
+
const AsktugHeader = () => {
const headerElem = document.getElementById('asktug-header')
if (!headerElem) {
@@ -95,6 +104,7 @@ const AsktugSite = () => {
+
)
}