This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed
components/atoms/ExitPreview Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change
1
+ import Link from 'next/link'
2
+
3
+ /**
4
+ * Renders an anchor to exit Preview Mode.
5
+ *
6
+ * @param {object } props The component as props.
7
+ * @param {object } props.preview Checks if a preview exists.
8
+ * @return {Element | null } The ExitPreview component.
9
+ */
10
+ export default function ExitPreview ( { preview} ) {
11
+ if ( preview ) {
12
+ return (
13
+ < p >
14
+ This page is a preview.
15
+ < Link href = "/api/exit-preview" >
16
+ < a > Exit preview mode</ a >
17
+ </ Link >
18
+ </ p >
19
+ )
20
+ }
21
+
22
+ return null
23
+ }
Original file line number Diff line number Diff line change
1
+ export { default } from './ExitPreview.js'
Original file line number Diff line number Diff line change
1
+ import ExitPreview from '@/components/atoms/ExitPreview'
1
2
import WordPressProvider from '@/components/common/WordPressProvider'
2
3
import { useWpApollo } from '@/lib/wordpress/connector'
3
4
import '@/styles/demo.css'
4
5
import '@/styles/index.css'
5
6
import { ApolloProvider } from '@apollo/client'
6
7
import { SessionProvider as NextAuthProvider } from 'next-auth/react'
7
- import Link from 'next/link'
8
8
import PropTypes from 'prop-types'
9
9
import { useState } from 'react'
10
10
import 'tailwindcss/tailwind.css'
@@ -72,15 +72,7 @@ export default function App({Component, pageProps}) {
72
72
< Custom500 errorMessage = { errorMessage } post = { componentProps . post } />
73
73
) : (
74
74
< >
75
- { ! ! preview && (
76
- // TODO -- abstract this to a component.
77
- < p >
78
- This page is a preview.{ ' ' }
79
- < Link href = "/api/exit-preview" >
80
- < a > Exit preview mode</ a >
81
- </ Link >
82
- </ p >
83
- ) }
75
+ < ExitPreview preview = { preview } />
84
76
< Component { ...componentProps } />
85
77
</ >
86
78
) }
You can’t perform that action at this time.
0 commit comments