/** * function similar to blade asset * * @param $path * @return string * */ function asset($path, $prefix = '/public') { // get flight $app = Flight::app(); // getting basePath $basePath = $app->get('basePath'); // path to mix-manifest $file = $app->get('basePath').'mix-manifest.json'; if (file_exists($file)) { $manifest = file_get_contents($file); $files = json_decode($manifest, true); if (isset($files[$prefix.$path])) { $path = str_replace($prefix, '', $files[$prefix.$path]); } } return $path; } /** * getting title for head * * @param array $page * @param array $site * @return string */ function title($page, $site) { $title = []; if (isset($site['data']['title'])) { $title[] = $site['data']['title']; } // if not homepage set page title first if ($page['data']['slug']) { array_unshift($title, $page['data']['title']); } else { $title[] = $page['data']['title']; } return join(' | ', $title); } function styles($values) { $result = ''; if ($values && is_array($values)) { $result = implode(' ', $values); } return $result; }