Can we modify the rendering if displayed into an iframe ? #4674
-
Hi, I used to use vitepress for my documentations but I find it so great that I build complete static website with it now ! I'm developing a SaaS project and I want to display a presentation page directly inside the app for each premium feature. I was wondering if I could integrate the website page inside the app with an iframe if I found a way to remove some part of the page. like <iframe src="/feature-page?mode=iframe" /> and on vitepress if mode=iframe I can remove html blocks like header, footer... and remove js tracking code and chatbot. Does somebody knows how to do that ? Here is an example of a real page : https://www.smartplatform.cloud/fr/fonctionnalites/vue-kanban |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can do something like this: // .vitepress/config.ts
import { defineConfig } from 'vitepress'
export default defineConfig({
head: [
[
'script',
{ id: 'check-iframe' },
`window.self !== window.top && document.documentElement.classList.add('iframe')`
]
]
}) And add this to styles: .iframe header {
display: none !important;
}
/* ... for footer, etc. similarly. override any padding, etc. too if needed */ For chat widget, I'm not sure what your code looks like, but probably you can conditionally initialize that? Or you can hide it from CSS too. BTW very clean site. |
Beta Was this translation helpful? Give feedback.
You can do something like this:
And add this to styles:
For chat widget, I'm not sure what your code looks like, but probably you can conditionally initialize that? Or you can hide it from CSS too.
BTW very clean site.