mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
updated github link
This commit is contained in:
parent
6821b0e00b
commit
e1e0a16b44
@ -82,7 +82,7 @@ const PreviewBar = ({ isPreview, isDevelopmentMode }) => {
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
href="https://github.com/agility/agilitycms-nextjs-starter"
|
||||
href="https://github.com/agility/nextjs-commerce-agilitycms"
|
||||
target="_blank"
|
||||
title="View on GitHub"
|
||||
className="text-2xl"
|
||||
|
@ -1,62 +0,0 @@
|
||||
import PreviewBar from './PreviewBar'
|
||||
import GlobalHeader from './GlobalHeader'
|
||||
import GlobalFooter from './GlobalFooter'
|
||||
import { useRouter } from 'next/router'
|
||||
import Head from 'next/head'
|
||||
import dynamic from 'next/dynamic'
|
||||
import tw from "twin.macro"
|
||||
|
||||
const MainElem = tw.main`p-8`;
|
||||
|
||||
import AnimationRevealPage from "helpers/AnimationRevealPage"
|
||||
import Error from 'next/error'
|
||||
|
||||
function Layout(props) {
|
||||
const { page, sitemapNode, dynamicPageItem, notFound } = props
|
||||
|
||||
// If the page is not yet generated, this will be displayed
|
||||
// initially until getStaticProps() finishes running
|
||||
const router = useRouter()
|
||||
if (router.isFallback) {
|
||||
return <div>Loading page...</div>
|
||||
}
|
||||
|
||||
if (notFound === true) {
|
||||
return <Error statusCode="404" />
|
||||
}
|
||||
|
||||
const AgilityPageTemplate = dynamic(() => import('components/agility-pageTemplates/' + props.pageTemplateName));
|
||||
|
||||
if (dynamicPageItem?.seo?.metaDescription) {
|
||||
page.seo.metaDescription = dynamicPageItem.seo.metaDescription
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{sitemapNode?.title} - Agility CMS Sample Blog</title>
|
||||
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
|
||||
<meta name="description" content={page.seo.metaDescription} />
|
||||
<meta name="generator" content="Agility CMS" />
|
||||
<meta name="agility_timestamp" content={new Date().toLocaleString()} />
|
||||
{dynamicPageItem?.seo?.ogImage &&
|
||||
<meta property="og:image" content={dynamicPageItem.seo.ogImage} />
|
||||
}
|
||||
<link rel="stylesheet" href="/prose.css" />
|
||||
|
||||
</Head>
|
||||
<PreviewBar {...props} />
|
||||
|
||||
<MainElem>
|
||||
{/* <AnimationRevealPage disabled> */}
|
||||
<GlobalHeader {...props} />
|
||||
<AgilityPageTemplate {...props} />
|
||||
<GlobalFooter {...props} />
|
||||
{/* </AnimationRevealPage> */}
|
||||
</MainElem>
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Layout
|
@ -1,60 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
const PreviewBar = ({ isPreview, isDevelopmentMode }) => {
|
||||
|
||||
if (isPreview && !isDevelopmentMode) {
|
||||
return (
|
||||
<div className="agility-preview-bar">
|
||||
<img className="agility-preview-bar__logo" src="https://media.agilitycms.com/preview-bar/2018-11/agility-logo-preview-bar-1.png" alt="Powered by Agility CMS" />
|
||||
<span className="agility-preview-bar__text">You are viewing the latest changes in <strong>Preview Mode</strong>.</span>
|
||||
<div>
|
||||
<button className="agility-preview-bar__btn agility-preview-bar__btn-share" title="Click to generate a share-able link" onClick={getPreviewLink}>Share</button>
|
||||
<button className="agility-preview-bar__btn" title="Click to exit preview" onClick={exitPreview}>Exit Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else if(isDevelopmentMode) {
|
||||
return (
|
||||
<div className="agility-preview-bar">
|
||||
<img className="agility-preview-bar__logo" src="https://media.agilitycms.com/preview-bar/2018-11/agility-logo-preview-bar-1.png" alt="Powered by Agility CMS" />
|
||||
<span className="agility-preview-bar__text">You are viewing the latest changes in <strong>Development Mode</strong>.</span>
|
||||
<div></div>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const exitPreview = () => {
|
||||
const exit = confirm("Would you like to exit Preview Mode?");
|
||||
if (exit === true) {
|
||||
window.location = `/api/exitPreview?slug=${window.location.pathname}`;
|
||||
}
|
||||
}
|
||||
|
||||
const getPreviewLink = () => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.onload = function () {
|
||||
|
||||
// Process our return data
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
// What do when the request is successful
|
||||
|
||||
const previewKey = xhr.responseText;
|
||||
const previewLink = `${window.location.pathname}?agilitypreviewkey=${escape(previewKey)}`;
|
||||
|
||||
prompt("To share this page in preview mode with others, copy the link below:", previewLink);
|
||||
|
||||
} else {
|
||||
// What do when the request fails
|
||||
alert('Could not generate Preview Link. This indicates a problem with the API route that generates a Preview Link.')
|
||||
}
|
||||
};
|
||||
|
||||
// Create and send a GET request
|
||||
xhr.open('GET', '/api/generatePreviewKey');
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
export default PreviewBar;
|
Loading…
x
Reference in New Issue
Block a user