Render saved Studio results directly by ID without an editor
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import type {GetServerSideProps} from 'next';
|
||||
import {NativeResult} from '../components/NativeResult';
|
||||
import fixedLayouts from '../content/templates/layouts.json';
|
||||
import standardLayout from '../content/standard-layout.json';
|
||||
import {readDesign} from '../lib/design-server';
|
||||
import {nativeLayout,type Design} from '../lib/native-layout';
|
||||
import type {Layout} from '../lib/layout-parameters';
|
||||
|
||||
type Props={layout:Layout;design:Design};
|
||||
export default function TemplateLayout(props:Props){return <NativeResult {...props}/>}
|
||||
export const getServerSideProps:GetServerSideProps<Props>=async({query,req,res})=>{
|
||||
res.setHeader('Cache-Control','private, no-store');
|
||||
const design=await readDesign(query.id,req);
|
||||
if(!design)return {notFound:true};
|
||||
const layout=[standardLayout,...fixedLayouts].find(l=>l.id===design.layoutId);
|
||||
if(!layout)return {notFound:true};
|
||||
return {props:{layout:nativeLayout(layout),design}};
|
||||
};
|
||||
Reference in New Issue
Block a user