File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1+ function Skeleton ( ) {
2+ return (
3+ < div className = "skeleton" >
4+ < div className = "s-banner" > </ div >
5+ < div className = "s-header" > </ div >
6+ < div className = "s-content" > </ div >
7+ < div className = "s-content" > </ div >
8+ < div className = "s-content" > </ div >
9+ < style jsx > { `
10+ .skeleton {
11+ max-width: 1200px;
12+ margin: 20px auto;
13+ }
14+ .skeleton > div {
15+ background: #dbcc1a;
16+ border-radius: 4px;
17+ margin: 20px 0;
18+ }
19+ .s-banner {
20+ padding: 12% 0;
21+ }
22+ .s-header {
23+ padding: 15px 0;
24+ max-width: 500px;
25+ }
26+ .s-content {
27+ padding: 8px 0;
28+ max-width: 1000px;
29+ }
30+ ` } </ style >
31+ </ div >
32+ ) ;
33+ }
34+
35+ export default Skeleton ;
Original file line number Diff line number Diff line change 11import { createClient } from "contentful" ;
22import { documentToReactComponents } from "@contentful/rich-text-react-renderer" ;
33import Image from "next/image" ;
4+ import Skeleton from "../../components/Skeleton" ;
45
56const client = createClient ( {
67 space : process . env . CONTENTFUL_SPACE_ID ,
@@ -14,7 +15,10 @@ export const getStaticPaths = async () => {
1415 params : { slug : item . fields . slug } ,
1516 } ;
1617 } ) ;
17- return { paths, fallback : false } ;
18+ return {
19+ paths,
20+ fallback : true , // handle new recipes
21+ } ;
1822} ;
1923
2024export async function getStaticProps ( { params } ) {
@@ -31,6 +35,8 @@ export async function getStaticProps({ params }) {
3135}
3236
3337export default function RecipeDetails ( { recipe } ) {
38+ if ( ! recipe ) return < Skeleton /> ;
39+
3440 const {
3541 featuredImage,
3642 title,
You can’t perform that action at this time.
0 commit comments