Move portfolio case studies to data-driven template system and archive old individual files
This commit is contained in:
31
LocalValetDriver.php
Normal file
31
LocalValetDriver.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class LocalValetDriver extends \Valet\Drivers\BasicValetDriver
|
||||
{
|
||||
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
|
||||
{
|
||||
$path = trim(parse_url($uri, PHP_URL_PATH), '/');
|
||||
|
||||
// /portfolio → portfolio.php
|
||||
if ($path === 'portfolio') {
|
||||
return $this->servePhpFile($sitePath, '/portfolio.php');
|
||||
}
|
||||
|
||||
// /portfolio/{slug} → portfolio-page.php?slug={slug}
|
||||
if (preg_match('#^portfolio/([a-z0-9-]+)$#', $path, $m)) {
|
||||
$_GET['slug'] = $m[1];
|
||||
return $this->servePhpFile($sitePath, '/portfolio-page.php');
|
||||
}
|
||||
|
||||
return parent::frontControllerPath($sitePath, $siteName, $uri);
|
||||
}
|
||||
|
||||
private function servePhpFile(string $sitePath, string $file): string
|
||||
{
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sitePath . $file;
|
||||
$_SERVER['SCRIPT_NAME'] = $file;
|
||||
$_SERVER['DOCUMENT_ROOT'] = $sitePath;
|
||||
|
||||
return $sitePath . $file;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user