File size: 587 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import fs from 'fs'
import path from 'path'
let gspCalls = 0
export async function getStaticProps() {
const data = await fs.promises.readFile(
path.join(process.cwd(), 'data.txt'),
'utf8'
)
gspCalls += 1
if (data.trim() === 'hide') {
return {
notFound: true,
revalidate: 1,
}
}
return {
props: {
hello: 'world',
data,
gspCalls,
},
revalidate: 1,
}
}
export default function Page(props) {
return (
<>
<p id="gsp">getStaticProps page</p>
<p id="props">{JSON.stringify(props)}</p>
</>
)
}
|