mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-09-02 02:12:37 +02:00
Added dynamic page titles
This commit is contained in:
@@ -85,6 +85,7 @@ class DirectoryController
|
||||
}
|
||||
|
||||
return $this->view->render($response, 'index.twig', [
|
||||
'title' => $this->relativePath($path),
|
||||
'breadcrumbs' => $this->breadcrumbs($path),
|
||||
'files' => $files,
|
||||
'is_root' => $this->isRoot($path),
|
||||
@@ -93,6 +94,20 @@ class DirectoryController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the relative path given a full path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function relativePath(string $path): string
|
||||
{
|
||||
return Collection::make(explode('/', $path))->diff(
|
||||
explode('/', $this->container->get('base_path'))
|
||||
)->filter()->implode('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an array of breadcrumbs for a given path.
|
||||
*
|
||||
|
@@ -1,5 +1,6 @@
|
||||
{% extends "layouts/app.twig" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
{% block content %}
|
||||
{% include "components/header.twig" %}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
<link rel="stylesheet" href="{{ asset('app.css') }}">
|
||||
|
||||
<title>Directory Lister</title>
|
||||
<title>{% block title %}{% endblock %} • Directory Lister</title>
|
||||
|
||||
<div id="app" class="flex flex-col min-h-screen font-mono {{ config('dark_mode') ? 'dark-mode' : '' }}">
|
||||
{% block content %}{% endblock %}
|
||||
|
Reference in New Issue
Block a user