Skip to content

Commit

Permalink
app-root: Undo bathPath and /mock routes from testing with FrontDoor (#…
Browse files Browse the repository at this point in the history
…6296)

* start to undo basePath stuff

* revert change to AboutHeader

* revert middleware file
  • Loading branch information
goplayoutside3 authored Sep 12, 2024
1 parent daac050 commit c010bf0
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 159 deletions.
6 changes: 3 additions & 3 deletions kubernetes/deployment-production.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,17 @@ spec:
cpu: "1000m"
startupProbe:
httpGet:
path: /mock
path: /users
port: 3000
failureThreshold: 6
livenessProbe:
httpGet:
path: /mock
path: /users
port: 3000
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /mock
path: /users
port: 3000
initialDelaySeconds: 20
timeoutSeconds: 10
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/deployment-staging.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,17 @@ spec:
cpu: "1000m"
startupProbe:
httpGet:
path: /mock
path: /users
port: 3000
failureThreshold: 6
livenessProbe:
httpGet:
path: /mock
path: /users
port: 3000
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /mock
path: /users
port: 3000
initialDelaySeconds: 20
timeoutSeconds: 10
Expand Down
1 change: 0 additions & 1 deletion packages/app-root/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const bundleAnalyzer = withBundleAnalyzer({
})

const nextConfig = {
basePath: '/mock',
experimental: {
optimizePackageImports: [
'@zooniverse/react-components',
Expand Down
25 changes: 0 additions & 25 deletions packages/app-root/src/app/faq/page.js

This file was deleted.

134 changes: 53 additions & 81 deletions packages/app-root/src/app/page.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,59 @@
import { AboutHeader } from '@zooniverse/content'
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
}
}

export default function MockPage() {
const links = [
{
href: '/',
label: 'Mock'
},
{
href: '/resources',
label: 'Resources'
},
{
href: '/faq',
label: 'FAQ'
async function fetchBlogFeed(url) {
try {
const response = await fetch(url)
if (response.ok) {
const feed = await response.json()
return feed.posts
}
]

return (
<>
<AboutHeader links={links} navTitle='Mock' />
<p>This is /mock</p>
</>
)
return []
} catch (error) {
console.error(error)
return []
}
}

/* 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
// }
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)
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}
// />
// )
// }
return (
<HomePageContainer
dailyZooPosts={dailyZooPosts}
zooBlogPosts={zooBlogPosts}
/>
)
}
25 changes: 0 additions & 25 deletions packages/app-root/src/app/resources/page.js

This file was deleted.

19 changes: 1 addition & 18 deletions packages/app-root/src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@
import { NextResponse } from 'next/server'

export function middleware(req) {
/*
Bypass /assets.
*/
if (req.nextUrl.pathname.startsWith('/assets')) {
return NextResponse.next()
}
/*
Bypass internal NextJS requests.
*/
if (req.nextUrl.pathname.startsWith('/_next')) {
return NextResponse.next()
}
/* This is a temporary mocked env */
if (req.nextUrl.pathname.startsWith('/mock/wrong')) {
return NextResponse.redirect(new URL('/mock', req.url))
}

/*
Redirect legacy PFE /about and /get-involved paths to new FEM paths
*/
Expand Down Expand Up @@ -65,5 +48,5 @@ export function middleware(req) {

/* Only care about /about and /get-involved routes */
export const config = {
matcher: ['/mock/:path*', '/about/:path*', '/get-involved/:paths*']
matcher: ['/about/:path*', '/get-involved/:paths*']
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client'

import { Box } from 'grommet'
import { ZooniverseLogotype } from '@zooniverse/react-components'
import styled from 'styled-components'
Expand Down
1 change: 0 additions & 1 deletion packages/lib-content/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { default as About } from './screens/About/About.js'
export { default as AboutHeader } from './components/AboutHeader/AboutHeader.js'
export { default as Collaborate } from './screens/Collaborate/Collaborate.js'
export { default as CommunityContainer } from './screens/Home/Community/CommunityContainer.js'
export { default as Default404 } from './screens/404/Default404.js'
Expand Down

0 comments on commit c010bf0

Please sign in to comment.