Add plugin system and improve language handling
Add global and page-level plugin support Implement language-aware content filtering Add month translations to language files Refactor date formatting to use translations Move translation loading to plugin system Improve content availability checks
This commit is contained in:
parent
875408a27c
commit
24ee209e17
9 changed files with 196 additions and 30 deletions
|
|
@ -4,6 +4,7 @@
|
|||
require_once __DIR__ . '/constants.php';
|
||||
require_once __DIR__ . '/context.php';
|
||||
require_once __DIR__ . '/helpers.php';
|
||||
require_once __DIR__ . '/plugins.php';
|
||||
require_once __DIR__ . '/config.php';
|
||||
require_once __DIR__ . '/content.php';
|
||||
require_once __DIR__ . '/rendering.php';
|
||||
|
|
@ -90,9 +91,10 @@ switch ($parsedPath['type']) {
|
|||
$itemPath = "$dir/$item";
|
||||
|
||||
// Check if content exists for current language
|
||||
if ($ctx->currentLang !== $ctx->defaultLang) {
|
||||
$contentFiles = findAllContentFiles($itemPath, $ctx->currentLang, $ctx->defaultLang, $ctx->availableLangs);
|
||||
if (empty($contentFiles)) return null;
|
||||
if ($ctx->currentLang !== $ctx->defaultLang && shouldHideUntranslated()) {
|
||||
$hasLangContent = hasLanguageContent($itemPath, $ctx->currentLang, CONTENT_EXTENSIONS);
|
||||
$hasLangMetadata = hasLanguageMetadata($itemPath, $ctx->currentLang);
|
||||
if (!$hasLangContent && !$hasLangMetadata) return null;
|
||||
}
|
||||
|
||||
$metadata = loadMetadata($itemPath, $ctx->currentLang, $ctx->defaultLang);
|
||||
|
|
@ -102,9 +104,9 @@ switch ($parsedPath['type']) {
|
|||
$title = $metadata['title'] ?? extractTitle($itemPath, $ctx->currentLang, $ctx->defaultLang) ?? $item;
|
||||
$date = null;
|
||||
if (isset($metadata['date'])) {
|
||||
$date = formatNorwegianDate($metadata['date']);
|
||||
$date = formatDate($metadata['date'], $ctx->currentLang);
|
||||
} else {
|
||||
$date = extractDateFromFolder($item) ?: date("F d, Y", filemtime($itemPath));
|
||||
$date = extractDateFromFolder($item, $ctx->currentLang) ?: date("F d, Y", filemtime($itemPath));
|
||||
}
|
||||
|
||||
// Use translated slug if available, otherwise use folder name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue