Skip to content

Commit

Permalink
[optimize] update index.tsx getStaticProps ISR
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrunlin committed Aug 5, 2023
1 parent 34ef4f6 commit 7b17514
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"mobx-lark": "^1.0.0-beta.6",
"mobx-react": "^6.3.1",
"mobx-restful": "^0.6.5",
"mobx-restful-table": "^1.0.2",
"mobx-restful-table": "^1.0.4",
"next": "^12.3.4",
"react": "^17.0.2",
"react-bootstrap": "^2.7.4",
Expand Down
42 changes: 20 additions & 22 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,29 @@ import { ProjectModel } from '../models/Project';
import { RepositoryModel } from '../models/Repository';
import { i18n } from '../models/Translation';
import styles from '../styles/Home.module.less';
import { getTarget, withErrorLog, withTranslation } from './api/core';
import { getTarget } from './api/core';
import { service } from './api/home';

export const getServerSideProps = withErrorLog(
withTranslation(async () => {
const [projects, repositories, partners, members] = await Promise.all([
new ProjectModel().getList({}, 1, 9),
new RepositoryModel().getList(),
new ClientModel().getList({ partnership: '战略合作' }),
new MemberModel().getList({ type: '全职' }),
]);
export const getServerSideProps = async () => {
const [projects, repositories, partners, members] = await Promise.all([
new ProjectModel().getList({}, 1, 9),
new RepositoryModel().getList(),
new ClientModel().getList({ partnership: '战略合作' }),
new MemberModel().getList({ type: '全职' }),
]);

return {
props: {
projects,
repositories,
partners,
members: [...members].sort(
({ joinedAt: a }, { joinedAt: b }) =>
+new Date(a as number) - +new Date(b as number),
),
},
};
}),
);
return {
props: {
projects,
repositories,
partners,
members: [...members].sort(
({ joinedAt: a }, { joinedAt: b }) =>
+new Date(a as number) - +new Date(b as number),
),
},
};
};

const { t } = i18n;

Expand Down
52 changes: 44 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 7b17514

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for idea2app ready!

✅ Preview
https://idea2app-p20w5auqu-techquery.vercel.app

Built with commit 7b17514.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.