Skip to content

Commit

Permalink
fix(viewer): 💚 Attempt to fix LP rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 10, 2022
1 parent 92515ef commit 19f4fdb
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 73 deletions.
10 changes: 5 additions & 5 deletions apps/builder/components/share/EditableUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const EditableUrl = ({
onSubmit={onPublicIdChange}
>
<HStack spacing={1}>
<Text>https://</Text>
<Text>{process.env.NEXT_PUBLIC_VIEWER_HOST}/</Text>
<Tooltip label="Edit">
<EditablePreview
mx={1}
Expand All @@ -43,15 +43,15 @@ export const EditableUrl = ({
fontWeight="semibold"
/>
</Tooltip>

<EditableInput px={2} />

<Text>.typebot.io/</Text>
</HStack>

<HStack>
<EditButton size="xs" />
<CopyButton size="xs" textToCopy={`https://${publicId}.typebot.io/`} />
<CopyButton
size="xs"
textToCopy={`${process.env.NEXT_PUBLIC_VIEWER_HOST}/${publicId}`}
/>
</HStack>
</Editable>
)
Expand Down
8 changes: 6 additions & 2 deletions apps/builder/services/publicTypebot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
PublicBlock,
PublicStep,
PublicTypebot,
Step,
Typebot,
} from 'models'
import shortId from 'short-uuid'
Expand All @@ -17,10 +16,15 @@ import { isDefined } from '@udecode/plate-common'
export const parseTypebotToPublicTypebot = (
typebot: Typebot
): PublicTypebot => ({
...typebot,
id: shortId.generate(),
typebotId: typebot.id,
blocks: parseBlocksToPublicBlocks(typebot.blocks),
edges: typebot.edges,
name: typebot.name,
publicId: typebot.publicId,
settings: typebot.settings,
theme: typebot.theme,
variables: typebot.variables,
})

const parseBlocksToPublicBlocks = (blocks: Block[]): PublicBlock[] =>
Expand Down
4 changes: 4 additions & 0 deletions apps/landing-page/.env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NOTION_API_TOKEN=
NOTION_DATABASE_ID=
NEXT_PUBLIC_VIEWER_HOST=http://localhost:3001
LANDING_PAGE_HOST=http://localhost:3002
42 changes: 36 additions & 6 deletions apps/landing-page/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ const securityHeaders = [
},
]

const pages = [
'blog',
'pricing',
'privacy-policies',
'terms-of-service',
'vs-landbot',
'vs-tally',
'vs-typeform',
]

module.exports = withBundleAnalyzer({
async headers() {
return [
Expand All @@ -30,11 +40,31 @@ module.exports = withBundleAnalyzer({
]
},
async rewrites() {
return [
{
source: '/:path*',
destination: `${process.env.NEXT_PUBLIC_VIEWER_HOST}/:path*`,
},
]
return {
beforeFiles: [
{
source: '/_next/static/:static*',
destination:
process.env.NEXT_PUBLIC_VIEWER_HOST + '/_next/static/:static*',
has: [
{
type: 'header',
key: 'referer',
value:
process.env.LANDING_PAGE_HOST +
'/(?!' +
pages.join('|') +
'|\\?).+',
},
],
},
],
fallback: [
{
source: '/:user*',
destination: process.env.NEXT_PUBLIC_VIEWER_HOST + '/:user*',
},
],
}
},
})
7 changes: 4 additions & 3 deletions apps/landing-page/pages/vs-landbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import {
} from '@chakra-ui/react'
import loadLandbot from '../lib/landbot'
import Image from 'next/image'
import Typebot from 'typebot-js'
import { initContainer } from 'typebot-js'
import { ArticleCallToAction } from 'components/common/ArticleCta'
import { Footer } from 'components/common/Footer'
import { Navbar } from 'components/common/Navbar/Navbar'
import { NextChakraLink } from 'components/common/nextChakraAdapters/NextChakraLink'
import { SocialMetaTags } from 'components/common/SocialMetaTags'
import { Yes, No } from 'components/common/TableCells'
import landbotVisualFlowSrc from 'public/images/landbot/visual-flow.png'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const Landbot: any
Expand All @@ -35,7 +36,7 @@ const VsTypebot = () => {
'https://chats.landbot.io/v3/H-937813-ZLZEY720UH1TWN5S/index.json',
})
})
Typebot.initContainer('typebot-container', {
initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
Expand Down Expand Up @@ -91,7 +92,7 @@ const VsTypebot = () => {
</Text>
<Box h="400px" pos="relative">
<Image
src="landbotVisualFlowSrc"
src={landbotVisualFlowSrc}
layout="fill"
objectFit="contain"
alt="Visual flow screenshot"
Expand Down
4 changes: 2 additions & 2 deletions apps/landing-page/pages/vs-tally.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Th,
Flex,
} from '@chakra-ui/react'
import Typebot from 'typebot-js'
import { initContainer } from 'typebot-js'
import { ArticleCallToAction } from 'components/common/ArticleCta'
import { roadmapLink, Footer } from 'components/common/Footer'
import { Navbar } from 'components/common/Navbar/Navbar'
Expand All @@ -22,7 +22,7 @@ import { Yes, No } from 'components/common/TableCells'

const VsTypebot = () => {
useEffect(() => {
Typebot.initContainer('typebot-container', {
initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
Expand Down
4 changes: 2 additions & 2 deletions apps/landing-page/pages/vs-typeform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Th,
Flex,
} from '@chakra-ui/react'
import Typebot from 'typebot-js'
import { initContainer } from 'typebot-js'
import { CheckIcon } from 'assets/icons/CheckIcon'
import { CloseIcon } from 'assets/icons/CloseIcon'
import { ArticleCallToAction } from 'components/common/ArticleCta'
Expand All @@ -25,7 +25,7 @@ import loadTypeform from 'lib/typeform'
const VsTypebot = () => {
useEffect(() => {
loadTypeform().then()
Typebot.initContainer('typebot-container', {
initContainer('typebot-container', {
publishId: 'example-vs-other-tools',
})
}, [])
Expand Down
8 changes: 4 additions & 4 deletions apps/viewer/pages/[publicId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import prisma from '../libs/prisma'
export const getServerSideProps: GetServerSideProps = async (
context: GetServerSidePropsContext
) => {
let typebot: PublicTypebot | undefined
let typebot: PublicTypebot | null
const isIE = /MSIE|Trident/.test(context.req.headers['user-agent'] ?? '')
const pathname = context.resolvedUrl.split('?')[0]
try {
Expand All @@ -33,12 +33,12 @@ export const getServerSideProps: GetServerSideProps = async (

const getTypebotFromPublicId = async (
publicId?: string
): Promise<PublicTypebot | undefined> => {
if (!publicId) return
): Promise<PublicTypebot | null> => {
if (!publicId) return null
const typebot = await prisma.publicTypebot.findUnique({
where: { publicId },
})
return (typebot as unknown as PublicTypebot | undefined) ?? undefined
return (typebot as unknown as PublicTypebot) ?? null
}

const App = ({ typebot, ...props }: TypebotPageProps) =>
Expand Down
47 changes: 0 additions & 47 deletions apps/viewer/pages/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"dotenv-cli": "^4.1.1",
"turbo": "^1.1.1"
"turbo": "^1.1.2"
},
"packageManager": "yarn@1.22.17"
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8073,7 +8073,7 @@ turbo-windows-64@1.1.2:
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.1.2.tgz#8eb3f77ab7e04b077752ae2204114c82e5c74697"
integrity sha512-0Ncx/iKhnKrdAU8hJ+8NUcF9jtFr8KoW5mMWfiFzy+mgUbVKbpzWT2eoGR6zJExedQsRvYOejbEX5iihbnj5bA==

turbo@^1.1.1:
turbo@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.1.2.tgz#751b9651dc3ebe469898db76afab6405666ad0ff"
integrity sha512-3ViHKyAkaBKNKwHASTa1zkVT3tVVhQNLrpxBS7LoN+794ouQUYmy6lf0rTqzG3iTZHtIDwC+piZSdTl4XjEVMg==
Expand Down

3 comments on commit 19f4fdb

@vercel
Copy link

@vercel vercel bot commented on 19f4fdb Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landing-page-v2 – ./apps/landing-page

landing-page-v2-git-main-typebot-io.vercel.app
landing-page-v2-typebot-io.vercel.app
landing-page-v2-jade.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 19f4fdb Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

viewer-v2-git-main-typebot-io.vercel.app
typebot-viewer.vercel.app
viewer-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 19f4fdb Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

next.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

Please sign in to comment.