forked from laysense/laysite
Add maintenance and 404 pages, template suites, and MCP skill
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Content;
|
||||
|
||||
final class SystemPage
|
||||
{
|
||||
public const TYPES = ['maintenance' => '维护页', 'not-found' => '404 页'];
|
||||
|
||||
public static function slugMatches(string $type, mixed $slug): bool
|
||||
{
|
||||
return isset(self::TYPES[$type]) && is_string($slug)
|
||||
&& preg_match('/^system--' . $type . '-[a-f0-9]{16}$/D', $slug) === 1;
|
||||
}
|
||||
|
||||
public static function published(Repository $repo, string $type, mixed $slug): ?array
|
||||
{
|
||||
if (!self::slugMatches($type, $slug)) {
|
||||
return null;
|
||||
}
|
||||
$page = $repo->page($slug);
|
||||
|
||||
return $page && $page['page_type'] === $type && $page['status'] === 'published' ? $page : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user