File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
apps/site/next-data/generators Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('generateWebsiteFeeds', () => {
2626 slug : '/post-1' ,
2727 title : 'Post 1' ,
2828 author : 'Author 1' ,
29- date : '2024-02 -18' ,
29+ date : '2025-04 -18' ,
3030 categories : [ 'all' ] ,
3131 } ,
3232 ] ,
@@ -36,6 +36,7 @@ describe('generateWebsiteFeeds', () => {
3636 expect ( result . size ) . toBe ( 3 ) ;
3737
3838 const blogFeed = result . get ( 'blog.xml' ) ;
39+ const expectedDate = new Date ( '2025-04-18' ) ;
3940
4041 expect ( blogFeed . options . id ) . toBe ( 'blog.xml' ) ;
4142 expect ( blogFeed . options . title ) . toBe ( 'Node.js Blog' ) ;
@@ -45,9 +46,10 @@ describe('generateWebsiteFeeds', () => {
4546 expect ( blogFeed . items . length ) . toBe ( 1 ) ;
4647 const feedItem = blogFeed . items [ 0 ] ;
4748 expect ( feedItem . id ) . toBe ( '/post-1' ) ;
49+ expect ( feedItem . guid ) . toBe ( `/post-1?${ expectedDate . getTime ( ) } ` ) ;
4850 expect ( feedItem . title ) . toBe ( 'Post 1' ) ;
4951 expect ( feedItem . author ) . toBe ( 'Author 1' ) ;
50- expect ( feedItem . date ) . toEqual ( new Date ( '2024-02-18' ) ) ;
52+ expect ( feedItem . date ) . toEqual ( expectedDate ) ;
5153 expect ( feedItem . link ) . toBe ( 'https://nodejs.org/en/post-1' ) ;
5254 } ) ;
5355} ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ import { siteConfig } from '../../next.json.mjs';
99// with English locale (which is where the website feeds run)
1010const canonicalUrl = `${ BASE_URL } ${ BASE_PATH } /en` ;
1111
12+ // This is April 16th, 2025, which is around the time that https://github.com/nodejs/nodejs.org/pull/7648
13+ // was merged. This ensures that future article edits are properly timestamped, while also preventing the
14+ // currently-published article GUIDs from changing
15+ const guidTimestampStartDate = 1744761600000 ;
16+
1217/**
1318 * This method generates RSS website feeds based on the current website configuration
1419 * and the current blog data that is available
@@ -33,13 +38,22 @@ const generateWebsiteFeeds = ({ posts }) => {
3338
3439 const blogFeedEntries = posts
3540 . filter ( post => post . categories . includes ( category ) )
36- . map ( post => ( {
37- id : post . slug ,
38- title : post . title ,
39- author : post . author ,
40- date : new Date ( post . date ) ,
41- link : `${ canonicalUrl } ${ post . slug } ` ,
42- } ) ) ;
41+ . map ( post => {
42+ const date = new Date ( post . date ) ;
43+ const time = date . getTime ( ) ;
44+
45+ return {
46+ id : post . slug ,
47+ title : post . title ,
48+ author : post . author ,
49+ date,
50+ link : `${ canonicalUrl } ${ post . slug } ` ,
51+ guid :
52+ time > guidTimestampStartDate
53+ ? `${ post . slug } ?${ date . getTime ( ) } `
54+ : post . slug ,
55+ } ;
56+ } ) ;
4357
4458 blogFeedEntries . forEach ( entry => feed . addItem ( entry ) ) ;
4559
You can’t perform that action at this time.
0 commit comments