-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a temporary basepath of /mock to app-root (#6292)
- Loading branch information
1 parent
439aac3
commit 49633d6
Showing
5 changed files
with
88 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
// /> | ||
// ) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters