From e75fe11b91166f6a2be39a4e11d9a2881f4b5fa2 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Mon, 8 May 2023 20:02:37 +0200 Subject: [PATCH] feat: add featured video in docs table of content --- apps/docs/layouts/DefaultLayout.tsx | 3 +- apps/docs/layouts/guides/index.tsx | 55 ++++++++++++++++++- .../docs/layouts/tutorials/TutorialLayout.tsx | 8 ++- apps/docs/next.config.mjs | 1 + .../getting-started/tutorials/with-nextjs.mdx | 3 +- 5 files changed, 65 insertions(+), 5 deletions(-) diff --git a/apps/docs/layouts/DefaultLayout.tsx b/apps/docs/layouts/DefaultLayout.tsx index b8338b9d451..4c93336fb87 100644 --- a/apps/docs/layouts/DefaultLayout.tsx +++ b/apps/docs/layouts/DefaultLayout.tsx @@ -12,6 +12,7 @@ interface Props { description?: string hide_table_of_contents?: boolean video?: string + tocVideo?: string canonical?: string } children: any @@ -74,7 +75,7 @@ const Layout: FC = (props: Props) => { 'thin-scrollbar overflow-y-auto sticky hidden md:block md:col-span-3 px-2', ].join(' ')} > - + )} diff --git a/apps/docs/layouts/guides/index.tsx b/apps/docs/layouts/guides/index.tsx index e24008fe864..930d3f8a19d 100644 --- a/apps/docs/layouts/guides/index.tsx +++ b/apps/docs/layouts/guides/index.tsx @@ -1,10 +1,11 @@ import { MDXProvider } from '@mdx-js/react' import { NextSeo } from 'next-seo' import Head from 'next/head' +import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' import { FC, useEffect, useRef, useState } from 'react' -import { IconExternalLink } from 'ui' +import { IconExternalLink, IconPlay, IconPlayCircle } from 'ui' import components from '~/components' import { highlightSelectedTocItem } from '~/components/CustomHTMLElements/CustomHTMLElements.utils' import FooterHelpCallout, { FooterHelpCalloutType } from '~/components/FooterHelpCallout' @@ -20,6 +21,7 @@ interface Props { subtitle?: string footerHelpType?: FooterHelpCalloutType video?: string + tocVideo?: string canonical?: string } children: any @@ -35,9 +37,10 @@ const Layout: FC = (props) => { const [tocList, setTocList] = useState([]) const { asPath } = useRouter() - const router = useRouter() + const [openVideoLightbox, setOpenVideoLightbox] = useState(false) + const EDIT_BUTTON_EXCLUDE_LIST = ['/404'] useEffect(() => { @@ -63,6 +66,7 @@ const Layout: FC = (props) => { }, []) const hasTableOfContents = tocList.length > 0 + const tocVideoPreview = `http://img.youtube.com/vi/${props.meta.tocVideo}/0.jpg` // page type, ie, Auth, Database, Storage etc const ogPageType = asPath.split('/')[2] @@ -103,6 +107,30 @@ const Layout: FC = (props) => { }, }} /> + {openVideoLightbox && ( +
setOpenVideoLightbox(false)} + > +
+
+ +
+