feat(viewer): ✨ Custom head code
This commit is contained in:
@ -3,9 +3,11 @@ import { Answer, PublicTypebot, VariableWithValue } from 'models'
|
||||
import { useRouter } from 'next/router'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { upsertAnswer } from 'services/answer'
|
||||
import { isDefined } from 'utils'
|
||||
import { SEO } from '../components/Seo'
|
||||
import { createResult, updateResult } from '../services/result'
|
||||
import { ErrorPage } from './ErrorPage'
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
|
||||
export type TypebotPageProps = {
|
||||
typebot?: PublicTypebot
|
||||
@ -39,6 +41,13 @@ export const TypebotPage = ({
|
||||
})
|
||||
setPredefinedVariables(predefinedVariables)
|
||||
initializeResult().then()
|
||||
const { customHeadCode } = typebot.settings.metadata
|
||||
if (isDefined(customHeadCode) && customHeadCode !== '')
|
||||
document.head.innerHTML =
|
||||
document.head.innerHTML +
|
||||
sanitizeHtml(customHeadCode ?? '', {
|
||||
allowedTags: ['script', 'meta'],
|
||||
})
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
|
@ -23,9 +23,10 @@
|
||||
"next": "^12.1.4",
|
||||
"nodemailer": "^6.7.3",
|
||||
"qs": "^6.10.3",
|
||||
"utils": "*",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"react-dom": "^17.0.2",
|
||||
"sanitize-html": "^2.7.0",
|
||||
"utils": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.20.2",
|
||||
@ -35,6 +36,7 @@
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/qs": "^6.9.7",
|
||||
"@types/react": "^17.0.43",
|
||||
"@types/sanitize-html": "^2.6.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
||||
"eslint": "<8.0.0",
|
||||
"eslint-config-next": "12.1.4",
|
||||
|
Reference in New Issue
Block a user