<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">

  @foreach($posts as $post)
  <url>
    <loc>{{ $domain }}/blog/{{ $post->slug }}</loc>
    <priority>0.75</priority>
    <changefreq>monthly</changefreq>
    <lastmod>{{ $post->updated_at?->toAtomString() ?? now()->toAtomString() }}</lastmod>
    @if($post->cover_image)
    <image:image>
      <image:loc>{{ $post->cover_image }}</image:loc>
      <image:title>{{ htmlspecialchars($post->title) }}</image:title>
    </image:image>
    @endif
    @if($post->published_at && $post->published_at->gt(now()->subDays(2)))
    <news:news>
      <news:publication>
        <news:name>Animexe Blog</news:name>
        <news:language>tr</news:language>
      </news:publication>
      <news:publication_date>{{ $post->published_at->toAtomString() }}</news:publication_date>
      <news:title>{{ htmlspecialchars($post->title) }}</news:title>
      @if($post->excerpt)<news:keywords>{{ htmlspecialchars(\Illuminate\Support\Str::limit($post->excerpt, 200)) }}</news:keywords>@endif
    </news:news>
    @endif
  </url>
  @endforeach

</urlset>
