Add language prefix support to cached markdown rendering
Add language prefix parameter to cache functions Update renderContentFile to handle language prefixes Add language prefix to internal links in markdown Make template variables available to PHP content files
This commit is contained in:
parent
f212e320cb
commit
8291a86373
2 changed files with 33 additions and 15 deletions
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
function getCachedMarkdown(string $filePath): ?string {
|
||||
function getCachedMarkdown(string $filePath, string $langPrefix = ''): ?string {
|
||||
$cacheDir = '/tmp/folderweb_cache';
|
||||
$mtime = filemtime($filePath);
|
||||
$cacheKey = md5($filePath . $mtime);
|
||||
$cacheKey = md5($filePath . $mtime . $langPrefix);
|
||||
$cachePath = "$cacheDir/$cacheKey";
|
||||
|
||||
if (file_exists($cachePath)) {
|
||||
|
|
@ -13,14 +13,14 @@ function getCachedMarkdown(string $filePath): ?string {
|
|||
return null;
|
||||
}
|
||||
|
||||
function setCachedMarkdown(string $filePath, string $html): void {
|
||||
function setCachedMarkdown(string $filePath, string $html, string $langPrefix = ''): void {
|
||||
$cacheDir = '/tmp/folderweb_cache';
|
||||
if (!is_dir($cacheDir)) {
|
||||
mkdir($cacheDir, 0755, true);
|
||||
}
|
||||
|
||||
$mtime = filemtime($filePath);
|
||||
$cacheKey = md5($filePath . $mtime);
|
||||
$cacheKey = md5($filePath . $mtime . $langPrefix);
|
||||
$cachePath = "$cacheDir/$cacheKey";
|
||||
|
||||
file_put_contents($cachePath, $html);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue