Skip to content

Commit 2e35df4

Browse files
authored
Merge pull request #2723 from PolicyEngine/enhanced-cps-full-launch
Add OBBBA household-by-household tile and update blog dates
2 parents 335b6fe + 5548490 commit 2e35df4

8 files changed

Lines changed: 76 additions & 19 deletions

File tree

234 KB
Loading
63.9 KB
Loading
1.38 MB
Loading

src/pages/BlogPage.jsx

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,29 @@ export default function BlogPage() {
4949
// /uk/research/blog-slug-here
5050
const { postName } = useParams();
5151
const countryId = useCountryId();
52+
const [content, setContent] = useState("");
5253

5354
const post = posts.find((post) => post.slug === postName);
54-
const postDate = formatFullDate(moment(post.date), countryId);
5555

56-
const imageUrl = post.image ? handleImageLoad(post.image) : "";
57-
const file = require(`../posts/articles/${post.filename}`);
56+
const isNotebook =
57+
post && post.filename ? post.filename.endsWith(".ipynb") : false;
58+
const file =
59+
post && post.filename
60+
? require(`../posts/articles/${post.filename}`)
61+
: null;
5862

59-
const [content, setContent] = useState("");
60-
const isNotebook = post.filename.endsWith(".ipynb");
6163
useEffect(() => {
62-
fetch(file)
63-
.then((response) => response.text())
64-
.then((text) => {
65-
if (isNotebook) {
66-
setContent(JSON.parse(text));
67-
} else {
68-
setContent(text);
69-
}
70-
});
64+
if (file) {
65+
fetch(file)
66+
.then((response) => response.text())
67+
.then((text) => {
68+
if (isNotebook) {
69+
setContent(JSON.parse(text));
70+
} else {
71+
setContent(text);
72+
}
73+
});
74+
}
7175
}, [file, isNotebook]);
7276

7377
// Some old links might point to a dated URL format
@@ -76,6 +80,19 @@ export default function BlogPage() {
7680
return <Navigate to={`/${countryId}/blog/${postName.substring(11)}`} />;
7781
}
7882

83+
// Handle external URL redirects
84+
if (post && post.external_url) {
85+
return <Navigate to={post.external_url} replace />;
86+
}
87+
88+
// Handle missing post or filename
89+
if (!post || !post.filename) {
90+
return <Navigate to={`/${countryId}/research`} replace />;
91+
}
92+
93+
const postDate = formatFullDate(moment(post.date), countryId);
94+
const imageUrl = post.image ? handleImageLoad(post.image) : "";
95+
7996
let markdown;
8097

8198
if (isNotebook && content) {

src/pages/home/HomeBlogPreview.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ export function FeaturedBlogPreview({ blogs, width, imageHeight }) {
403403
export function MediumBlogPreview({ blog, minHeight }) {
404404
const displayCategory = useDisplayCategory();
405405
const countryId = useCountryId();
406-
const slug = blog.filename.split(".")[0];
407-
const link = `/${countryId}/research/${slug}`;
406+
const slug = blog.filename ? blog.filename.split(".")[0] : blog.slug;
407+
const link = blog.external_url || `/${countryId}/research/${slug}`;
408408

409409
const imageUrl = blog.image ? handleImageLoad(blog.image) : "";
410410

src/posts/authors.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,23 @@
150150
"github": "https://github.com/eccuraa",
151151
"headshot": "elena-cura.png",
152152
"title": "Data Science Intern at PolicyEngine"
153+
},
154+
"ben-ogorek": {
155+
"name": "Ben Ogorek",
156+
"email": "ben.ogorek@policyengine.org",
157+
"bio": "Ben is a data scientist at PolicyEngine.",
158+
"linkedin": "https://www.linkedin.com/in/benogorek/",
159+
"github": "https://github.com/baogorek",
160+
"headshot": "ben-ogorek.jpeg",
161+
"title": "Data Scientist at PolicyEngine"
162+
},
163+
"maria-juaristi": {
164+
"name": "Maria Juaristi",
165+
"email": "maria@policyengine.org",
166+
"bio": "Maria is a data scientist at PolicyEngine.",
167+
"linkedin": "https://www.linkedin.com/in/mariajuaristi/",
168+
"github": "https://github.com/juaristi22",
169+
"headshot": "maria-juaristi.jpeg",
170+
"title": "Data Scientist at PolicyEngine"
153171
}
154172
}

src/posts/postTransformers.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import posts from "./posts.json";
33
const postsSorted = posts.sort((a, b) => (a.date < b.date ? 1 : -1));
44

55
for (let post of postsSorted) {
6-
post.slug = post.filename.substring(0, post.filename.indexOf("."));
6+
if (post.filename) {
7+
post.slug = post.filename.substring(0, post.filename.indexOf("."));
8+
} else if (post.external_url) {
9+
// For external URLs, generate a slug from the title
10+
post.slug = post.title
11+
.toLowerCase()
12+
.replace(/\s+/g, "-")
13+
.replace(/[^a-z0-9-]/g, "");
14+
}
715
}
816

917
const tags = postsSorted.map((post) => post.tags);

src/posts/posts.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22
{
33
"title": "Enhanced CPS full launch: Comprehensive microdata for policy analysis",
44
"description": "The Enhanced Current Population Survey now includes tip, overtime, and auto loan interest imputations, plus upcoming state and congressional district calibration.",
5-
"date": "2025-08-08",
5+
"date": "2025-08-11",
66
"tags": ["us", "data", "featured"],
77
"filename": "enhanced-cps-launch.md",
88
"image": "enhanced-cps-launch.png",
9-
"authors": ["max-ghenis", "nikhil-woodruff"]
9+
"authors": ["max-ghenis", "nikhil-woodruff", "ben-ogorek", "maria-juaristi"]
10+
},
11+
{
12+
"title": "The One Big Beautiful Bill Act, household by household",
13+
"description": "Our latest interactive shows how the reconciliation bill affects each of 20,000 representative households across income levels, states, and provisions.",
14+
"date": "2025-08-11",
15+
"tags": ["us", "policy", "featured", "reconciliation", "interactives"],
16+
"external_url": "/us/obbba-household-by-household",
17+
"image": "obbba-household-by-household.png",
18+
"authors": [
19+
"max-ghenis",
20+
"pavel-makarchuk",
21+
"ben-ogorek",
22+
"nikhil-woodruff"
23+
]
1024
},
1125
{
1226
"title": "Analysis of individual income tax provisions in the final reconciliation bill",

0 commit comments

Comments
 (0)