From 47a454c6cc3db33f46a0e7f6b4b08aa2c08e8842 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Thu, 17 Oct 2024 09:23:46 -0500 Subject: [PATCH] show or hide meta tags --- .../content/carousels/CoursesCarousel.js | 2 +- .../content/carousels/DocumentsCarousel.js | 2 +- .../content/carousels/VideosCarousel.js | 2 +- .../carousels/templates/CourseTemplate.js | 17 +++++++++++++---- .../carousels/templates/DocumentTemplate.js | 19 ++++++++++++++----- .../carousels/templates/VideoTemplate.js | 19 ++++++++++++++----- 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/components/content/carousels/CoursesCarousel.js b/src/components/content/carousels/CoursesCarousel.js index f7b09ce..093003d 100644 --- a/src/components/content/carousels/CoursesCarousel.js +++ b/src/components/content/carousels/CoursesCarousel.js @@ -73,7 +73,7 @@ export default function CoursesCarousel() { itemTemplate={(item) => !processedCourses.length ? : - + } responsiveOptions={responsiveOptions} /> diff --git a/src/components/content/carousels/DocumentsCarousel.js b/src/components/content/carousels/DocumentsCarousel.js index 8484432..ab61366 100644 --- a/src/components/content/carousels/DocumentsCarousel.js +++ b/src/components/content/carousels/DocumentsCarousel.js @@ -94,7 +94,7 @@ export default function DocumentsCarousel() { }} itemTemplate={(item) => processedDocuments.length > 0 ? - : + : } responsiveOptions={responsiveOptions} /> diff --git a/src/components/content/carousels/VideosCarousel.js b/src/components/content/carousels/VideosCarousel.js index bc954aa..08eb156 100644 --- a/src/components/content/carousels/VideosCarousel.js +++ b/src/components/content/carousels/VideosCarousel.js @@ -92,7 +92,7 @@ export default function VideosCarousel() { itemTemplate={(item) => !processedVideos.length ? : - + } responsiveOptions={responsiveOptions} /> diff --git a/src/components/content/carousels/templates/CourseTemplate.js b/src/components/content/carousels/templates/CourseTemplate.js index 13612c0..7984766 100644 --- a/src/components/content/carousels/templates/CourseTemplate.js +++ b/src/components/content/carousels/templates/CourseTemplate.js @@ -15,7 +15,7 @@ import useWindowWidth from "@/hooks/useWindowWidth"; import GenericButton from "@/components/buttons/GenericButton"; import appConfig from "@/config/appConfig"; -export function CourseTemplate({ course }) { +export function CourseTemplate({ course, showMetaTags = true }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: course }); const [zapAmount, setZapAmount] = useState(0); const [lessonCount, setLessonCount] = useState(0); @@ -53,6 +53,13 @@ export function CourseTemplate({ course }) { } }, [course]); + const shouldShowMetaTags = (topic) => { + if (!showMetaTags) { + return !["lesson", "document", "video", "course"].includes(topic); + } + return true; + } + if (!nAddress) return
if (zapsError) return
Error: {zapsError}
; @@ -87,9 +94,11 @@ export function CourseTemplate({ course }) {
{course && course.topics && course.topics.map((topic, index) => ( - - {topic} - + shouldShowMetaTags(topic) && ( + + {topic} + + ) ))}
diff --git a/src/components/content/carousels/templates/DocumentTemplate.js b/src/components/content/carousels/templates/DocumentTemplate.js index e9a9bd1..a13672e 100644 --- a/src/components/content/carousels/templates/DocumentTemplate.js +++ b/src/components/content/carousels/templates/DocumentTemplate.js @@ -14,7 +14,7 @@ import useWindowWidth from "@/hooks/useWindowWidth"; import GenericButton from "@/components/buttons/GenericButton"; import appConfig from "@/config/appConfig"; -export function DocumentTemplate({ document, isLesson }) { +export function DocumentTemplate({ document, isLesson, showMetaTags }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: document }); const [nAddress, setNAddress] = useState(null); const [zapAmount, setZapAmount] = useState(0); @@ -42,6 +42,13 @@ export function DocumentTemplate({ document, isLesson }) { } }, [zaps, document]); + const shouldShowMetaTags = (topic) => { + if (!showMetaTags) { + return !["lesson", "document", "video", "course"].includes(topic); + } + return true; + } + if (zapsError) return
Error: {zapsError}
; return ( @@ -74,11 +81,13 @@ export function DocumentTemplate({ document, isLesson }) {
{document?.topics?.map((topic, index) => ( - - {topic} - + shouldShowMetaTags(topic) && ( + + {topic} + + ) ))} - {isLesson && } + {isLesson && showMetaTags && }

{document?.readTime || "5 min"} read

diff --git a/src/components/content/carousels/templates/VideoTemplate.js b/src/components/content/carousels/templates/VideoTemplate.js index 571b944..af57677 100644 --- a/src/components/content/carousels/templates/VideoTemplate.js +++ b/src/components/content/carousels/templates/VideoTemplate.js @@ -15,7 +15,7 @@ import useWindowWidth from "@/hooks/useWindowWidth"; import GenericButton from "@/components/buttons/GenericButton"; import appConfig from "@/config/appConfig"; -export function VideoTemplate({ video, isLesson }) { +export function VideoTemplate({ video, isLesson, showMetaTags }) { const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: video }); const [nAddress, setNAddress] = useState(null); const [zapAmount, setZapAmount] = useState(0); @@ -43,6 +43,13 @@ export function VideoTemplate({ video, isLesson }) { } }, [zaps, video]); + const shouldShowMetaTags = (topic) => { + if (!showMetaTags) { + return !["lesson", "document", "video", "course"].includes(topic); + } + return true; + } + if (zapsError) return
Error: {zapsError}
; return ( @@ -75,11 +82,13 @@ export function VideoTemplate({ video, isLesson }) {
{video?.topics?.map((topic, index) => ( - - {topic} - + shouldShowMetaTags(topic) && ( + + {topic} + + ) ))} - {isLesson && } + {isLesson && showMetaTags && }

{video?.duration || "5 min"} watch