@@ -87,6 +87,53 @@ pub fn generate_closing_message(issue_number: u32) -> String {
8787 . to_string ( )
8888}
8989
90+ pub fn generate_intro_closing ( issue_number : u32 ) -> String {
91+ match issue_number % 41 {
92+ 1 => "Enjoy the journey ahead!" ,
93+ 2 => "Let's dive in and learn together!" ,
94+ 3 => "Time to explore and experiment!" ,
95+ 4 => "May your code compile on the first try!" ,
96+ 5 => "Happy learning and building!" ,
97+ 6 => "Let's get coding!" ,
98+ 7 => "Enjoy this issue and keep shipping!" ,
99+ 8 => "Hope you find something inspiring!" ,
100+ 9 => "Ready to level up your skills?" ,
101+ 10 => "Make something you are proud of!" ,
102+ 11 => "One small step today counts!" ,
103+ 12 => "Build, break, learn, repeat!" ,
104+ 13 => "Stay curious and keep tinkering!" ,
105+ 14 => "Push an idea a little further!" ,
106+ 15 => "Create value, have fun!" ,
107+ 16 => "Sharpen your tools and ship!" ,
108+ 17 => "Try it, test it, teach it!" ,
109+ 18 => "Progress beats perfection!" ,
110+ 19 => "Learn a little, apply a lot!" ,
111+ 20 => "Trust the process and iterate!" ,
112+ 21 => "Let curiosity lead the way!" ,
113+ 22 => "Make it work, then make it better!" ,
114+ 23 => "Small wins add up fast!" ,
115+ 24 => "Build something delightful!" ,
116+ 25 => "Keep going, you are close!" ,
117+ 26 => "Sketch, code, refine!" ,
118+ 27 => "Turn ideas into experiments!" ,
119+ 28 => "Read, try, reflect, repeat!" ,
120+ 29 => "Ship the smallest useful thing!" ,
121+ 30 => "Improve 1% today!" ,
122+ 31 => "Stretch your skills a notch!" ,
123+ 32 => "Refactor with kindness to your future self!" ,
124+ 33 => "Document now, thank yourself later!" ,
125+ 34 => "Chase clarity, not cleverness!" ,
126+ 35 => "Learn by doing and sharing!" ,
127+ 36 => "Ask good questions, find better answers!" ,
128+ 37 => "Make it simple and solid!" ,
129+ 38 => "Quality is a habit. Practice!" ,
130+ 39 => "Explore the edges of your comfort zone!" ,
131+ 40 => "Keep building. The future is compounding!" ,
132+ _ => "Happy reading and coding!" ,
133+ }
134+ . to_string ( )
135+ }
136+
90137// Embed the newsletter template at compile time
91138const NEWSLETTER_TEMPLATE : & str = include_str ! ( "../templates/newsletter.md" ) ;
92139
@@ -144,6 +191,10 @@ impl TemplateRenderer {
144191 let greeting = generate_greeting ( issue_number) ;
145192 context. insert ( "greeting" , & greeting) ;
146193
194+ // Add intro closing variable
195+ let intro_closing = generate_intro_closing ( issue_number) ;
196+ context. insert ( "intro_closing" , & intro_closing) ;
197+
147198 // Add closing variables
148199 let closing_title = generate_closing_title ( issue_number) ;
149200 let closing_message = generate_closing_message ( issue_number) ;
@@ -187,7 +238,7 @@ mod tests {
187238 title : "An Interactive Guide to SVG Paths" . to_string ( ) ,
188239 url : "https://joshwcomeau.com/svg/interactive-guide-to-paths" . to_string ( ) ,
189240 description : "I've always had a bit of a thing for vector graphics..." . to_string ( ) ,
190- image : "https://assets.buttondown.email/images/23f6bfbf-fa80-44b0-b4e3-692947f7363a.png?w=960&fit=max" . to_string ( ) ,
241+ image : Some ( "https://assets.buttondown.email/images/23f6bfbf-fa80-44b0-b4e3-692947f7363a.png?w=960&fit=max" . to_string ( ) ) ,
191242 score : 100 ,
192243 original_image : "" . to_string ( ) ,
193244 campaign_urls : CampaignUrls {
@@ -202,7 +253,7 @@ mod tests {
202253 title: "Closer to the Metal: Leaving Playwright for CDP" . to_string( ) ,
203254 url: "https://browser-use.com/posts/playwright-to-cdp" . to_string( ) ,
204255 description: "Let's switch gears... but not completely..." . to_string( ) ,
205- image: "" . to_string( ) ,
256+ image: Some ( "" . to_string( ) ) ,
206257 score: 90 ,
207258 original_image: "" . to_string( ) ,
208259 campaign_urls: CampaignUrls {
@@ -218,7 +269,7 @@ mod tests {
218269 title: "React calendar components: 6 best libraries for 2025" . to_string( ) ,
219270 url: "https://builder.io/blog/best-react-calendar-component-ai" . to_string( ) ,
220271 description: "" . to_string( ) ,
221- image: "" . to_string( ) ,
272+ image: Some ( "" . to_string( ) ) ,
222273 score: 70 ,
223274 original_image: "" . to_string( ) ,
224275 campaign_urls: CampaignUrls {
@@ -301,6 +352,24 @@ mod tests {
301352 assert_eq ! ( greeting10, "Hello" ) ; // Issue 10 (0 modulo)
302353 }
303354
355+ #[ test]
356+ fn test_intro_closing_generation ( ) {
357+ let intro1 = generate_intro_closing ( 1 ) ;
358+ let intro2 = generate_intro_closing ( 2 ) ;
359+ let intro10 = generate_intro_closing ( 10 ) ;
360+ let intro41 = generate_intro_closing ( 41 ) ;
361+ let intro42 = generate_intro_closing ( 42 ) ;
362+
363+ // Different issue numbers should generate different intro closings (except for same modulo 41)
364+ assert_ne ! ( intro1, intro2) ;
365+ assert_ne ! ( intro1, intro10) ;
366+ assert_eq ! ( intro1, intro42) ; // Both 1 and 42 have same modulo (42 % 41 = 1)
367+ assert_eq ! ( intro1, "Enjoy the journey ahead!" ) ; // Issue 1
368+ assert_eq ! ( intro2, "Let's dive in and learn together!" ) ; // Issue 2
369+ assert_eq ! ( intro10, "Make something you are proud of!" ) ; // Issue 10
370+ assert_eq ! ( intro41, "Happy reading and coding!" ) ; // Issue 41 (0 modulo - default)
371+ }
372+
304373 #[ test]
305374 fn test_extra_content_title_generation ( ) {
306375 let title1 = generate_extra_content_title ( 1 ) ;
0 commit comments