Add language prefix to content URLs and use folder names for assets
Use language prefix for all content URLs and ensure assets reference folder names instead of translated slugs for proper file access
This commit is contained in:
parent
77f97a3a5d
commit
8857a91406
1 changed files with 7 additions and 3 deletions
|
|
@ -139,15 +139,19 @@ switch ($parsedPath['type']) {
|
||||||
// Use slug if available
|
// Use slug if available
|
||||||
$urlSlug = ($metadata && isset($metadata['slug'])) ? $metadata['slug'] : $item;
|
$urlSlug = ($metadata && isset($metadata['slug'])) ? $metadata['slug'] : $item;
|
||||||
|
|
||||||
$baseUrl = '/' . trim($ctx->requestPath, '/') . '/' . urlencode($urlSlug);
|
$langPrefix = $ctx->get('langPrefix', '');
|
||||||
|
$baseUrl = $langPrefix . '/' . trim($ctx->requestPath, '/') . '/' . urlencode($urlSlug);
|
||||||
|
|
||||||
|
// Assets (cover, PDF) must use actual folder name, not translated slug
|
||||||
|
$assetUrl = $langPrefix . '/' . trim($ctx->requestPath, '/') . '/' . urlencode($item);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'url' => $baseUrl . '/',
|
'url' => $baseUrl . '/',
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'summary' => $metadata['summary'] ?? null,
|
'summary' => $metadata['summary'] ?? null,
|
||||||
'cover' => $coverImage ? "$baseUrl/$coverImage" : null,
|
'cover' => $coverImage ? "$assetUrl/$coverImage" : null,
|
||||||
'pdf' => $pdfFile ? "$baseUrl/$pdfFile" : null,
|
'pdf' => $pdfFile ? "$assetUrl/$pdfFile" : null,
|
||||||
'redirect' => $metadata['redirect'] ?? null
|
'redirect' => $metadata['redirect'] ?? null
|
||||||
];
|
];
|
||||||
}, $subdirs));
|
}, $subdirs));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue