Skip to content

Commit

Permalink
add Iframe component to embed codepen
Browse files Browse the repository at this point in the history
  • Loading branch information
antlossway committed Jan 4, 2024
1 parent 94639d7 commit 42db758
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const nextConfig = {
},
],
},

async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Content-Security-Policy",
value: "frame-ancestors https://codepen.io",
},
],
},
]
},
}

module.exports = nextConfig
1 change: 1 addition & 0 deletions src/app/blog/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PostListItem from "@/components/PostListItem"
import paginate from "@/lib/paginate"
import Pagination from "@/components/Pagination"
import GradientBlog from "@/components/(decoration)/GradientBlog"
import Iframe from "@/components/Iframe"

export const revalidate = parseInt(process.env.REVALIDATE_INTERVAL)

Expand Down
17 changes: 17 additions & 0 deletions src/components/Iframe.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react"

const Iframe = ({ title, src, otherClass = "w-full h-[500px]", children }) => {
return (
<iframe
className={otherClass}
title={title}
src={src}
loading="lazy"
allowFullScreen={true}
>
{children}
</iframe>
)
}

export default Iframe
3 changes: 3 additions & 0 deletions src/lib/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Video from "@/components/Video"
import Button from "@/components/Button"
import LinkToNewTab from "@/components/LinkToNewTab"
import HeightTransition from "@/components/(demo)/HeightTransition"
import Iframe from "@/components/Iframe"

import { s } from "hastscript"

export async function getPostByName(fileName) {
Expand Down Expand Up @@ -33,6 +35,7 @@ export async function getPostByName(fileName) {
Button,
LinkToNewTab,
HeightTransition,
Iframe,
},
options: {
parseFrontmatter: true,
Expand Down

1 comment on commit 42db758

@vercel
Copy link

@vercel vercel bot commented on 42db758 Jan 4, 2024

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:

mysite-nextjs-remote-mdx – ./

mysite-nextjs-remote-mdx-antlossway.vercel.app
mysite-nextjs-remote-mdx-git-main-antlossway.vercel.app
quinn.unices.org

Please sign in to comment.