<?php
/**
 * TappyCalc Blog - RSS Feed
 */

require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../data/blog-posts.php';

header('Content-Type: application/rss+xml; charset=UTF-8');

$site_url = 'https://tappycalc.com';
?>
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
    <title>TappyCalc Blog</title>
    <link><?php echo $site_url; ?>/blog</link>
    <description>Tips, guides, and insights on GST, EMI, BMI, finance, health, and more from the TappyCalc team.</description>
    <language>en-in</language>
    <lastBuildDate><?php echo date('r'); ?></lastBuildDate>
    <atom:link href="<?php echo $site_url; ?>/blog/feed.xml" rel="self" type="application/rss+xml"/>
    
    <?php foreach ($blog_posts as $post): ?>
    <item>
        <title><?php echo htmlspecialchars($post['title']); ?></title>
        <link><?php echo $site_url; ?>/blog/<?php echo htmlspecialchars($post['slug']); ?></link>
        <guid><?php echo $site_url; ?>/blog/<?php echo htmlspecialchars($post['slug']); ?></guid>
        <description><?php echo htmlspecialchars($post['excerpt']); ?></description>
        <pubDate><?php echo date('r', strtotime($post['date'])); ?></pubDate>
        <?php foreach ($post['tags'] as $tag): ?>
        <category><?php echo htmlspecialchars($tag); ?></category>
        <?php endforeach; ?>
    </item>
    <?php endforeach; ?>
</channel>
</rss>
