open note if search is a perfect match on title

This commit is contained in:
quenousimporte 2024-10-01 09:21:11 +02:00
parent 1aeaffde97
commit 6d87adb4d5
1 changed files with 11 additions and 3 deletions

View File

@ -231,12 +231,20 @@
if (($_GET['param'] && isset($_GET['search'])) || isset($_GET['tags'])) if (($_GET['param'] && isset($_GET['search'])) || isset($_GET['tags']))
{ {
$content = file_get_contents($path . '.md'); $content = file_get_contents($path . '.md');
if (
if ((isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) // param does not match content or title
|| (isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))) (isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) ||
// param does not match tags
(isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))
)
{ {
continue; continue;
} }
else if (isset($_GET['search']) && $param == $name)
{
header('Location: index.php?open=true&param=' . urlencode($name));
die();
}
} }
echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>'; echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if (isset($content) && isset($_GET['tags'])) if (isset($content) && isset($_GET['tags']))