Skip to content

Commit 6ee838b

Browse files
i18n(ko-KR): create astro-static-paths.mdx (#13553)
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
1 parent 7361fac commit 6ee838b

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Static Paths API 참조
3+
sidebar:
4+
label: 'astro:static-paths'
5+
i18nReady: true
6+
tableOfContents:
7+
minHeadingLevel: 2
8+
maxHeadingLevel: 6
9+
---
10+
import ReadMore from '~/components/ReadMore.astro';
11+
import Since from '~/components/Since.astro';
12+
13+
<p><Since v="6.0.0" /></p>
14+
15+
이 모듈은 어댑터가 대상 런타임(예: `workerd`) 내에서 정적 경로를 수집할 수 있도록 돕는 유틸리티를 제공합니다. 이 모듈은 `prerender` Vite 환경에서만 실제 구현을 제공하며, 다른 환경에서는 아무런 동작도 수행하지 않는(no-op) 구현을 반환합니다.
16+
17+
## `astro:static-paths`에서 가져오기
18+
19+
```js
20+
import {
21+
StaticPaths,
22+
} from 'astro:static-paths';
23+
```
24+
25+
### `StaticPaths`
26+
27+
어댑터가 대상 런타임 내에서 사전 렌더링이 필요한 모든 경로를 수집할 수 있게 해줍니다. 이는 Node가 아닌 환경에서 실행되는 [사용자 정의 사전 렌더러를 구현](/ko/reference/adapter-reference/#사용자-정의-사전-렌더러)할 때 유용합니다.
28+
29+
`StaticPaths` 생성자는 필수 항목인 [SSR 매니페스트](/ko/reference/integrations-reference/#ssrmanifest)와 라우트 캐시를 설명하고 라우트를 렌더링하는 데 사용되는 컴포넌트에 접근하는 메서드를 제공하는 객체를 인자로 받습니다. `StaticPaths` 인스턴스를 초기화하는 권장 방법은 [앱 인스턴스](/ko/reference/modules/astro-app/#the-app-instance)를 전달하는 것입니다.
30+
31+
다음 예시는 어댑터 서버 진입점에서 앱을 통해 `StaticPaths` 인스턴스를 초기화합니다:
32+
33+
```js title="my-adapter/server.js"
34+
import { createApp } from 'astro/app/entrypoint';
35+
import { StaticPaths } from 'astro:static-paths';
36+
37+
const app = createApp();
38+
const staticPaths = new StaticPaths(app);
39+
40+
export const handler = (event, context) => {
41+
// `staticPaths`를 사용하여 무언가 수행합니다.
42+
};
43+
```
44+
45+
#### `StaticPaths.getAll()`
46+
47+
<p>
48+
49+
**타입:** <code>() => Promise\<Array\<\{ pathname: string, route: <a href="/ko/reference/integrations-reference/#routedata">RouteData</a> \}\>\></code>
50+
</p>
51+
52+
사전 렌더링해야 하는 모든 경로를 검색합니다. 이 메서드는 라우트 경로와 해당 데이터를 설명하는 객체 배열로 분석되는 Promise를 반환합니다.
53+
54+
다음 예시는 어댑터 핸들러에서 사전 렌더링할 모든 정적 경로를 수집하고 이를 `Response`로 반환하는 과정을 보여줍니다:
55+
56+
```js title="my-adapter/handler.js"
57+
import { StaticPaths } from 'astro:static-paths';
58+
59+
export function createHandler(app) {
60+
return async (request) => {
61+
const { pathname } = new URL(request.url);
62+
63+
// 빌드 중 정적 경로를 수집하기 위한 엔드포인트
64+
if (pathname === '/__astro_static_paths') {
65+
const staticPaths = new StaticPaths(app);
66+
const paths = await staticPaths.getAll();
67+
// { pathname: string, route: RouteData } 배열을 반환합니다.
68+
return new Response(JSON.stringify({ paths }));
69+
}
70+
71+
// ... 다른 요청 처리
72+
};
73+
}
74+
```

0 commit comments

Comments
 (0)