@@ -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---
371371export 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 >
0 commit comments