Blog localization: lang-filtered API, strict EN/FA mirrored content, 12 new topics
Deploy Backend / deploy (push) Successful in 2m51s

- Add FilterableByLanguage scope (posts/categories/tags) keyed off the -fa slug convention; every public blog list endpoint honors ?lang=fa|en, feeds/sitemaps keep all languages when omitted
- Homepage (latest/most-viewed/random posts + categories) filters per language; post detail shows same-language related posts only
- Reseed content to a strict English/Persian mirror: 6 existing international topics + 6 new Iran-market topics (technical SEO for Persian sites, Iranian dev freelancing, AI & Iranian dev careers, web design for Iranian businesses, React job market in Iran, WordPress-to-Next migration), 12 posts per language, zero posts in only one language
- Fix 2 legacy FA slugs to follow the EN-slug + -fa convention so twin redirects and mirror assertions hold
- Update seeder test to assert balanced languages, full twin coverage and same-language related posts; add lang-filter coverage
This commit is contained in:
Parsa Aghayi committed 2026-10-02 08:27:20 -04:00
1 parent 21fa37af1f
commit 65415beae7
11 files changed
+904 -32

No files matched your search

+24
View File
@@ -83,4 +83,28 @@ class PostTest extends TestCase
$response->assertStatus(200);
}
public function test_can_filter_posts_by_language()
{
Post::factory()->create(['slug' => 'localized-topic', 'title' => 'A topic']);
Post::factory()->create(['slug' => 'localized-topic-fa', 'title' => 'یک موضوع']);
$response = $this->getJson('/api/blog/posts?per_page=10&lang=fa');
$response->assertStatus(200)
->assertJsonCount(1, 'data')
->assertJsonPath('data.0.slug', 'localized-topic-fa');
$response = $this->getJson('/api/blog/posts?per_page=10&lang=en');
$response->assertStatus(200)
->assertJsonCount(1, 'data')
->assertJsonPath('data.0.slug', 'localized-topic');
// Omitting lang keeps every language (sitemaps, feeds, admin).
$response = $this->getJson('/api/blog/posts?per_page=10');
$response->assertStatus(200)
->assertJsonCount(2, 'data');
}
}