Explorar el Código

add isr page

main
shigeo.shinohara hace 2 años
padre
commit
8b83282e58
Se han modificado 1 ficheros con 34 adiciones y 0 borrados
  1. +34
    -0
      pages/isr.tsx

+ 34
- 0
pages/isr.tsx Ver fichero

@@ -0,0 +1,34 @@
import React, { FC } from "react";
import { fetchGuitars } from "../lib/strapi";
import { GetStaticProps } from "next";
import { Guitar, GuitarResponse } from "../type/guitars";

// ===========================
// getStaticPropsのpropsに設定したデータを引数で受け取れる
// ==========================
const Isr: FC<GuitarResponse> = ({ guitars }) => {
return (
<div>
{guitars.map((guitar: Guitar) => {
return <div key={guitar.id}>{guitar.attributes.name}</div>;
})}
</div>
);
};

// ===============================
// 静的サイト作成時にはgetStaticPropsの中で
// 表示データを作成する
// ===============================
export const getStaticProps: GetStaticProps = async () => {
const guitars = await fetchGuitars();
return {
props: {
guitars,
},
// キャッシュする秒数
revalidate: 20,
};
};

export default Isr;

Cargando…
Cancelar
Guardar