Skip to content

Commit

Permalink
add a temporary basepath of /mock to app-root (#6292)
Browse files Browse the repository at this point in the history
  • Loading branch information
goplayoutside3 authored Sep 12, 2024
1 parent 439aac3 commit 49633d6
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 84 deletions.
1 change: 1 addition & 0 deletions packages/app-root/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const bundleAnalyzer = withBundleAnalyzer({
})

const nextConfig = {
basePath: '/mock',
experimental: {
optimizePackageImports: [
'@zooniverse/react-components',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
Expand Down
25 changes: 0 additions & 25 deletions packages/app-root/src/app/mock/page.js

This file was deleted.

134 changes: 81 additions & 53 deletions packages/app-root/src/app/page.js
Original file line number Diff line number Diff line change
@@ -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 <p></p>
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 (
<HomePageContainer
dailyZooPosts={dailyZooPosts}
zooBlogPosts={zooBlogPosts}
/>
<>
<AboutHeader links={links} navTitle='Mock' />
<p>This is /mock</p>
</>
)
}

/* 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 <p></p>
// 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 (
// <HomePageContainer
// dailyZooPosts={dailyZooPosts}
// zooBlogPosts={zooBlogPosts}
// />
// )
// }
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
Expand Down

0 comments on commit 49633d6

Please sign in to comment.