Skip to content

Commit 93b7f67

Browse files
i18n(ko-KR): update multiple pages (withastro#14188)
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
1 parent 65e0c82 commit 93b7f67

9 files changed

Lines changed: 108 additions & 54 deletions

File tree

src/content/docs/ko/guides/endpoints.mdx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import type { APIRoute } from "astro";
5959
const usernames = ["Sarah", "Chris", "Yan", "Elian"];
6060

6161
export const GET = (({ params, request }) => {
62-
const id = params.id;
62+
const id = Number(params.id);
6363

6464
return new Response(
6565
JSON.stringify({
@@ -113,9 +113,10 @@ export const GET = (({ params, request }) => {
113113
서버 엔드포인트는 `getStaticPaths`를 내보내지 않고도 `params`에 액세스할 수 있으며, 상태 코드 및 헤더를 설정할 수 있는 `Response` 객체를 반환할 수 있습니다.
114114

115115
```js title="src/pages/[id].json.js"
116+
import type { APIRoute } from "astro";
116117
import { getProduct } from "../db";
117118

118-
export async function GET({ params }) {
119+
export const GET = (async ({ params }) => {
119120
const id = params.id;
120121
const product = await getProduct(id);
121122

@@ -132,24 +133,26 @@ export async function GET({ params }) {
132133
"Content-Type": "application/json",
133134
},
134135
});
135-
}
136+
}) satisfies APIRoute;
136137
```
137138

138139
이렇게 하면 동적 라우트와 일치하는 모든 요청에 응답합니다. 예를 들어 `/helmet.json`으로 이동하면 `params.id``helmet`으로 설정됩니다. `helmet`이 모의 제품 데이터베이스에 존재하면 엔드포인트는 `Response` 객체를 사용하여 JSON으로 응답하고 성공적인 [HTTP 상태 코드](https://developer.mozilla.org/en-US/docs/Web/API/Response/status)를 반환합니다. 그렇지 않으면 `Response` 객체를 사용하여 `404`로 응답합니다.
139140

140141
SSR 모드에서는 특정 공급자가 이미지를 반환하기 위해 `Content-Type` 헤더를 요구합니다. 이 경우 `Response` 객체를 사용하여 `headers` 속성을 지정합니다. 예를 들어 바이너리 `.png` 이미지를 생성하려면 다음을 수행합니다.
141142

142143
```ts title="src/pages/astro-logo.png.ts"
143-
export async function GET({ params, request }) {
144+
import type { APIRoute } from "astro";
145+
146+
export const GET = (async ({ params, request }) => {
144147
const response = await fetch(
145148
"https://docs.astro.build/assets/full-logo-light.png",
146149
);
147-
const buffer = Buffer.from(await response.arrayBuffer());
148-
150+
const buffer = Buffer.from(await response.arrayBuffer()); // 타입 안전성을 위해 의존성에 `@types/node`가 필요합니다.
151+
149152
return new Response(buffer, {
150153
headers: { "Content-Type": "image/png" },
151154
});
152-
}
155+
}) satisfies APIRoute;
153156
```
154157

155158
### HTTP 메서드
@@ -159,6 +162,8 @@ export async function GET({ params, request }) {
159162
해당하는 내보낸 함수가 없는 모든 메서드와 일치하도록 `ALL` 함수를 내보낼 수도 있습니다. 일치하는 메서드가 없는 요청이 있으면 사이트의 [404 페이지](/ko/basics/astro-pages/#사용자-정의-404-오류-페이지)로 리디렉션됩니다.
160163

161164
```ts title="src/pages/methods.json.ts"
165+
import type { APIRoute } from "astro";
166+
162167
export const GET = (({ params, request }) => {
163168
return new Response(
164169
JSON.stringify({
@@ -201,6 +206,8 @@ export const ALL = (({ request }) => {
201206
SSR 모드에서 `request` 속성은 현재 요청을 참조하는 완전히 사용 가능한 [`Request`](https://developer.mozilla.org/ko/docs/Web/API/Request) 객체를 반환합니다. 이를 통해 데이터를 수락하고 헤더를 확인할 수 있습니다.
202207

203208
```ts title="src/pages/test-post.json.ts"
209+
import type { APIRoute } from "astro";
210+
204211
export const POST = (async ({ request }) => {
205212
if (request.headers.get("Content-Type") === "application/json") {
206213
const body = await request.json();
@@ -224,10 +231,11 @@ export const POST = (async ({ request }) => {
224231

225232
엔드포인트 컨텍스트는 `Astro.redirect`와 유사한 `redirect()` 유틸리티를 내보냅니다.
226233

227-
```js title="src/pages/links/[id].js" {14}
234+
```js title="src/pages/links/[id].js" {15}
235+
import type { APIRoute } from "astro";
228236
import { getLinkUrl } from "../db";
229237

230-
export async function GET({ params, redirect }) {
238+
export const GET = (async ({ params, redirect }) => {
231239
const { id } = params;
232240
const link = await getLinkUrl(id);
233241

@@ -239,5 +247,5 @@ export async function GET({ params, redirect }) {
239247
}
240248

241249
return redirect(link, 307);
242-
}
250+
}) satisfies APIRoute;
243251
```

src/content/docs/ko/guides/integrations-guide/cloudflare.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ Cloudflare 어댑터는 [`@cloudflare/vite-plugin`](https://developers.cloudflar
125125
- **`cloudflare`:** [Cloudflare Image Resizing](https://developers.cloudflare.com/images/image-resizing/) 서비스를 사용합니다.
126126
- **`cloudflare-binding`:** 이미지 변환을 위해 [Cloudflare Images 바인딩](https://developers.cloudflare.com/images/transform-images/bindings/)을 사용합니다. 바인딩은 배포 시 자동으로 프로비저닝됩니다.
127127
- **`passthrough`:** 기존 [`noop`](/ko/guides/images/#무작동-패스스루-서비스-구성) 서비스를 사용합니다.
128-
- **`compile`:** 사전 렌더링된 경로에 대해 빌드 시 로컬에서 이미지를 변환하기 위해 내부 의존성 조합을 사용합니다. 주문형 렌더링 페이지에는 noop `passthrough` 옵션이 구성됩니다.
129-
- **`custom`:** 항상 [이미지 옵션](/ko/reference/configuration-reference/#이미지-옵션)에 구성된 이미지 서비스를 사용합니다. **이 옵션은 구성된 이미지 서비스가 Cloudflare의 `workerd` 런타임에서 작동하는지 확인하지 않습니다.**
128+
- **`compile`:** [구성된 이미지 서비스](/ko/reference/configuration-reference/#imageservice)를 사용하거나, 이미지 서비스가 구성되지 않은 경우 내부 의존성을 조합하여 사전 렌더링 경로의 이미지를 빌드 시점에 로컬에서 변환합니다. 주문형 렌더링 페이지에서는 아무 작업도 수행하지 않는 `passthrough` 옵션이 사용됩니다.
129+
- **`custom`:** [구성된 이미지 서비스](/ko/reference/configuration-reference/#imageservice)(기본값: Sharp)를 사용하여 사전 렌더링 경로의 에셋을 빌드 시점에 처리합니다. 또한 런타임 이미지 처리를 위해 이미지 서비스를 번들에 포함하지만, 해당 서비스가 Cloudflare의 `workerd` 런타임과 호환되는지는 검사하지 않습니다.
130+
130131

131132
이미지 서비스를 객체로 구성하여 빌드 시점 서비스와 런타임 서비스를 각각 독립적으로 설정할 수도 있습니다. 현재 빌드 시점 옵션으로는 `'compile'`만 사용할 수 있습니다. 지원되는 런타임 옵션은 `'passthrough'` (기본값) 및 `'cloudflare-binding'`입니다.
132133

src/content/docs/ko/guides/integrations-guide/netlify.mdx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export default defineConfig({
352352
- 로컬 [Netlify Blobs](https://docs.netlify.com/build/data-and-storage/netlify-blobs/) 서버. 기본적으로 [세션](#세션)에 사용됩니다.
353353
- Netlify 구성의 [리디렉션, URL 재작성 (Rewrites)](https://docs.netlify.com/manage/routing/redirects/overview/)[헤더](https://docs.netlify.com/manage/routing/headers/)
354354
- 요청 시 렌더링되는 페이지에서 [Netlify Edge Context](#사이트에서-에지-컨텍스트에-액세스하기)에 액세스
355+
- 프로젝트의 `netlify/edge-functions` 디렉터리에 정의된 [Netlify Edge Functions](https://docs.netlify.com/build/edge-functions/overview/) 에뮬레이션
355356
- Netlify 사이트의 [환경 변수](https://docs.netlify.com/build/environment-variables/overview/)
356357

357358
로컬 사이트가 `netlify link`를 사용하여 [Netlify 사이트에 연결](https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli/#link-and-unlink-sites)되어 있을 때 가장 잘 작동합니다.
@@ -362,13 +363,13 @@ export default defineConfig({
362363

363364
<p>
364365
**타입:** `boolean | object`<br />
365-
**기본값:** `{ images: true, environmentVariables: false }`<br />
366+
**기본값:** `{ images: true, environmentVariables: false, edgeFunctions: true }`<br />
366367
<Since v="6.5.1" pkg="@astrojs/netlify"/>
367368
</p>
368369

369370
`devFeatures` 옵션은 모든 기능을 활성화 또는 비활성화하는 부울이거나 특정 기능을 활성화하는 객체일 수 있습니다.
370371

371-
```js title="astro.config.mjs" ins={7-12}
372+
```js title="astro.config.mjs" ins={7-14}
372373
import { defineConfig } from 'astro/config';
373374
import netlify from '@astrojs/netlify';
374375

@@ -380,6 +381,8 @@ export default defineConfig({
380381
images: false,
381382
// 개발 모드에서 Netlify 환경 변수를 주입합니다. 기본값은 false입니다.
382383
environmentVariables: true,
384+
// 개발 모드에서 Netlify Edge Functions를 에뮬레이션합니다. 기본값은 true입니다.
385+
edgeFunctions: false,
383386
},
384387
}),
385388
});
@@ -409,6 +412,18 @@ Netlify 사이트의 환경 변수를 개발 환경으로 주입합니다.
409412

410413
이를 통해 프로덕션 환경과 동일한 값을 개발 환경에서 사용할 수 있습니다. 환경마다 다른 변수를 사용하는 방법을 비롯한 자세한 내용은 [환경 변수에 대한 Netlify 문서](https://docs.netlify.com/build/environment-variables/overview/)를 참조하세요.
411414

415+
##### `devFeatures.edgeFunctions`
416+
417+
<p>
418+
**타입:** `boolean`<br />
419+
**기본값:** `true`<br />
420+
<Since v="8.1.0" pkg="@astrojs/netlify"/>
421+
</p>
422+
423+
개발 환경에서 프로젝트의 `netlify/edge-functions` 디렉터리에 정의된 [Netlify Edge Functions](https://docs.netlify.com/build/edge-functions/overview/)을 에뮬레이션합니다.
424+
425+
초기화 과정에서 파일 시스템에 접근하는 일부 npm 패키지는 에지 함수 샌드박스 환경에서 작동하지 않으며, `Reading or writing files with Edge Functions is not supported yet`와 같은 오류가 발생할 수 있습니다. 이러한 오류가 발생하는 경우 `edgeFunctions``false`로 설정하여 에지 함수 에뮬레이션을 비활성화하고, 대신 `netlify dev`를 사용하세요. 에지 함수는 프로덕션 빌드에서는 계속 정상적으로 동작합니다.
426+
412427
### `staticHeaders`
413428

414429
<p>

src/content/docs/ko/guides/internationalization.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ Astro는 미들웨어를 위한 도우미 함수를 제공하므로 기본 라
193193

194194
```js title="src/middleware.js"
195195
import { defineMiddleware } from "astro:middleware";
196-
import { redirectToDefaultLocale } from "astro:i18n"; // 'manual' 라우팅으로 사용 가능한 함수
197-
export const onRequest = defineMiddleware(async (ctx, next) => {
198-
if (ctx.url.startsWith("/about")) {
196+
import { redirectToDefaultLocale } from "astro:i18n"; // `manual` 라우팅에서 사용할 수 있는 함수
197+
export const onRequest = defineMiddleware((ctx, next) => {
198+
if (ctx.url.pathname.startsWith("/about")) {
199199
return next();
200200
} else {
201-
return redirectToDefaultLocale(302);
201+
return redirectToDefaultLocale(ctx, 302);
202202
}
203203
})
204204
```

src/content/docs/ko/guides/middleware.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ export function onRequest (context, next) {
257257
이 시그니처로 `next()`를 호출하면 이전 `ctx.request`를 사용하여 새 `Request` 객체가 생성됩니다. 즉, 이 리라이트 전이나 후에 `Request.body`를 사용하려고 하면 런타임 오류가 발생합니다. 이 오류는 [HTML 양식을 사용하는 Astro 액션](/ko/guides/actions/#html-양식-액션에서-액션-호출)에서 자주 발생합니다. 이러한 경우 미들웨어를 대신 `Astro.rewrite()`를 사용하여 Astro 템플릿에서 리라이트를 처리하는 것이 좋습니다.
258258

259259
```js title="src/middleware.js"
260+
import { sequence } from "astro:middleware";
261+
260262
// 현재 URL은 https://example.com/blog
261263

262264
// 첫 미들웨어 함수

src/content/docs/ko/guides/prefetch.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default defineConfig({
100100
import { prefetch } from 'astro:prefetch';
101101
102102
const btn = document.getElementById('btn');
103-
btn.addEventListener('click', () => {
103+
btn?.addEventListener('click', () => {
104104
prefetch('/about');
105105
});
106106
</script>
@@ -158,11 +158,13 @@ prefetch('/terms-of-service', { eagerness: 'moderate' });
158158
<a class="link-moderate" href="/nice-link-20">멋진 링크 20</a>
159159
160160
<script>
161-
import { prefetch } from 'astro:prefetch';
161+
import { prefetch } from "astro:prefetch";
162162
163-
const linkModerate = document.getElementsByClassName('link-moderate');
164-
linkModerate.forEach((link) => prefetch(link.getAttribute('href'), {eagerness: 'moderate'}));
165-
163+
const linkModerate = document.getElementsByClassName("link-moderate");
164+
for (const link of linkModerate) {
165+
const href = link.getAttribute("href");
166+
if (href) prefetch(href, { eagerness: "moderate" });
167+
}
166168
</script>
167169
```
168170

src/content/docs/ko/guides/routing.mdx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -431,23 +431,26 @@ Astro는 여러 페이지로 분할해야 하는 대규모 데이터 컬렉션
431431

432432
다음과 같이 `paginate()` 함수를 사용하여 값 배열에 대한 이러한 페이지를 생성할 수 있습니다.
433433

434-
```astro /{ (paginate) }/ /paginate\\(.*\\);/ /(?<=const.*)(page)/ /page\\.[a-zA-Z]+/
434+
```astro title="src/pages/astronauts/[page].astro" /{ (paginate) }/ /paginate\\(.*\\);/ /(?<=const.*)(page)/ /page\\.[a-zA-Z]+/
435435
---
436-
// src/pages/astronauts/[page].astro
437-
export function getStaticPaths({ paginate }) {
436+
import type { GetStaticPaths } from "astro";
437+
438+
export const getStaticPaths = (({ paginate }) => {
438439
const astronautPages = [
439440
{ astronaut: "Neil Armstrong" },
440441
{ astronaut: "Buzz Aldrin" },
441442
{ astronaut: "Sally Ride" },
442443
{ astronaut: "John Glenn" },
443444
];
444-
445-
// astronauts 배열로부터 페이지를 생성하며, 각 페이지에는 2개의 항목이 표시됩니다.
445+
446+
// 우주비행사 배열을 기반으로, 페이지당 2개의 항목을 포함하는 페이지를 생성합니다.
446447
return paginate(astronautPages, { pageSize: 2 });
447-
}
448-
// 페이지네이션된 모든 데이터는 "page" prop으로 전달됩니다.
448+
}) satisfies GetStaticPaths;
449+
450+
// 모든 페이지네이션 데이터는 `page` prop을 통해 전달됩니다.
449451
const { page } = Astro.props;
450452
---
453+
451454
<!-- 현재 페이지 번호를 표시합니다. `Astro.params.page`를 사용할 수도 있습니다! -->
452455
<h1>Page {page.currentPage}</h1>
453456
<ul>
@@ -502,8 +505,11 @@ interface Page<T = any> {
502505
```astro /(?<=const.*)(page)/ /page\\.[a-zA-Z]+(?:\\.(?:prev|next|first|last))?/
503506
---
504507
// src/pages/astronauts/[page].astro
508+
import type { GetStaticPaths } from "astro";
509+
505510
// 이전 예제와 동일한 `{ astronaut }` 객체 목록을 페이지로 나눕니다.
506-
export function getStaticPaths({ paginate }) { /* ... */ }
511+
export const getStaticPaths = (({ paginate }) => { /* ... */}) satisfies GetStaticPaths;
512+
507513
const { page } = Astro.props;
508514
---
509515
<h1>현재 페이지: {page.currentPage}</h1>
@@ -533,26 +539,32 @@ const { page } = Astro.props;
533539

534540
다음 예제에서는 위에 나열된 URL을 빌드하기 위해 중첩된 페이지네이션을 구현합니다.
535541

536-
```astro /(?:[(]|=== )(tag)/ "params: { tag }," /const [{ ]*(page|params)/
542+
```astro title="src/pages/[tag]/[page].astro" /(?:[(]|=== )(tag)/ "params: { tag }," /const [{ ]*(page|params)/
537543
---
538-
// src/pages/[tag]/[page].astro
539-
export function getStaticPaths({ paginate }) {
544+
import type { GetStaticPaths } from "astro";
545+
546+
export const getStaticPaths = (({ paginate }) => {
540547
const allTags = ["red", "blue", "green"];
541-
const allPosts = Object.values(import.meta.glob("../pages/post/*.md", { eager: true }));
548+
const allPosts = Object.values(
549+
import.meta.glob("../pages/post/*.md", { eager: true }),
550+
);
542551
// 모든 태그에 대해 `paginate()` 결과를 반환합니다.
543-
// Astro가 결과가 어떤 태그 그룹에 대한 것인지 알 수 있도록
544-
// `{ params: { tag }}`를 `paginate()`에 전달해야 합니다.
552+
// Astro가 결과의 태그 그룹화 대상을 알 수 있도록
553+
// 반드시 `{ params: { tag }}`를 `paginate()`에 전달하세요.
545554
return allTags.flatMap((tag) => {
546-
const filteredPosts = allPosts.filter((post) => post.frontmatter.tag === tag);
555+
const filteredPosts = allPosts.filter(
556+
(post: any) => post.frontmatter.tag === tag,
557+
);
547558
return paginate(filteredPosts, {
548559
params: { tag },
549-
pageSize: 10
560+
pageSize: 10,
550561
});
551562
});
552-
}
563+
}) satisfies GetStaticPaths;
553564
554565
const { page } = Astro.props;
555566
const params = Astro.params;
567+
---
556568
```
557569

558570
## 페이지 제외

src/content/docs/ko/guides/typescript.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,14 @@ Astro는 동적 라우트를 위한 [`getStaticPaths()`](/ko/reference/routing-r
306306

307307
`InferGetStaticParamsType`으로 [`Astro.params`](/ko/reference/api-reference/#params)의 타입을 얻고, `InferGetStaticPropsType`으로 [`Astro.props`](/ko/reference/api-reference/#props)의 타입을 얻을 수 있습니다. 또는 `GetStaticPaths`를 사용하여 두 타입을 모두 얻을 수 있습니다.
308308

309-
```astro title="src/pages/posts/[...id].astro" {2-6,18-19} "satisfies GetStaticPaths;"
309+
```astro title="src/pages/posts/[...id].astro" {2-6,19-20} "satisfies GetStaticPaths;"
310310
---
311311
import type {
312312
InferGetStaticParamsType,
313313
InferGetStaticPropsType,
314314
GetStaticPaths,
315315
} from "astro";
316+
import { getCollection } from "astro:content";
316317
317318
export const getStaticPaths = (async () => {
318319
const posts = await getCollection("blog");
@@ -327,7 +328,7 @@ export const getStaticPaths = (async () => {
327328
type Params = InferGetStaticParamsType<typeof getStaticPaths>;
328329
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
329330
330-
const { id } = Astro.params as Params;
331+
const { id } = Astro.params;
331332
// ^? { id: string; }
332333
333334
const { title } = Astro.props;

0 commit comments

Comments
 (0)