Skip to content

Commit

Permalink
fix: Sort Timeline (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicstone authored Jun 26, 2023
1 parent c37a3e2 commit 3896464
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/features/Timeline/TimelineVirtualizedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const query = graphql`
nodes {
__typename
id
dateX: date(formatString: "X")
... on ArticlesYaml {
...TimelineArticleCard
}
Expand Down Expand Up @@ -113,6 +114,13 @@ export const TimelineVirtualizedList = ({
const minHeightSingleColumn = (CARD_HEIGHT + 24) * (items.nodes.length + 1);
const minHeightDoubleColumn = minHeightSingleColumn / 2;

// XXX: Gatsby でなぜかソートされないことがあるため
// クライアント側でもう一回ソートする
// 重くなるため早めに原因特定したい
const sortedItems = Array.from(items.nodes).sort((a, b) => {
return Number(b.dateX) - Number(a.dateX);
});

const FallBack = (): JSX.Element => (
<div
aria-busy="true"
Expand All @@ -131,7 +139,7 @@ export const TimelineVirtualizedList = ({
return (
<NoSsr defer fallback={<FallBack />}>
<VirtuosoGrid
data={items.nodes}
data={sortedItems}
components={{
List: Container,
}}
Expand Down
14 changes: 14 additions & 0 deletions src/generated/graphqlTypes.ts

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

6 changes: 0 additions & 6 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ const NotFound = (): JSX.Element => {
>
{TRANSLATION.notFound.backToTimeline}
</Button>
<Button
component={RouterLink}
variant="outlined"
to="/"
color="secondary"
></Button>
</div>
</Container>
);
Expand Down

0 comments on commit 3896464

Please sign in to comment.