Skip to content

Commit

Permalink
i18n(ko-KR): update server-side-rendering.mdx (withastro#8142)
Browse files Browse the repository at this point in the history
* i18n(ko-KR): update `server-side-rendering.mdx`

* Update src/content/docs/ko/guides/server-side-rendering.mdx

Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>

---------

Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
  • Loading branch information
2 people authored and wpplumber committed May 15, 2024
1 parent 5115fe1 commit afaad4f
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/content/docs/ko/guides/server-side-rendering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,42 @@ API 참조에서 [`Astro.cookies` 및 `AstroCookie` 타입](/ko/reference/api-re

### `Response`

주문형 렌더링을 사용하면 모든 페이지에서 [Response](https://developer.mozilla.org/ko/docs/Web/API/Response)를 반환할 수도 있습니다.
[`Astro.response`](/ko/reference/api-reference/#astroresponse)는 표준 [`ResponseInit`](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#options) 객체입니다. 응답 상태와 헤더를 설정하는 데 사용할 수 있습니다.

아래 예시에서는 제품이 존재하지 않는 경우 제품 목록 페이지에 대한 응답 상태 및 상태 텍스트를 설정합니다.

```astro title="src/pages/my-product.astro" {8-9}
---
import { getProduct } from '../api';
const product = await getProduct(Astro.params.id);
// 제품을 찾을 수 없는 경우
if (!product) {
Astro.response.status = 404;
Astro.response.statusText = 'Not found';
}
---
<html>
<!-- 페이지 -->
</html>
```

#### `Astro.response.headers`

`Astro.response.headers` 객체를 사용하여 헤더를 설정할 수 있습니다.

```astro title="src/pages/index.astro" {2}
---
Astro.response.headers.set('Cache-Control', 'public, max-age=3600');
---
<html>
<!-- 페이지 -->
</html>
```

#### `Response` 객체 반환

주문형 렌더링을 사용하면 모든 페이지에서 직접 [Response](https://developer.mozilla.org/ko/docs/Web/API/Response) 객체를 반환할 수도 있습니다.

아래 예시는 데이터베이스에서 id를 조회한 후 동적 페이지에 404를 반환합니다.

Expand Down

0 comments on commit afaad4f

Please sign in to comment.