Skip to content

Commit

Permalink
Merge pull request #149 from dailybruin/Breaking-Feeds
Browse files Browse the repository at this point in the history
Breaking Feeds update
  • Loading branch information
EdNawrocki authored Nov 5, 2024
2 parents 8680f85 + 42c699f commit e1c1152
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pages/category/breaking/[slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@ class Tag extends Component {
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}`
);
`${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=27179&tags=${tag[0].id}`
); //27179 is the id the category of breaking feed posts
const posts = await postsRes.json();
const eventSummaryRes = await fetch(
`${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=27127&tags=${tag[0].id}`
)
); //27127 is the id of the category of breaking feed overview
const eventSummaries = await eventSummaryRes.json();
/*
This is temporary for the event summary, we will have to make a new tag / category for event Summary then pluck that
*/
const eventSummary = eventSummaries[0];
eventSummary.excerpt.rendered = eventSummary.content.rendered; // Currently making the post content the excerpt in order to keep old card skeleton
if (eventSummary) {
eventSummary.excerpt.rendered = eventSummary.content.rendered; // Currently making the post content the excerpt in order to keep old card skeleton
}
return { tag, posts, eventSummary };
}
return { tag };
Expand Down
46 changes: 46 additions & 0 deletions pages/category/breaking/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 CategoryLayout from "../../../layouts/Category";

/*
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 postsRes = await fetch(
`${Config.apiUrl}/wp-json/wp/v2/posts?_embed&categories=27093`
);
const posts = await postsRes.json();
return { posts };
}
render() {
return (
<>
<Head>
<title>{"Breaking News - Daily Bruin"}</title>
</Head>
<div style={{ padding: "6px" }}>
<SectionHeader
category={'Breaking News'}
/>
</div>
<CategoryLayout
posts={this.props.posts}
categoryID={27093}
/>
</>
);
}
}

export default PageWrapper(Tag);

0 comments on commit e1c1152

Please sign in to comment.