[bugfix,site][s]: replace YOUTUBE_REGEX
This commit is contained in:
parent
d284ea96ce
commit
3ecdf4cca2
|
|
@ -1,5 +1,5 @@
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { YOUTUBE_REGEX } from "../../lib/constants"
|
import { YOUTUBE_ID_REGEX } from "../../lib/constants"
|
||||||
|
|
||||||
export function Latest({ posts }) {
|
export function Latest({ posts }) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -23,7 +23,7 @@ export function Latest({ posts }) {
|
||||||
<div className="flex-1 bg-slate-800 p-6 flex flex-col justify-between">
|
<div className="flex-1 bg-slate-800 p-6 flex flex-col justify-between">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium text-indigo-600 dark:text-yellow-500">
|
<p className="text-sm font-medium text-indigo-600 dark:text-yellow-500">
|
||||||
{youtube && YOUTUBE_REGEX.test(youtube) ? (
|
{youtube && YOUTUBE_ID_REGEX.test(youtube) ? (
|
||||||
<a target="_blank" rel="noopener" href={youtube} className="hover:underline">
|
<a target="_blank" rel="noopener" href={youtube} className="hover:underline">
|
||||||
Video
|
Video
|
||||||
</a>) : <p>Article</p>}
|
</a>) : <p>Article</p>}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ import MdxContent from "./MdxContent";
|
||||||
import siteConfig from "../config/siteConfig";
|
import siteConfig from "../config/siteConfig";
|
||||||
|
|
||||||
import LiteYouTubeEmbed from "react-lite-youtube-embed";
|
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 }) {
|
export default function MdxPage({ body, meta }) {
|
||||||
const { title, description, date, keywords, youtube, podcast, image, _raw } =
|
const { title, description, date, keywords, youtube, podcast, image, _raw } =
|
||||||
meta;
|
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;
|
const PodcastIcon = siteConfig.social.find((s) => s.name === "Podcast").icon;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 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+)/;
|
export const TWITTER_REGEX = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { allOtherPages } from "contentlayer/generated"
|
import { allOtherPages } from "contentlayer/generated"
|
||||||
import { YOUTUBE_REGEX } from "lib/constants";
|
import { YOUTUBE_ID_REGEX } from "lib/constants";
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const posts = allOtherPages
|
const posts = allOtherPages
|
||||||
|
|
@ -39,7 +39,7 @@ export default function Notes({ posts }) {
|
||||||
<div className="flex-1 bg-slate-800 p-6 flex flex-col justify-between">
|
<div className="flex-1 bg-slate-800 p-6 flex flex-col justify-between">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium text-indigo-600 dark:text-yellow-500">
|
<p className="text-sm font-medium text-indigo-600 dark:text-yellow-500">
|
||||||
{youtube && YOUTUBE_REGEX.test(youtube)
|
{youtube && YOUTUBE_ID_REGEX.test(youtube)
|
||||||
? (<a target="_blank" rel="noopener" href={youtube} className="hover:underline">
|
? (<a target="_blank" rel="noopener" href={youtube} className="hover:underline">
|
||||||
Video
|
Video
|
||||||
</a>)
|
</a>)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue