Skip to content

Commit 0360974

Browse files
authored
Merge pull request #34 from ethereum/feat/next-generation-shielded-pools-post
feat: add "Exploring Hardened Shielded Pools" blog post
2 parents 113d3cd + f45465c commit 0360974

6 files changed

Lines changed: 154 additions & 2 deletions

File tree

2.53 MB
Loading

src/lib/posts.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { CollectionEntry } from 'astro:content';
2+
3+
/*
4+
* Date gating for the `posts` collection, matching Jekyll's `future: false`:
5+
* a post whose `date` is in the future is hidden until the site is rebuilt at
6+
* or after that moment (GH Pages rebuilds on push/merge).
7+
*
8+
* Shared by every consumer of getCollection('posts') so the blog index, the
9+
* homepage latest-posts list, and static path generation all agree.
10+
*
11+
* The comparison is on the full timestamp, not just the calendar day, so a
12+
* post can be scheduled to the hour. Give `date` a time and offset to pin a
13+
* release (e.g. `2026-06-11T07:00:00-04:00` for 7am ET). A bare `YYYY-MM-DD`
14+
* is parsed as midnight UTC, which keeps day-granular scheduling working.
15+
* Note this only gates the static output: a future-dated post still appears
16+
* only once a build actually runs at or after its `date`.
17+
*/
18+
export function isPublished(
19+
post: CollectionEntry<'posts'>,
20+
now: Date = new Date(),
21+
): boolean {
22+
const date =
23+
post.data.date instanceof Date ? post.data.date : new Date(post.data.date);
24+
return date.getTime() <= now.getTime();
25+
}

src/pages/blog/[slug].astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getCollection, render } from 'astro:content';
1010
import DetailPageLayout from '../../layouts/DetailPageLayout.astro';
1111
import ArticleFooter from '../../components/ArticleFooter.astro';
1212
import { jekyllSlugify } from '../../lib/jekyllSlug';
13+
import { isPublished } from '../../lib/posts';
1314
1415
function toISODate(d: string | Date | undefined): string {
1516
if (!d) return '';
@@ -19,7 +20,7 @@ function toISODate(d: string | Date | undefined): string {
1920
2021
export async function getStaticPaths() {
2122
const entries = await getCollection('posts');
22-
return entries.map((entry) => ({
23+
return entries.filter((entry) => isPublished(entry)).map((entry) => ({
2324
params: { slug: jekyllSlugify(entry.data.title) },
2425
props: { entry },
2526
}));

src/pages/blog/index.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getCollection } from 'astro:content';
1212
import ListPageLayout from '../../layouts/ListPageLayout.astro';
1313
import NextStepCTA from '../../components/NextStepCTA.astro';
1414
import { jekyllSlugify } from '../../lib/jekyllSlug';
15+
import { isPublished } from '../../lib/posts';
1516
1617
function toISODate(d: string | Date | undefined): string {
1718
if (!d) return '';
@@ -21,6 +22,7 @@ function toISODate(d: string | Date | undefined): string {
2122
2223
const all = await getCollection('posts');
2324
const posts = all
25+
.filter((p) => isPublished(p))
2426
.map((p) => ({
2527
slug: jekyllSlugify(p.data.title),
2628
title: p.data.title,

src/pages/index.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PipelineAnimation from '../components/PipelineAnimation.astro';
55
import { getStats } from '../lib/stats';
66
import { getCollection } from 'astro:content';
77
import { jekyllSlugify } from '../lib/jekyllSlug';
8+
import { isPublished } from '../lib/posts';
89
import { findFaq } from '../data/faq';
910
1011
const stats = await getStats();
@@ -18,7 +19,8 @@ function toISODate(d: string | Date | undefined): string {
1819
return String(d).slice(0, 10);
1920
}
2021
const allPosts = await getCollection('posts');
21-
const latestPosts = [...allPosts]
22+
const latestPosts = allPosts
23+
.filter((p) => isPublished(p))
2224
.map((p) => ({
2325
slug: jekyllSlugify(p.data.title),
2426
title: p.data.title,

0 commit comments

Comments
 (0)