Replace layout workbenches with native editable pages and server-loaded designs
studio CI and deployment / verify-and-deploy (push) Failing after 2m55s
studio CI and deployment / verify-and-deploy (push) Failing after 2m55s
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import type {GetStaticPaths,GetStaticProps} from 'next';
|
||||
import {LayoutWorkbench} from '../../components/LayoutWorkbench';
|
||||
import layouts from '../../content/templates/layouts.json';
|
||||
export default function LayoutPage({id}:{id:string}){return <LayoutWorkbench layoutId={id}/>}
|
||||
export const getStaticPaths:GetStaticPaths=async()=>({paths:layouts.map(l=>({params:{id:l.id}})),fallback:false});
|
||||
export const getStaticProps:GetStaticProps=async({params})=>layouts.some(l=>l.id===params?.id)?{props:{id:params?.id}}:{notFound:true};
|
||||
@@ -0,0 +1,17 @@
|
||||
import type {GetServerSideProps} from 'next';
|
||||
import {LayoutWorkbench,type LayoutPageProps} from '../../components/LayoutWorkbench';
|
||||
import layouts from '../../content/templates/layouts.json';
|
||||
import {nativeLayout} from '../../lib/native-layout';
|
||||
import {readDesign} from '../../lib/design-server';
|
||||
export default function LayoutPage(props:LayoutPageProps){return <LayoutWorkbench key={props.design?.id||props.layout.id} {...props}/>}
|
||||
export const getServerSideProps:GetServerSideProps<LayoutPageProps>=async({params,query,req,res})=>{
|
||||
res.setHeader('Cache-Control','private, no-store');
|
||||
const layout=layouts.find(l=>l.id===params?.layoutId);
|
||||
if(!layout)return {notFound:true};
|
||||
if(query.id!==undefined){
|
||||
const design=await readDesign(query.id,req);
|
||||
if(!design||design.layoutId!==layout.id)return {notFound:true};
|
||||
return {props:{layout:nativeLayout(layout),design}};
|
||||
}
|
||||
return {props:{layout:nativeLayout(layout),design:null}};
|
||||
};
|
||||
Reference in New Issue
Block a user