Skip to content

Instantly share code, notes, and snippets.

@deepslam
Created August 1, 2019 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepslam/424c56dfb43ccbb62dbc9e10dccddf6b to your computer and use it in GitHub Desktop.
Save deepslam/424c56dfb43ccbb62dbc9e10dccddf6b to your computer and use it in GitHub Desktop.
<?php
if (!function_exists('ssr')) {
function ssr(string $ident = '', $element): string {
$path = storage_path('prerendered/'.$ident.'.json');
if (file_exists($path)) {
$content = file_get_contents($path);
$json = json_decode($content);
if ($json && isset($json->$element)) {
return $json->$element;
}
}
return '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment