chore: filter out blog posts from updates
e7d0aefc
4 file(s) · +20 −5
| 18 | 18 | markdown?: string; |
|
| 19 | 19 | }; |
|
| 20 | 20 | textContent?: string; |
|
| 21 | + | location?: string; |
|
| 21 | 22 | }; |
|
| 22 | 23 | } |
|
| 23 | 24 | ||
| 40 | 41 | .then((res) => (res.ok ? res.json() : { records: [] })) |
|
| 41 | 42 | .catch(() => ({ records: [] })); |
|
| 42 | 43 | ||
| 43 | - | const sortedDocuments: Document[] = (documentsData.records || []).sort( |
|
| 44 | + | const filteredDocuments = (documentsData.records || []).filter( |
|
| 45 | + | (doc: Document) => doc.value.location !== "main-blog", |
|
| 46 | + | ); |
|
| 47 | + | ||
| 48 | + | const sortedDocuments: Document[] = filteredDocuments.sort( |
|
| 44 | 49 | (a: Document, b: Document) => { |
|
| 45 | 50 | const dateA = new Date(a.value.publishedAt); |
|
| 46 | 51 | const dateB = new Date(b.value.publishedAt); |
|
| 25 | 25 | }; |
|
| 26 | 26 | textContent?: string; |
|
| 27 | 27 | publishedAt: string; |
|
| 28 | + | location?: string; |
|
| 28 | 29 | }; |
|
| 29 | 30 | } |
|
| 30 | 31 | ||
| 49 | 50 | } |
|
| 50 | 51 | ||
| 51 | 52 | const data = (await response.json()) as ListRecordsResponse; |
|
| 52 | - | const documents = data.records; |
|
| 53 | + | ||
| 54 | + | // Filter out main-blog posts |
|
| 55 | + | const filteredDocuments = data.records.filter( |
|
| 56 | + | (doc) => doc.value.location !== "main-blog", |
|
| 57 | + | ); |
|
| 53 | 58 | ||
| 54 | 59 | // Sort by publishedAt descending |
|
| 55 | - | documents.sort((a, b) => { |
|
| 60 | + | filteredDocuments.sort((a, b) => { |
|
| 56 | 61 | const dateA = new Date(a.value.publishedAt); |
|
| 57 | 62 | const dateB = new Date(b.value.publishedAt); |
|
| 58 | 63 | return dateB.getTime() - dateA.getTime(); |
|
| 59 | 64 | }); |
|
| 60 | 65 | ||
| 61 | - | const items = documents.map((record) => { |
|
| 66 | + | const items = filteredDocuments.map((record) => { |
|
| 62 | 67 | const doc = record.value; |
|
| 63 | 68 | const rkey = record.uri.split("/").pop(); |
|
| 64 | 69 | ||
| 227 | 227 | } |
|
| 228 | 228 | ||
| 229 | 229 | const data = (await response.json()) as ListRecordsResponse; |
|
| 230 | - | const documents = data.records; |
|
| 230 | + | ||
| 231 | + | // Filter out main-blog posts |
|
| 232 | + | const documents = data.records.filter( |
|
| 233 | + | (doc) => doc.value.location !== "main-blog", |
|
| 234 | + | ); |
|
| 231 | 235 | ||
| 232 | 236 | // Create the feed |
|
| 233 | 237 | const feed = new Feed({ |
| 31 | 31 | tags?: string[]; // Max 50 graphemes per tag |
|
| 32 | 32 | publishedAt: string; // ISO datetime string |
|
| 33 | 33 | updatedAt?: string; // ISO datetime string |
|
| 34 | + | location?: string; // Custom field for filtering posts by location |
|
| 34 | 35 | } |
|
| 35 | 36 | ||
| 36 | 37 | export interface StandardSiteDocumentRecord { |