Add sitemap.xml/robots.txt and a clearer guest message on site pages

Sitemap lists the static pages plus one URL per indexed site (644
URLs currently); not sharded — fine at this scale, but the sitemap
protocol caps a single file at 50,000 URLs, so this will need a
sitemap index if the site count ever gets there. robots.txt moved
from a static public file to a route so it can point at the real
sitemap URL in any environment (a static file would also silently
shadow the dynamic route in production, since webservers serve
existing public/ files before hitting Laravel's router at all).

Site detail page: guests now get one prominent banner up top ("you're
viewing limited data — register or sign in to see everything") in
addition to the existing per-section "N of M results" notices, so the
overall gating is obvious immediately rather than only on scroll.
Also gave site pages a real per-page meta description (using the
site's own description/title) instead of falling back to the generic
site-wide one — worth doing now that these pages are actually in the
sitemap and indexable.

Caught and fixed a real Blade bug along the way: an inline
:description="..." expression on <x-layouts.app> with escaped
double-quoted PHP strings corrupted the compiler's directive parsing
in a way that only surfaced as a 500 on a page rendering the guest
@guest block below it (mismatched @if/@endif at compile time) — not
on the expression itself. Fixed by computing the description in a
@php block first and passing a plain variable instead.

Verified over real HTTP: sitemap.xml validates as well-formed XML
(644 <url> entries), robots.txt correctly emits the live sitemap URL,
the guest banner and site-specific meta description both render
correctly. Full test suite (31 tests) passes.
This commit is contained in:
m105
2026-07-25 16:25:08 +03:00
parent 4f26f840aa
commit b181dd7e1c
5 changed files with 75 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>{{ route('home') }}</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>{{ route('sites.index') }}</loc>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>{{ route('discover') }}</loc>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
@foreach ($sites as $site)
<url>
<loc>{{ route('sites.show', $site) }}</loc>
<lastmod>{{ $site->updated_at->toAtomString() }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
@endforeach
</urlset>