From b094a03c44b86b95dab2a1028cc1a902348e4957 Mon Sep 17 00:00:00 2001 From: Zachary Proser Date: Thu, 29 Aug 2024 07:06:59 -0400 Subject: [PATCH 1/2] Add more posts to homepage --- src/app/HomepageClientComponent.tsx | 17 ++++++++++++++--- src/app/page.tsx | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/app/HomepageClientComponent.tsx b/src/app/HomepageClientComponent.tsx index 318e828a..bbe0336a 100644 --- a/src/app/HomepageClientComponent.tsx +++ b/src/app/HomepageClientComponent.tsx @@ -140,6 +140,7 @@ export default function HomepageClientComponent({ mlProjects, aiDev, refArchitectures, + careerAdvice, isMobile }: HomepageClientComponentProps) { const [email, setEmail] = useState("") @@ -230,7 +231,7 @@ export default function HomepageClientComponent({
-

Machine Learning Projects

+

Open-source AI / ML / Pipelines Projects

{mlProjects.slice(0, 3).map((article) => ( @@ -241,7 +242,7 @@ export default function HomepageClientComponent({
-

AI Assisted Development

+

AI-assisted Development

{aiDev.slice(0, 3).map((article) => ( @@ -251,6 +252,17 @@ export default function HomepageClientComponent({
+
+

Career Advice

+
+ {careerAdvice.slice(0, 3).map((article) => ( + + ))} +
+
+
+ +

Reference Architectures and Demos

@@ -262,7 +274,6 @@ export default function HomepageClientComponent({
- {/* ... footer content ... */}
) diff --git a/src/app/page.tsx b/src/app/page.tsx index 020b0132..5387922e 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -18,16 +18,23 @@ export default async function Page() { const aiDevSlugs = [ 'automations-project', - 'how-are-embeddings-models-trained-for-rag', - 'codeium-review' + 'autocomplete-is-not-all-you-need', + 'codeium-analysis-4-2024' ] const refArchitectureSlugs = [ 'pinecone-reference-architecture-launch', - 'pinecone-reference-architecture-scaling' + 'pinecone-reference-architecture-scaling', + 'pinecone-reference-architecture-technical-walkthrough' ] - const allSlugs = [...mlProjectSlugs, ...aiDevSlugs, ...refArchitectureSlugs] + const careerAdviceSlugs = [ + 'run-your-own-tech-blog', + 'wash-three-walls-with-one-bucket', + 'you-get-to-keep-the-neural-connections' + ] + + const allSlugs = [...mlProjectSlugs, ...aiDevSlugs, ...refArchitectureSlugs, ...careerAdviceSlugs] try { // Fetch all articles matching the slugs @@ -42,6 +49,9 @@ export default async function Page() { article.type === 'demo' || article.type === 'architecture' ) + + const careerAdvice = allArticles.filter(article => careerAdviceSlugs.includes(article.slug)) + // Server-side mobile detection const userAgent = headers().get('user-agent') || '' const parser = new UAParser(userAgent) @@ -53,6 +63,7 @@ export default async function Page() { mlProjects={mlProjects} aiDev={aiDev} refArchitectures={refArchitectures} + careerAdvice={careerAdvice} isMobile={isMobile} /> ) From c8726d25686ca0ad2b9299a20b22acfb5015284f Mon Sep 17 00:00:00 2001 From: Zachary Proser Date: Thu, 29 Aug 2024 07:12:28 -0400 Subject: [PATCH 2/2] Add videos to homepage --- src/app/HomepageClientComponent.tsx | 18 ++++++++++++++++-- src/app/page.tsx | 11 +++++++++++ src/lib/videos.ts | 12 +++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/app/HomepageClientComponent.tsx b/src/app/HomepageClientComponent.tsx index bbe0336a..7dcb94ed 100644 --- a/src/app/HomepageClientComponent.tsx +++ b/src/app/HomepageClientComponent.tsx @@ -133,6 +133,8 @@ interface HomepageClientComponentProps { mlProjects: Article[]; aiDev: Article[]; refArchitectures: Article[]; + careerAdvice: Article[]; + videos: Article[]; isMobile: boolean; } @@ -141,6 +143,7 @@ export default function HomepageClientComponent({ aiDev, refArchitectures, careerAdvice, + videos, isMobile }: HomepageClientComponentProps) { const [email, setEmail] = useState("") @@ -251,7 +254,7 @@ export default function HomepageClientComponent({
-
+

Career Advice

@@ -262,7 +265,18 @@ export default function HomepageClientComponent({
-
+
+
+

Videos

+
+ {videos.slice(0, 3).map((article) => ( + + ))} +
+
+
+ +

Reference Architectures and Demos

diff --git a/src/app/page.tsx b/src/app/page.tsx index 5387922e..2a6d8854 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,5 @@ import { getAllArticles } from "@/lib/articles" +import { getAllVideos } from "@/lib/videos" // Import the new function import HomepageClientComponent from './HomepageClientComponent' import { headers } from 'next/headers' import { UAParser } from 'ua-parser-js' @@ -34,11 +35,18 @@ export default async function Page() { 'you-get-to-keep-the-neural-connections' ] + const videoSlugs = [ + 'how-to-build-chat-with-your-data-rag', + 'how-to-use-chatgpt-in-your-terminal', + 'what-is-a-vector-database' + ] + const allSlugs = [...mlProjectSlugs, ...aiDevSlugs, ...refArchitectureSlugs, ...careerAdviceSlugs] try { // Fetch all articles matching the slugs const allArticles = await getAllArticles(allSlugs) + const allVideos = await getAllVideos(videoSlugs) // Fetch all videos with matching slugs const mlProjects = allArticles.filter(article => mlProjectSlugs.includes(article.slug)) @@ -52,6 +60,8 @@ export default async function Page() { const careerAdvice = allArticles.filter(article => careerAdviceSlugs.includes(article.slug)) + const videos = allVideos.filter(video => videoSlugs.includes(video.slug)) // Filter videos + // Server-side mobile detection const userAgent = headers().get('user-agent') || '' const parser = new UAParser(userAgent) @@ -64,6 +74,7 @@ export default async function Page() { aiDev={aiDev} refArchitectures={refArchitectures} careerAdvice={careerAdvice} + videos={videos} // Added new prop isMobile={isMobile} /> ) diff --git a/src/lib/videos.ts b/src/lib/videos.ts index 0a6b4cb8..c10cea06 100644 --- a/src/lib/videos.ts +++ b/src/lib/videos.ts @@ -1,6 +1,6 @@ import { Article, ArticleWithSlug } from './shared-types' - import glob from 'fast-glob' +import path from 'path' async function importArticle( articleFilename: string, @@ -17,12 +17,18 @@ async function importArticle( } } -export async function getAllVideos() { +// Extend getAllVideos to accept an optional array of slugs +export async function getAllVideos(matchingSlugs?: string[]) { let articleFilenames = await glob('*/page.mdx', { - cwd: './src/app/videos', + cwd: path.join(process.cwd(), 'src', 'app', 'videos'), }) let articles = await Promise.all(articleFilenames.map(importArticle)) + // Filter articles to include only those whose slug is in matchingSlugs + if (matchingSlugs && matchingSlugs.length > 0) { + articles = articles.filter(article => matchingSlugs.includes(article.slug)) + } + return articles.sort((a, z) => +new Date(z.date) - +new Date(a.date)) }