blog/frontend/src/routes/post/+page.server.ts
SquidSpirit 24a98f8f70
All checks were successful
Frontend CI / build (push) Successful in 6m14s
BLOG-126 Post management (list and create) (#139)
### Description

- As the title

### Package Changes

_No response_

### Screenshots

|Scenario|Screenshot|
|-|-|
|Posts list|![截圖 2025-10-15 凌晨4.09.28.png](/attachments/c8ad41e8-1065-4249-90e3-977bd36031e8)|
|Empty input|![截圖 2025-10-15 凌晨4.10.12.png](/attachments/c902fdc0-4287-4b5d-9b9e-63dd6a5604a6)|
|Pattern not matched|![截圖 2025-10-15 凌晨4.11.05.png](/attachments/88e4fb1d-6a69-4305-a94c-bd48982bb8a5)|

### Reference

Resolve #126.

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #139
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-10-15 04:21:13 +08:00

14 lines
346 B
TypeScript

import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ locals }) => {
const { container } = locals;
const store = container.createPostsListedStore();
const { trigger: loadPosts } = store;
const state = await loadPosts();
return {
dehydratedData: state.data?.map((post) => post.dehydrate()),
};
};