Skip to content

Commit c527725

Browse files
i18n(ko-KR): update from-nextjs, from-nuxtjs, troubleshooting, sharing-state (#14219)
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
1 parent 03cdc7e commit c527725

4 files changed

Lines changed: 127 additions & 96 deletions

File tree

src/content/docs/ko/guides/migrate-to-astro/from-nextjs.mdx

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,23 @@ React (`.jsx`) 컴포넌트에서는 표준 JSX 이미지 구문 (`<img />`)을
516516
```astro title="src/pages/index.astro" "class" "</a>" "<a"
517517
---
518518
---
519+
519520
<ul class="plain-list pokeList">
520-
{pokemons.map((pokemon) => (
521-
<li class="pokemonListItem">
522-
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
523-
<p class="pokemonId">No. {pokemon.id}</p>
524-
<img class="pokemonImage" src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`} alt={`${pokemon.name} picture`}/>
525-
<h2 class="pokemonName">{pokemon.name}</h2>
526-
</a>
527-
</li>
528-
))}
521+
{
522+
pokemons.map((pokemon: any) => (
523+
<li class="pokemonListItem">
524+
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
525+
<p class="pokemonId">No. {pokemon.id}</p>
526+
<img
527+
class="pokemonImage"
528+
src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`}
529+
alt={`${pokemon.name} picture`}
530+
/>
531+
<h2 class="pokemonName">{pokemon.name}</h2>
532+
</a>
533+
</li>
534+
))
535+
}
529536
</ul>
530537
```
531538
@@ -536,36 +543,42 @@ React (`.jsx`) 컴포넌트에서는 표준 JSX 이미지 구문 (`<img />`)을
536543
- `getStaticProps` 함수는 더 이상 필요하지 않습니다. API의 데이터는 코드 펜스에서 직접 가져옵니다.
537544
- `<Layout>` 컴포넌트를 가져와서 페이지 템플릿을 래핑합니다.
538545
539-
```astro ins={2,4-16,19,31} title="src/pages/index.astro"
546+
```astro ins={2,4-16,19,37} title="src/pages/index.astro"
540547
---
541-
import Layout from '../layouts/layout.astro';
548+
import Layout from "../layouts/layout.astro";
542549

543550
const res = await fetch("https://pokeapi.co/api/v2/pokemon?limit=151");
544551
const resJson = await res.json();
545-
const pokemons = resJson.results.map(pokemon => {
546-
const name = pokemon.name;
547-
// https://pokeapi.co/api/v2/pokemon/1/
548-
const url = pokemon.url;
549-
const id = url.split("/")[url.split("/").length - 2];
550-
return {
551-
name,
552-
url,
553-
id
554-
}
552+
const pokemons = resJson.results.map((pokemon: any) => {
553+
const name = pokemon.name;
554+
// https://pokeapi.co/api/v2/pokemon/1/
555+
const url = pokemon.url;
556+
const id = url.split("/")[url.split("/").length - 2];
557+
return {
558+
name,
559+
url,
560+
id,
561+
};
555562
});
556563
---
557564

558565
<Layout>
559566
<ul class="plain-list pokeList">
560-
{pokemons.map((pokemon) => (
561-
<li class="pokemonListItem" key={pokemon.name}>
562-
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
563-
<p class="pokemonId">No. {pokemon.id}</p>
564-
<img class="pokemonImage" src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`} alt={`${pokemon.name} picture`}/>
565-
<h2 class="pokemonName">{pokemon.name}</h2>
566-
</a>
567-
</li>
568-
))}
567+
{
568+
pokemons.map((pokemon: any) => (
569+
<li class="pokemonListItem">
570+
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
571+
<p class="pokemonId">No. {pokemon.id}</p>
572+
<img
573+
class="pokemonImage"
574+
src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`}
575+
alt={`${pokemon.name} picture`}
576+
/>
577+
<h2 class="pokemonName">{pokemon.name}</h2>
578+
</a>
579+
</li>
580+
))
581+
}
569582
</ul>
570583
</Layout>
571584
```

src/content/docs/ko/guides/migrate-to-astro/from-nuxtjs.mdx

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Astro 컴포넌트의 속성 또는 컴포넌트 속성을 바인딩하려면
300300
301301
<p aria-label={message}>...</p>
302302
<!-- 컴포넌트 props도 지원 -->
303-
<Header title={"Page"}/>
303+
<Header title="Page"/>
304304
```
305305

306306
### Nuxt Links 변환
@@ -369,15 +369,16 @@ Astro에서도 마찬가지로 두 가지 선택이 있습니다.
369369
```astro title="src/pages/pokemon/[name].astro"
370370
---
371371
export const getStaticPaths = async () => {
372-
const res = await fetch("https://pokeapi.co/api/v2/pokemon?limit=151")
372+
const res = await fetch("https://pokeapi.co/api/v2/pokemon?limit=151");
373373
const resJson = await res.json();
374374
const pokemons = resJson.results;
375-
return pokemons.map(({ name }) => ({
376-
params: { name },
377-
}))
378-
}
375+
return pokemons.map((pokemon: any) => ({
376+
params: { name: pokemon.name },
377+
}));
378+
};
379379
// ...
380380
---
381+
381382
<!-- 템플릿 작성 -->
382383
```
383384

@@ -440,7 +441,7 @@ Nuxt는 Vue의 컴포넌트 스타일을 활용하여 페이지 스타일을 생
440441

441442
마찬가지로 Astro에서는 페이지 템플릿에 `<style>` 요소를 추가하여 컴포넌트에 범위가 지정된 스타일을 제공할 수 있습니다.
442443

443-
```astro title="src/pages/index.vue"
444+
```astro title="src/pages/index.astro"
444445
---
445446
// 서버 로직 작성
446447
---
@@ -456,7 +457,7 @@ Nuxt는 Vue의 컴포넌트 스타일을 활용하여 페이지 스타일을 생
456457

457458
`<style>` 태그는 Astro에서 기본적으로 `scoped`입니다. `<style>` 태그를 전역으로 만들려면 `is:global` 속성으로 표시하세요.
458459

459-
```astro title="src/pages/index.vue"
460+
```astro title="src/pages/index.astro"
460461
<style is:global>
461462
p {
462463
color: red;
@@ -589,7 +590,7 @@ Astro 앱 내의 Vue (`.vue`) 컴포넌트에서 표준 JSX 이미지 구문 (`<
589590

590591
- `v-for``.map`이 됩니다.
591592

592-
- `:attr="val"``attr={val}`이 됩니다.
593+
- `:attr="val"``attr={val}`로 변경됩니다. 단, `key`는 Astro의 `li` 요소에서 속성으로 사용되지 않으므로 제외됩니다.
593594

594595
- `<NuxtLink>``<a>`가 됩니다.
595596

@@ -598,26 +599,33 @@ Astro 앱 내의 Vue (`.vue`) 컴포넌트에서 표준 JSX 이미지 구문 (`<
598599
```astro title="src/pages/index.astro" ".map" "</a>" "<a" "key={" "}>" "href={" " {pokemon.id}" "} alt={" "src={" "}/>" ">{pokemon.name}<"
599600
---
600601
---
602+
601603
<ul class="plain-list pokeList">
602-
{pokemons.map((pokemon) => (
603-
<li class="pokemonListItem" key={pokemon.name}>
604-
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
605-
<p class="pokemonId">No. {pokemon.id}</p>
606-
<img class="pokemonImage" src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`} alt={`${pokemon.name} picture`}/>
607-
<h2 class="pokemonName">{pokemon.name}</h2>
608-
</a>
609-
</li>
610-
))}
604+
{
605+
pokemons.map((pokemon: any) => (
606+
<li class="pokemonListItem">
607+
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
608+
<p class="pokemonId">No. {pokemon.id}</p>
609+
<img
610+
class="pokemonImage"
611+
src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`}
612+
alt={`${pokemon.name} picture`}
613+
/>
614+
<h2 class="pokemonName">{pokemon.name}</h2>
615+
</a>
616+
</li>
617+
))
618+
}
611619
</ul>
612620
613621
<style>
614-
.pokeList {
615-
display: grid;
616-
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
617-
gap: 1rem;
618-
}
622+
.pokeList {
623+
display: grid;
624+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
625+
gap: 1rem;
626+
}
619627
620-
/* ... */
628+
/* ... */
621629
</style>
622630
```
623631

@@ -629,47 +637,53 @@ Astro 앱 내의 Vue (`.vue`) 컴포넌트에서 표준 JSX 이미지 구문 (`<
629637
- `<Layout>` 컴포넌트를 가져와 페이지 템플릿을 래핑합니다.
630638
- `head()` Nuxt 메소드는 `<Layout>` 컴포넌트에 전달되며, 이는 `<title>` 요소에 속성으로 전달됩니다.
631639

632-
```astro ins={2,4-16,19,31} title="src/pages/index.astro"
640+
```astro ins={2,4-16,19,37} title="src/pages/index.astro"
633641
---
634-
import Layout from '../layouts/layout.astro';
642+
import Layout from "../layouts/layout.astro";
635643
636644
const res = await fetch("https://pokeapi.co/api/v2/pokemon?limit=151");
637645
const resJson = await res.json();
638-
const pokemons = resJson.results.map(pokemon => {
639-
const name = pokemon.name;
640-
// https://pokeapi.co/api/v2/pokemon/1/
641-
const url = pokemon.url;
642-
const id = url.split("/")[url.split("/").length - 2];
643-
return {
644-
name,
645-
url,
646-
id
647-
}
646+
const pokemons = resJson.results.map((pokemon: any) => {
647+
const name = pokemon.name;
648+
// https://pokeapi.co/api/v2/pokemon/1/
649+
const url = pokemon.url;
650+
const id = url.split("/")[url.split("/").length - 2];
651+
return {
652+
name,
653+
url,
654+
id,
655+
};
648656
});
649657
---
650658
651659
<Layout title="Pokedex: Generation 1">
652660
<ul class="plain-list pokeList">
653-
{pokemons.map((pokemon) => (
654-
<li class="pokemonListItem" key={pokemon.name}>
655-
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
656-
<p class="pokemonId">No. {pokemon.id}</p>
657-
<img class="pokemonImage" src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`} alt={`${pokemon.name} picture`}/>
658-
<h2 class="pokemonName">{pokemon.name}</h2>
659-
</a>
660-
</li>
661-
))}
661+
{
662+
pokemons.map((pokemon: any) => (
663+
<li class="pokemonListItem">
664+
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
665+
<p class="pokemonId">No. {pokemon.id}</p>
666+
<img
667+
class="pokemonImage"
668+
src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`}
669+
alt={`${pokemon.name} picture`}
670+
/>
671+
<h2 class="pokemonName">{pokemon.name}</h2>
672+
</a>
673+
</li>
674+
))
675+
}
662676
</ul>
663677
</Layout>
664678
665679
<style>
666-
.pokeList {
667-
display: grid;
668-
grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );
669-
gap: 1rem;
670-
}
680+
.pokeList {
681+
display: grid;
682+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
683+
gap: 1rem;
684+
}
671685
672-
/* ... */
686+
/* ... */
673687
</style>
674688
```
675689
</Steps>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Astro 컴포넌트 디버깅을 돕기 위해 Astro는 모든 값을 컴포넌
4040

4141
```astro {2,7}
4242
---
43-
import { Debug } from 'astro:components';
44-
const sum = (a, b) => a + b;
43+
import { Debug } from "astro:components";
44+
const sum = (a: any, b: any) => a + b;
4545
---
4646
4747
<!-- 예: 브라우저에 {answer: 6}을 출력합니다. -->
@@ -50,15 +50,16 @@ const sum = (a, b) => a + b;
5050

5151
Debug 컴포넌트는 더욱 유연하고 간결한 디버깅을 위해 다양한 구문 옵션을 지원합니다.
5252

53-
```astro {2,7-9}
53+
```astro {2,8-10}
5454
---
55-
import { Debug } from 'astro:components';
56-
const sum = (a, b) => a + b;
55+
import { Debug } from "astro:components";
56+
const sum = (a: any, b: any) => a + b;
5757
const answer = sum(2, 4);
5858
---
59+
5960
<!-- 예: 세 가지 예시는 모두 동일합니다. -->
6061
<Debug answer={sum(2, 4)} />
61-
<Debug {...{answer: sum(2, 4)}} />
62+
<Debug {...{ answer: sum(2, 4) }} />
6263
<Debug {answer} />
6364
```
6465

src/content/docs/ko/recipes/sharing-state.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,35 @@ Astro 웹 사이트를 구축할 때 컴포넌트 간 상태를 공유해야 할
5252
<button id="openDialog">Open</button>
5353
5454
<script>
55-
import { isOpen } from '../store.js';
55+
import { isOpen } from "../store.js";
5656
5757
// 버튼을 클릭하면 스토어를 true로 설정합니다.
5858
function openDialog() {
5959
isOpen.set(true);
6060
}
6161
6262
// 버튼에 이벤트 리스너 추가를 추가합니다.
63-
document.getElementById('openDialog').addEventListener('click', openDialog);
63+
document.getElementById("openDialog")?.addEventListener("click", openDialog);
6464
</script>
6565
```
6666

6767
```astro title="src/components/Dialog.astro"
6868
<div id="dialog" style="display: none">Hello world!</div>
6969
7070
<script>
71-
import { isOpen } from '../store.js';
71+
import { isOpen } from "../store.js";
7272
73+
const dialog = document.getElementById("dialog");
7374
// 스토어의 변경 사항을 수신하여 그에 따라 대화 상자를 표시하거나 숨깁니다.
74-
isOpen.subscribe(open => {
75-
if (open) {
76-
document.getElementById('dialog').style.display = 'block';
77-
} else {
78-
document.getElementById('dialog').style.display = 'none';
75+
isOpen.subscribe((open) => {
76+
if (dialog) {
77+
if (open) {
78+
dialog.style.display = "block";
79+
} else {
80+
dialog.style.display = "none";
81+
}
7982
}
80-
})
83+
});
8184
</script>
8285
```
8386
</Steps>

0 commit comments

Comments
 (0)