From 49633d6a0dab070e6d0de9f3ac532e06e1df46af Mon Sep 17 00:00:00 2001
From: "Delilah C." <23665803+goplayoutside3@users.noreply.github.com>
Date: Thu, 12 Sep 2024 14:18:20 -0500
Subject: [PATCH] add a temporary basepath of /mock to app-root (#6292)
---
packages/app-root/next.config.mjs | 1 +
.../app-root/src/app/{mock => }/faq/page.js | 6 +-
packages/app-root/src/app/mock/page.js | 25 ----
packages/app-root/src/app/page.js | 134 +++++++++++-------
.../src/app/{mock => }/resources/page.js | 6 +-
5 files changed, 88 insertions(+), 84 deletions(-)
rename packages/app-root/src/app/{mock => }/faq/page.js (80%)
delete mode 100644 packages/app-root/src/app/mock/page.js
rename packages/app-root/src/app/{mock => }/resources/page.js (81%)
diff --git a/packages/app-root/next.config.mjs b/packages/app-root/next.config.mjs
index 948ee0e76c..d814502e60 100644
--- a/packages/app-root/next.config.mjs
+++ b/packages/app-root/next.config.mjs
@@ -5,6 +5,7 @@ const bundleAnalyzer = withBundleAnalyzer({
})
const nextConfig = {
+ basePath: '/mock',
experimental: {
optimizePackageImports: [
'@zooniverse/react-components',
diff --git a/packages/app-root/src/app/mock/faq/page.js b/packages/app-root/src/app/faq/page.js
similarity index 80%
rename from packages/app-root/src/app/mock/faq/page.js
rename to packages/app-root/src/app/faq/page.js
index d84b4c24b1..5e3d7dfb1d 100644
--- a/packages/app-root/src/app/mock/faq/page.js
+++ b/packages/app-root/src/app/faq/page.js
@@ -3,15 +3,15 @@ import { AboutHeader } from '@zooniverse/content'
export default function MockPage() {
const links = [
{
- href: '/mock',
+ href: '/',
label: 'Mock'
},
{
- href: '/mock/resources',
+ href: '/resources',
label: 'Resources'
},
{
- href: '/mock/faq',
+ href: '/faq',
label: 'FAQ'
}
]
diff --git a/packages/app-root/src/app/mock/page.js b/packages/app-root/src/app/mock/page.js
deleted file mode 100644
index 9ffde0d222..0000000000
--- a/packages/app-root/src/app/mock/page.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { AboutHeader } from '@zooniverse/content'
-
-export default function MockPage() {
- const links = [
- {
- href: '/mock',
- label: 'Mock'
- },
- {
- href: '/mock/resources',
- label: 'Resources'
- },
- {
- href: '/mock/faq',
- label: 'FAQ'
- }
- ]
-
- return (
- <>
-
This is /mock
- > - ) -} diff --git a/packages/app-root/src/app/page.js b/packages/app-root/src/app/page.js index 366110524c..e6f147be98 100644 --- a/packages/app-root/src/app/page.js +++ b/packages/app-root/src/app/page.js @@ -1,59 +1,87 @@ -import HomePageContainer from '@/components/HomePageContainer' - -// daily.zooniverse.org most recent 4 posts -const DAILY_ZOO_FEED = - 'https://public-api.wordpress.com/rest/v1.1/sites/57182749/posts?number=4' -// blog.zooniverse.org most recent 4 posts -const ZOO_BLOG_FEED = - 'https://public-api.wordpress.com/rest/v1.1/sites/36711287/posts?number=4' - -/** Grab the data we want from each post */ -function parseFeedPost(post) { - return { - id: post.ID, // number - title: post.title, // string - excerpt: post.excerpt, // string but text is wrapped in - created_at: new Date(post.date), // string such as '2024-02-02T15:00:00+00:00' - url: post.URL, // string - imageSrc: post.featured_image // src string - } -} +import { AboutHeader } from '@zooniverse/content' -async function fetchBlogFeed(url) { - try { - const response = await fetch(url) - if (response.ok) { - const feed = await response.json() - return feed.posts +export default function MockPage() { + const links = [ + { + href: '/', + label: 'Mock' + }, + { + href: '/resources', + label: 'Resources' + }, + { + href: '/faq', + label: 'FAQ' } - return [] - } catch (error) { - console.error(error) - return [] - } -} - -async function getBlogPosts(url) { - let posts = [] - try { - const feed = await fetchBlogFeed(url) - posts = feed.map(post => parseFeedPost(post)) - - return posts - } catch (error) { - console.error(error) - } - return posts -} - -export default async function HomePage() { - const dailyZooPosts = await getBlogPosts(DAILY_ZOO_FEED) - const zooBlogPosts = await getBlogPosts(ZOO_BLOG_FEED) + ] return ( -This is /mock
+ > ) } + +/* Code below is temporary ignored to allow for testing /mock urls with Azure FrontDoor */ + +// import HomePageContainer from '@/components/HomePageContainer' + +// // daily.zooniverse.org most recent 4 posts +// const DAILY_ZOO_FEED = +// 'https://public-api.wordpress.com/rest/v1.1/sites/57182749/posts?number=4' +// // blog.zooniverse.org most recent 4 posts +// const ZOO_BLOG_FEED = +// 'https://public-api.wordpress.com/rest/v1.1/sites/36711287/posts?number=4' + +// /** Grab the data we want from each post */ +// function parseFeedPost(post) { +// return { +// id: post.ID, // number +// title: post.title, // string +// excerpt: post.excerpt, // string but text is wrapped in +// created_at: new Date(post.date), // string such as '2024-02-02T15:00:00+00:00' +// url: post.URL, // string +// imageSrc: post.featured_image // src string +// } +// } + +// async function fetchBlogFeed(url) { +// try { +// const response = await fetch(url) +// if (response.ok) { +// const feed = await response.json() +// return feed.posts +// } +// return [] +// } catch (error) { +// console.error(error) +// return [] +// } +// } + +// async function getBlogPosts(url) { +// let posts = [] +// try { +// const feed = await fetchBlogFeed(url) +// posts = feed.map(post => parseFeedPost(post)) + +// return posts +// } catch (error) { +// console.error(error) +// } +// return posts +// } + +// export default async function HomePage() { +// const dailyZooPosts = await getBlogPosts(DAILY_ZOO_FEED) +// const zooBlogPosts = await getBlogPosts(ZOO_BLOG_FEED) + +// return ( +//