|
name = "newsletter" |
|
prompt = """ |
|
Take the latest blog post and convert it into a raw Markdown format suitable for an email newsletter, saving the output to a temporary file. |
|
|
|
Here is the process to follow: |
|
1. Read the file `src/pages/latest.astro` to identify the URL of the latest post. |
|
2. Construct the full path to the post's `.astro` file from that URL. For example, if the URL is `/posts/my-post`, the file path is `src/pages/posts/my-post.astro`. |
|
3. Read the content of the latest post's file. |
|
4. Apply the following conversion rules to transform the Astro file's content into clean Markdown: |
|
- **Remove Frontmatter:** The `---` block at the top of the Astro file must be deleted. |
|
- **Title & Date:** The post title (from the frontmatter) becomes a Level 1 Heading (`# Title`). The publish date (from the frontmatter) should be placed on the line directly below it in plain text. |
|
- **Headings:** Convert all HTML headings (`<h2>`, `<h3>`, etc.) to their corresponding Markdown versions (`##`, `###`). |
|
- **Emphasis:** Convert `<strong>` tags, `<em>` tags, and spans with `font-semibold` class (e.g., `<span class="font-semibold">...</span>`) to their Markdown equivalents (`**bold**` and `*italic*`). |
|
- **Styled Callouts:** Convert all styled `<div>` boxes (e.g., the blue intro box, the red warning) into standard Markdown blockquotes (`>`). Preserve any emphasis within the box using bolding. |
|
- **Links:** Convert all HTML links (`<a href="...">...</a>`) to inline Markdown links (`[link text](URL)`). All relative URLs (e.g., `/posts/recovery`) must be converted to absolute URLs by prepending `https://to10percentbodyfat.com`. |
|
- **Images:** Convert all HTML `<img>` tags to Markdown images (``). The `src` attribute must be converted to an absolute URL by prepending `https://to10percentbodyfat.com`. **Important:** Always use linked images (hosted on a server) rather than embedding them. This is critical for email deliverability and to enable open tracking. Embedded images significantly increase file size, triggering spam filters. |
|
- **Lists:** Convert HTML lists (`<ul>`, `<li>`) to Markdown lists using a hyphen (`-`) for each item. Indent any nested lists with four spaces. |
|
- **Line Wrapping:** Manually wrap all paragraphs and long lines of text to a maximum of 80 characters. This is crucial for readability in mobile email clients. |
|
- **Whitespace:** Ensure a single blank line exists between all elements (paragraphs, headings, lists, blockquotes) to improve scannability. |
|
- **Omit Web Components:** All non-content elements, such as layouts, navigation, or other components, must be removed. |
|
5. Save the final Markdown content to a new file named `newsletter.md` in the project's root directory. |
|
6. Announce the completion by saying: "The newsletter-ready Markdown has been saved to `newsletter.md`." |
|
""" |
|
description = "Generates a newsletter-ready Markdown file from the latest blog post." |