From d7f73dc1fe01f80f5fbded0e4aecb65fb50f2088 Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Tue, 8 Oct 2024 15:04:50 -0700 Subject: [PATCH 1/7] Basic Breaking Layout, Card iteration #1 --- components/ArticleCard/Breaking.jsx | 152 ++++++++++++++++++++++ components/ArticleCard/index.jsx | 4 + layouts/Breaking/index.jsx | 195 ++++++++++++++++++++++++++++ pages/category/breaking.jsx | 110 ++++++++++++++++ 4 files changed, 461 insertions(+) create mode 100644 components/ArticleCard/Breaking.jsx create mode 100644 layouts/Breaking/index.jsx create mode 100644 pages/category/breaking.jsx diff --git a/components/ArticleCard/Breaking.jsx b/components/ArticleCard/Breaking.jsx new file mode 100644 index 0000000..c1f5668 --- /dev/null +++ b/components/ArticleCard/Breaking.jsx @@ -0,0 +1,152 @@ +import * as React from "react"; +import Link from "next/link"; +/** @jsx jsx */ +import { css, jsx } from "@emotion/core"; +import * as globals from "../globals"; +import * as locals from "./locals"; +import * as utilities from "./utilities"; +import * as moment from "moment"; + +export default function Breaking(props) { + return ( +
+
+ +
+ +
+
+

+ {props.photographer} +

+
+
+ + +

+ + + {moment(props.date).format("MMM D, YYYY h:mm a")} + + + +
+
+ +

+ By {utilities.renderAuthors(props.authors)} +

+
+
+ ); +} diff --git a/components/ArticleCard/index.jsx b/components/ArticleCard/index.jsx index 5921b63..22b227e 100644 --- a/components/ArticleCard/index.jsx +++ b/components/ArticleCard/index.jsx @@ -8,6 +8,7 @@ import Full from "./Full"; import Mini from "./Mini"; import Video from "./Video"; import Podcast from "./Podcast"; +import Breaking from "./Breaking"; export default class ArticleCard extends React.Component { constructor(props) { @@ -38,6 +39,9 @@ export default class ArticleCard extends React.Component { case "podcast": card = ; break; + case "breaking": + card = ; + break; default: card = ; } diff --git a/layouts/Breaking/index.jsx b/layouts/Breaking/index.jsx new file mode 100644 index 0000000..554b5ba --- /dev/null +++ b/layouts/Breaking/index.jsx @@ -0,0 +1,195 @@ +import React, { Component } from "react"; +import Error from "next/error"; +import { Config } from "../../config.js"; +import css from "../style.module.css"; +import * as utilities from "../utilities"; +import InfiniteScroll from "react-infinite-scroller"; +import Media from "react-media"; +import LoadingBear from "../../components/LoadingBear"; +import ClassifiedsCard from "../../components/ClassifiedsCard"; + +export default class BreakingLayout extends React.Component { + constructor(props) { + super(props); + this.state = { + otherArticleCards: utilities.buildArticleList(this.props.posts), + more: true + }; + this.getPosts = this.getPosts.bind(this); + } + + getPosts(page) { + fetch( + `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=${this.props.categoryID}&page=${page}` + ) + .then(response => response.json()) + .then( + json => { + if (json.data == undefined && json.length != 0) { + console.log(json.length()) + this.setState({ + otherArticleCards: this.state.otherArticleCards.concat( + utilities.buildArticleList(json) + ) + }); + } else { + this.setState({ + more: false + }); + } + }, + error => { + this.setState({ + more: false + }); + } + ) + .catch(err => + this.setState({ + more: false + }) + ); + } + + render() { + return ( + + {matches => ( + <> + {matches.phone && ( +
+
+ + } + > + {utilities.renderPostArray( + this.state.otherArticleCards, + "full" + )} + + {!this.state.more ? ( +

+ no more articles! +

+ ) : ( + + )} +
+
+ )} + {matches.tablet && ( +
+
+
+ + } + > + {utilities.renderPostArray( + this.state.otherArticleCards, + "horz" + )} + + {!this.state.more ? ( +

+ no more articles! +

+ ) : ( + + )} +
+
+
+ )} + {matches.desktop && ( +
+
+
+ + } + > + {utilities.renderPostArray( + this.state.otherArticleCards, + "breaking" + )} + + {!this.state.more ? ( +

+ End of Breaking Feed! +

+ ) : ( + + )} +
+
+
+ )} + + )} +
+ ); + } +} diff --git a/pages/category/breaking.jsx b/pages/category/breaking.jsx new file mode 100644 index 0000000..ad787c9 --- /dev/null +++ b/pages/category/breaking.jsx @@ -0,0 +1,110 @@ +import PageWrapper from "../../layouts/PageWrapper"; +import React, { Component } from "react"; +import Error from "next/error"; +import { Config } from "../../config.js"; +import Head from "next/head"; + +import SectionHeader from "../../components/SectionHeader"; +import BreakingLayout from "../../layouts/Breaking"; + +const COLUMN_SERIES_FEATURE_FLAG = false; + +const categoryDescriptions = { + quad: { + desktop: + "The Quad is the Daily Bruin's explanatory journalism section, which aims to break down salient topics \ + to make them digestible for UCLA's student body and community at large. Our in-depth reporting incorporates the \ + broader context of these topics to give a more comprehensive view on financial, lifestyle and academic discussions.", + mobile: + "The Quad is an explanatory journalism hub which contextualizes current events for readers, \ + with stories ranging from cultural trends to the interrogation of sociopolitical issues." + } +}; + +class Category extends Component { + static async getInitialProps(context) { + // slug is from url + const categoryRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/categories?slug=breaking` // slug = breaking + ); + const category = await categoryRes.json(); + if (category.length > 0) { + const subcategoriesRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/categories?parent=${category[0].id}&per_page=100` + ); + const subcategories = await subcategoriesRes.json(); + for (let i = 0; i < subcategories.length; i++) { + // const subsubcategoriesRes = await fetch( + // `${Config.apiUrl}/wp-json/wp/v2/categories?parent=${subcategories[i].id}` + // ); + // subcategories[i].subsubcategories = await subsubcategoriesRes.json(); + subcategories[i].subsubcategories = []; + } + + const postsRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=${category[0].id}` + ); + const posts = await postsRes.json(); + + const classifiedsRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/classifieds?_embed&Featured=3` + ); + const classifieds = await classifiedsRes.json(); + return { category, subcategories, posts, classifieds }; + } else { + return { category }; + } + } + render() { + if ( + this.props.category == undefined || + this.props.category.data != undefined || + this.props.category.length == 0 + ) { + return ; + } + for (let i = 0; i < this.props.posts.length; i++) + { + this.props.posts[i].excerpt = this.props.posts[i].content + } + const sectionLinks = this.props.subcategories.map(index => { + const subsubcategoriesSimple = index.subsubcategories.map(index => { + return { name: index.name, link: `/category/${index.slug}` }; + }); + return { + name: index.name, + link: `/category/${index.slug}`, + subsubcategories: subsubcategoriesSimple + }; + }); + return ( + <> + + {this.props.category[0].name + " - Daily Bruin"} + +
+ +
+ { + return { + category: { + name: c._embedded["wp:term"][1][0].name, + url: c._embedded["wp:term"][1][0].link + }, + content: { name: c.content.rendered, url: c.link } + }; + })} + /> + + ); + } +} + +export default PageWrapper(Category); From aae86ad3980606e0082d0e92ab2f61bf1f19017d Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Tue, 8 Oct 2024 18:34:09 -0700 Subject: [PATCH 2/7] Added time since posting metric --- components/ArticleCard/Breaking.jsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/components/ArticleCard/Breaking.jsx b/components/ArticleCard/Breaking.jsx index c1f5668..23f2574 100644 --- a/components/ArticleCard/Breaking.jsx +++ b/components/ArticleCard/Breaking.jsx @@ -8,6 +8,23 @@ import * as utilities from "./utilities"; import * as moment from "moment"; export default function Breaking(props) { + var CurrentTime = new Date(); + var PostTime = new Date(props.date); + var DiffInMinutes = Math.round(((CurrentTime - PostTime) / 1000) / 60); + var DiffInHours = Math.round(DiffInMinutes / 60); + var DiffInDays = Math.round(DiffInHours / 24); + DiffInMinutes %= 60; + DiffInHours %= 24; + var TimeDiff = ""; + + if (DiffInDays != 0) { + TimeDiff += DiffInDays + " Days, " + } + if (DiffInHours != 0) { + TimeDiff += DiffInHours + " Hours, " + } + TimeDiff += DiffInMinutes + " Minutes Ago" + return (
- {moment(props.date).format("MMM D, YYYY h:mm a")} + {TimeDiff} @@ -127,7 +144,7 @@ export default function Breaking(props) {
From 3524af13bbd3c96225be1fb4e9492f1e46bd64ab Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Wed, 9 Oct 2024 15:36:40 -0700 Subject: [PATCH 3/7] Updated breaking feeds to be tied to tags and more twitter-y Feeds have their own header now under "BreakingFeedsHeader" Breaking Cards now prioritize text with an image underneath. --- components/ArticleCard/Breaking.jsx | 172 ++++++++++----------- components/BreakingFeedsHeader/index.jsx | 121 +++++++++++++++ components/SectionHeader/index.jsx | 6 +- layouts/Breaking/index.jsx | 4 +- pages/category/breaking/[slug].jsx | 59 +++++++ pages/category/{ => breaking}/breaking.jsx | 8 +- 6 files changed, 272 insertions(+), 98 deletions(-) create mode 100644 components/BreakingFeedsHeader/index.jsx create mode 100644 pages/category/breaking/[slug].jsx rename pages/category/{ => breaking}/breaking.jsx (94%) diff --git a/components/ArticleCard/Breaking.jsx b/components/ArticleCard/Breaking.jsx index 23f2574..353feee 100644 --- a/components/ArticleCard/Breaking.jsx +++ b/components/ArticleCard/Breaking.jsx @@ -10,114 +10,76 @@ import * as moment from "moment"; export default function Breaking(props) { var CurrentTime = new Date(); var PostTime = new Date(props.date); - var DiffInMinutes = Math.round(((CurrentTime - PostTime) / 1000) / 60); - var DiffInHours = Math.round(DiffInMinutes / 60); - var DiffInDays = Math.round(DiffInHours / 24); - DiffInMinutes %= 60; - DiffInHours %= 24; - var TimeDiff = ""; + var DiffInMilliseconds = CurrentTime - PostTime; + var TotalMinutes = Math.floor(DiffInMilliseconds / (1000 * 60)); + var DiffInDays = Math.floor(TotalMinutes / (60 * 24)); + var DiffInHours = Math.floor((TotalMinutes % (60 * 24)) / 60); + var DiffInMinutes = TotalMinutes % 60; + var TimeDiff = ""; if (DiffInDays != 0) { - TimeDiff += DiffInDays + " Days, " + TimeDiff += DiffInDays + " Day" + (DiffInDays != 1 ? "s" : "") + ", "; } if (DiffInHours != 0) { - TimeDiff += DiffInHours + " Hours, " + TimeDiff += DiffInHours + " Hour" + (DiffInHours != 1 ? "s" : "") + ", "; } - TimeDiff += DiffInMinutes + " Minutes Ago" + TimeDiff += DiffInMinutes + " Minute" + (DiffInMinutes != 1 ? "s" : "") + " Ago"; return (
-
- -
- -
-
-

- {props.photographer} -

-
- -

+

+ {utilities.renderAuthors(props.authors)} +

+
+ + - + `} + > + {PostTime.toLocaleString()} + -
- -

+ {props.imageurl != "http://wp.dailybruin.com/images/2017/03/db-logo.png" && + +
+ +
+ /*

- By {utilities.renderAuthors(props.authors)} -

-
+ {props.photographer} +

*/ + } +
); } diff --git a/components/BreakingFeedsHeader/index.jsx b/components/BreakingFeedsHeader/index.jsx new file mode 100644 index 0000000..ecdd70b --- /dev/null +++ b/components/BreakingFeedsHeader/index.jsx @@ -0,0 +1,121 @@ +import * as React from "react"; +import Link from "next/link"; +/** @jsx jsx */ +import { css, jsx } from "@emotion/core"; +import * as globals from "../globals"; + +export default function TagHeader(props) { + return ( +
+
+
+ {/* Adjust the size as needed */} + + +
+ +
+
+ +
+ +
+
+ ); +} diff --git a/components/SectionHeader/index.jsx b/components/SectionHeader/index.jsx index 3d8e6a1..aa6c1c2 100644 --- a/components/SectionHeader/index.jsx +++ b/components/SectionHeader/index.jsx @@ -26,7 +26,11 @@ export default class SectionHeader extends React.Component { `} > ); - } else { + // } else if (this.props.category == "Breaking News") { + + // } + } + else { return (
); diff --git a/layouts/Breaking/index.jsx b/layouts/Breaking/index.jsx index 554b5ba..1ef20f6 100644 --- a/layouts/Breaking/index.jsx +++ b/layouts/Breaking/index.jsx @@ -20,7 +20,7 @@ export default class BreakingLayout extends React.Component { getPosts(page) { fetch( - `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=${this.props.categoryID}&page=${page}` + `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=${this.props.categoryID}&tag=${this.props.tagID}&page=${page}` ) .then(response => response.json()) .then( @@ -178,7 +178,7 @@ export default class BreakingLayout extends React.Component { textAlign: "center" }} > - End of Breaking Feed! + {/* Could have text here to display when breaking feed is done */}

) : ( diff --git a/pages/category/breaking/[slug].jsx b/pages/category/breaking/[slug].jsx new file mode 100644 index 0000000..542cd6c --- /dev/null +++ b/pages/category/breaking/[slug].jsx @@ -0,0 +1,59 @@ +import PageWrapper from "../../../layouts/PageWrapper"; +import React, { Component } from "react"; +import Error from "next/error"; +import { Config } from "../../../config.js"; +import Head from "next/head"; + +import BreakingFeedsHeader from "../../../components/BreakingFeedsHeader"; +import BreakingLayout from "../../../layouts/Breaking"; + +/* +When we have a URL that is https://dailybruin.com/category/breaking/[tag name] +First we take the slug that is provided in the url, then we get the ID of that slug +Next we create a new query string +Category ID #27093 is the Category ID of breaking news +https://wp.dailybruin.com/wp-json/wp/v2/posts?categories=27093&tags=[TAG ID] +*/ + +class Tag extends Component { + static async getInitialProps(context) { + const { slug } = context.query; + const tagRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/tags?slug=${slug}` + ); + const tag = await tagRes.json(); + if (tag.length > 0) { + const postsRes = await fetch( + `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=27093&tags=${tag[0].id}` + ); + const posts = await postsRes.json(); + return { tag, posts }; + } + return { tag }; + } + render() { + if (this.props.tag.data != undefined || this.props.tag.length == 0) + return ; + return ( + <> + + {this.props.tag[0].name + " - Daily Bruin"} + +
+
+ +
+ +
+ + ); + } +} + +export default PageWrapper(Tag); diff --git a/pages/category/breaking.jsx b/pages/category/breaking/breaking.jsx similarity index 94% rename from pages/category/breaking.jsx rename to pages/category/breaking/breaking.jsx index ad787c9..4ef6e69 100644 --- a/pages/category/breaking.jsx +++ b/pages/category/breaking/breaking.jsx @@ -1,11 +1,11 @@ -import PageWrapper from "../../layouts/PageWrapper"; +import PageWrapper from "../../../layouts/PageWrapper.jsx"; import React, { Component } from "react"; import Error from "next/error"; -import { Config } from "../../config.js"; +import { Config } from "../../../config.js"; import Head from "next/head"; -import SectionHeader from "../../components/SectionHeader"; -import BreakingLayout from "../../layouts/Breaking"; +import SectionHeader from "../../../components/SectionHeader/index.jsx"; +import BreakingLayout from "../../../layouts/Breaking/index.jsx"; const COLUMN_SERIES_FEATURE_FLAG = false; From 00486f41c6842ce95e4772d8326573c7263ba5b8 Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Fri, 11 Oct 2024 14:36:43 -0700 Subject: [PATCH 4/7] Added sticky news bulletin, fixed news feed to work mobile and tablet Breaking news page is now separated into three columns, a general overview that sticks with the user as they scroll, a feed in the middle, and an ad zone on the left side of the screen. --- components/ArticleCard/Breaking.jsx | 5 +- components/ArticleCard/BreakingOverview.jsx | 116 +++++++++++++++ components/ArticleCard/index.jsx | 4 + components/BreakingFeedsHeader/index.jsx | 3 +- layouts/Breaking/index.jsx | 153 +++++++++++++++----- layouts/utilities.jsx | 2 +- pages/category/breaking/[slug].jsx | 11 +- 7 files changed, 250 insertions(+), 44 deletions(-) create mode 100644 components/ArticleCard/BreakingOverview.jsx diff --git a/components/ArticleCard/Breaking.jsx b/components/ArticleCard/Breaking.jsx index 353feee..903c115 100644 --- a/components/ArticleCard/Breaking.jsx +++ b/components/ArticleCard/Breaking.jsx @@ -35,14 +35,14 @@ export default function Breaking(props) { background-color: #ffffff; /*border: 10px solid #d12008;*/ border-radius: 20px; - width: 50%; - margin-left: 25%; + width: 100%; `} >
@@ -132,6 +132,7 @@ export default function Breaking(props) { object-fit: cover; padding: 20px; padding-top: 0px; + padding-bottom: 10px; `} src={props.imageurl} /> diff --git a/components/ArticleCard/BreakingOverview.jsx b/components/ArticleCard/BreakingOverview.jsx new file mode 100644 index 0000000..99494df --- /dev/null +++ b/components/ArticleCard/BreakingOverview.jsx @@ -0,0 +1,116 @@ +import * as React from "react"; +import Link from "next/link"; +/** @jsx jsx */ +import { css, jsx } from "@emotion/core"; +import * as globals from "../globals"; +import * as locals from "./locals"; +import * as utilities from "./utilities"; +import * as moment from "moment"; + +export default function BreakingOverview(props) { + return ( +
+
+ + +

+ {"What we're covering here"} +

+
+
+
+
+
+ {props.imageurl != "http://wp.dailybruin.com/images/2017/03/db-logo.png" && + +
+ +
+ /*

+ {props.photographer} +

*/ + } + +
+ ); +} diff --git a/components/ArticleCard/index.jsx b/components/ArticleCard/index.jsx index 22b227e..a000642 100644 --- a/components/ArticleCard/index.jsx +++ b/components/ArticleCard/index.jsx @@ -9,6 +9,7 @@ import Mini from "./Mini"; import Video from "./Video"; import Podcast from "./Podcast"; import Breaking from "./Breaking"; +import BreakingOverview from "./BreakingOverview" export default class ArticleCard extends React.Component { constructor(props) { @@ -42,6 +43,9 @@ export default class ArticleCard extends React.Component { case "breaking": card = ; break; + case "breakingOverview": + card = ; + break; default: card = ; } diff --git a/components/BreakingFeedsHeader/index.jsx b/components/BreakingFeedsHeader/index.jsx index ecdd70b..326e971 100644 --- a/components/BreakingFeedsHeader/index.jsx +++ b/components/BreakingFeedsHeader/index.jsx @@ -4,7 +4,7 @@ import Link from "next/link"; import { css, jsx } from "@emotion/core"; import * as globals from "../globals"; -export default function TagHeader(props) { +export default function BreakingFeedsHeader(props) { return (
{ if (json.data == undefined && json.length != 0) { - console.log(json.length()) this.setState({ otherArticleCards: this.state.otherArticleCards.concat( utilities.buildArticleList(json) @@ -52,6 +82,7 @@ export default class BreakingLayout extends React.Component { } render() { + const { isFixed } = this.state; return ( +
+ {utilities.buildArticleCard(this.props.eventSummary, "breakingOverview")} +
{utilities.renderPostArray( this.state.otherArticleCards, - "full" + "breaking" )} {!this.state.more ? ( @@ -99,7 +133,7 @@ export default class BreakingLayout extends React.Component { textAlign: "center" }} > - no more articles! + End of news feed

) : ( @@ -117,6 +151,9 @@ export default class BreakingLayout extends React.Component { }} >
+
+ {utilities.buildArticleCard(this.props.eventSummary, "breakingOverview")} +
{utilities.renderPostArray( this.state.otherArticleCards, - "horz" + "breaking" )} {!this.state.more ? ( @@ -139,7 +176,7 @@ export default class BreakingLayout extends React.Component { textAlign: "center" }} > - no more articles! + End of news feed

) : ( @@ -149,40 +186,78 @@ export default class BreakingLayout extends React.Component {
)} {matches.desktop && ( -
-
-
- - } - > - {utilities.renderPostArray( - this.state.otherArticleCards, - "breaking" - )} - - {!this.state.more ? ( -

+

+
+ {/* + Normally you might just be able to do position: sticky to get the card to stick to the top of the + screen, but the stick only applies for the height of the div. + Instead of calculating the height of the screen to make the height of the div, we can instead + just put the position to fixed when the top of the div (from getBoundingClientRect) + + */} +
+ {utilities.buildArticleCard(this.props.eventSummary, "breakingOverview")} +
+
+
+
+ + } > - {/* Could have text here to display when breaking feed is done */} -

- ) : ( - - )} + {utilities.renderPostArray( + this.state.otherArticleCards, + "breaking" + )} +
+ {!this.state.more ? ( +

+ End of news feed +

+ ) : ( + + )} +
+
+
diff --git a/layouts/utilities.jsx b/layouts/utilities.jsx index 4a0096d..96aa0a9 100644 --- a/layouts/utilities.jsx +++ b/layouts/utilities.jsx @@ -15,7 +15,7 @@ export function buildArticleCard(story, type = "") { as={story.link} link={story.link} key={story.id.toString()} - date={moment.utc(story.date)} + date={story.date} authors={story.coauthors != undefined ? story.coauthors : []} category={{ name: story._embedded["wp:term"][0][0].name, diff --git a/pages/category/breaking/[slug].jsx b/pages/category/breaking/[slug].jsx index 542cd6c..e5a43db 100644 --- a/pages/category/breaking/[slug].jsx +++ b/pages/category/breaking/[slug].jsx @@ -27,7 +27,15 @@ class Tag extends Component { `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=27093&tags=${tag[0].id}` ); const posts = await postsRes.json(); - return { tag, posts }; + /* + This is temporary for the event summary, we will have to make a new tag / category for event Summary then pluck that + */ + const eventSummary = posts[0]; + posts.push(posts[1]); + posts.push(posts[0]); + posts.push(posts[1]); + posts.push(posts[0]); + return { tag, posts, eventSummary }; } return { tag }; } @@ -49,6 +57,7 @@ class Tag extends Component {
From 0dc0bdcc83b5083bdbf56bce35ff822bedfdb312 Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Fri, 11 Oct 2024 15:01:00 -0700 Subject: [PATCH 5/7] Added routing for new breaking news overview category modified the way the headline is displayed for "What we're covering here", might change it back --- components/ArticleCard/BreakingOverview.jsx | 18 ++---------------- pages/category/breaking/[slug].jsx | 6 +++++- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/components/ArticleCard/BreakingOverview.jsx b/components/ArticleCard/BreakingOverview.jsx index 99494df..56b4205 100644 --- a/components/ArticleCard/BreakingOverview.jsx +++ b/components/ArticleCard/BreakingOverview.jsx @@ -35,11 +35,8 @@ export default function BreakingOverview(props) {

@@ -49,17 +46,6 @@ export default function BreakingOverview(props) {
-
Date: Sat, 26 Oct 2024 15:47:31 -0700 Subject: [PATCH 6/7] removed default breaking page, changed color of outline --- components/ArticleCard/Breaking.jsx | 2 +- components/ArticleCard/BreakingOverview.jsx | 4 +- pages/category/breaking/[slug].jsx | 4 - pages/category/breaking/breaking.jsx | 110 -------------------- 4 files changed, 3 insertions(+), 117 deletions(-) delete mode 100644 pages/category/breaking/breaking.jsx diff --git a/components/ArticleCard/Breaking.jsx b/components/ArticleCard/Breaking.jsx index 903c115..263389d 100644 --- a/components/ArticleCard/Breaking.jsx +++ b/components/ArticleCard/Breaking.jsx @@ -94,7 +94,7 @@ export default function Breaking(props) {
0) { - const subcategoriesRes = await fetch( - `${Config.apiUrl}/wp-json/wp/v2/categories?parent=${category[0].id}&per_page=100` - ); - const subcategories = await subcategoriesRes.json(); - for (let i = 0; i < subcategories.length; i++) { - // const subsubcategoriesRes = await fetch( - // `${Config.apiUrl}/wp-json/wp/v2/categories?parent=${subcategories[i].id}` - // ); - // subcategories[i].subsubcategories = await subsubcategoriesRes.json(); - subcategories[i].subsubcategories = []; - } - - const postsRes = await fetch( - `${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=${category[0].id}` - ); - const posts = await postsRes.json(); - - const classifiedsRes = await fetch( - `${Config.apiUrl}/wp-json/wp/v2/classifieds?_embed&Featured=3` - ); - const classifieds = await classifiedsRes.json(); - return { category, subcategories, posts, classifieds }; - } else { - return { category }; - } - } - render() { - if ( - this.props.category == undefined || - this.props.category.data != undefined || - this.props.category.length == 0 - ) { - return ; - } - for (let i = 0; i < this.props.posts.length; i++) - { - this.props.posts[i].excerpt = this.props.posts[i].content - } - const sectionLinks = this.props.subcategories.map(index => { - const subsubcategoriesSimple = index.subsubcategories.map(index => { - return { name: index.name, link: `/category/${index.slug}` }; - }); - return { - name: index.name, - link: `/category/${index.slug}`, - subsubcategories: subsubcategoriesSimple - }; - }); - return ( - <> - - {this.props.category[0].name + " - Daily Bruin"} - -
- -
- { - return { - category: { - name: c._embedded["wp:term"][1][0].name, - url: c._embedded["wp:term"][1][0].link - }, - content: { name: c.content.rendered, url: c.link } - }; - })} - /> - - ); - } -} - -export default PageWrapper(Category); From 031a14c7f147a4e8df0eb83501f06a89218e825b Mon Sep 17 00:00:00 2001 From: Ed Nawrocki Date: Mon, 4 Nov 2024 13:22:15 -0800 Subject: [PATCH 7/7] removed /category/breaking post page --- pages/category/[slug].jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/category/[slug].jsx b/pages/category/[slug].jsx index 290dfb0..f8ea78e 100755 --- a/pages/category/[slug].jsx +++ b/pages/category/[slug].jsx @@ -25,6 +25,10 @@ class Category extends Component { static async getInitialProps(context) { // slug is from url const { slug } = context.query; + if (slug == 'breaking') { + const category = undefined + return { category } + } const categoryRes = await fetch( `${Config.apiUrl}/wp-json/wp/v2/categories?slug=${slug}` ); @@ -77,7 +81,8 @@ class Category extends Component { if ( this.props.category == undefined || this.props.category.data != undefined || - this.props.category.length == 0 + this.props.category.length == 0 || + this.slug == 'breaking' ) { return ; }