diff --git a/site/components/Home/Latest.js b/site/components/Home/Latest.js index 73c9403..d47f2c9 100644 --- a/site/components/Home/Latest.js +++ b/site/components/Home/Latest.js @@ -1,5 +1,5 @@ import Link from "next/link" -import { YOUTUBE_REGEX } from "../../lib/constants" +import { YOUTUBE_ID_REGEX } from "../../lib/constants" export function Latest({ posts }) { return ( @@ -23,7 +23,7 @@ export function Latest({ posts }) {

- {youtube && YOUTUBE_REGEX.test(youtube) ? ( + {youtube && YOUTUBE_ID_REGEX.test(youtube) ? ( Video ) :

Article

} diff --git a/site/components/MDX.js b/site/components/MDX.js index b9f6763..9362a3d 100644 --- a/site/components/MDX.js +++ b/site/components/MDX.js @@ -3,13 +3,13 @@ import MdxContent from "./MdxContent"; import siteConfig from "../config/siteConfig"; import LiteYouTubeEmbed from "react-lite-youtube-embed"; -import { YOUTUBE_REGEX, YOUTUBE_ID_REGEX } from "lib/constants"; +import { YOUTUBE_ID_REGEX } from "lib/constants"; export default function MdxPage({ body, meta }) { const { title, description, date, keywords, youtube, podcast, image, _raw } = meta; - const youtubeId = youtube && YOUTUBE_REGEX.test(youtube) && youtube.match(YOUTUBE_ID_REGEX)[1] + const youtubeId = youtube && YOUTUBE_ID_REGEX.test(youtube) && youtube.match(YOUTUBE_ID_REGEX)[1] const PodcastIcon = siteConfig.social.find((s) => s.name === "Podcast").icon; diff --git a/site/lib/constants.js b/site/lib/constants.js index 5b6e54c..0b11839 100644 --- a/site/lib/constants.js +++ b/site/lib/constants.js @@ -1,4 +1,3 @@ -export const YOUTUBE_REGEX = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; export const YOUTUBE_ID_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:\S*&)?vi?=|(?:embed|v|vi|user|shorts)\/))([^?&\"'>\s]+)/ export const TWITTER_REGEX = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/; diff --git a/site/pages/notes.js b/site/pages/notes.js index 4bc7dde..7472e48 100644 --- a/site/pages/notes.js +++ b/site/pages/notes.js @@ -1,6 +1,6 @@ import Link from "next/link"; import { allOtherPages } from "contentlayer/generated" -import { YOUTUBE_REGEX } from "lib/constants"; +import { YOUTUBE_ID_REGEX } from "lib/constants"; export async function getStaticProps() { const posts = allOtherPages @@ -30,37 +30,37 @@ export default function Notes({ posts }) {

- {posts && posts.map(({ title, description, image, youtube, link }) => ( - title && description && - (
-
- {image && {title}} -
-
-
-

- {youtube && YOUTUBE_REGEX.test(youtube) - ? ( - Video - ) - :

Article

- } -

- - -

{title}

-

- {description && description.length > 150 - ? `${description.slice(0, image ? 120 : 200)} ...` - : description - } -

-
- -
-
-
) - ))} + {posts && posts.map(({ title, description, image, youtube, link }) => ( + title && description && + (
+
+ {image && {title}} +
+
+
+

+ {youtube && YOUTUBE_ID_REGEX.test(youtube) + ? ( + Video + ) + :

Article

+ } +

+ + +

{title}

+

+ {description && description.length > 150 + ? `${description.slice(0, image ? 120 : 200)} ...` + : description + } +

+
+ +
+
+
) + ))}