mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
implement getPageLinkByPath method, fix readme
This commit is contained in:
parent
d12b52597f
commit
fbfaed02fc
2 changed files with 49 additions and 22 deletions
|
|
@ -110,19 +110,10 @@ class Helper
|
|||
{
|
||||
foreach ((array) $this->_filesystem->getPagePathsByPath($directory) as $file)
|
||||
{
|
||||
$pages[] = sprintf(
|
||||
'=> /%s %s',
|
||||
$this->_filesystem->getPageUriByPath(
|
||||
$file
|
||||
),
|
||||
$this->_reader->getH1(
|
||||
$this->_reader->toGemini(
|
||||
file_get_contents(
|
||||
$file
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($link = $this->getPageLinkByPath($file))
|
||||
{
|
||||
$pages[] = $link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,4 +129,26 @@ class Helper
|
|||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function getPageLinkByPath(string $path): ?string
|
||||
{
|
||||
if (in_array($path, $this->_filesystem->getList()) && is_file($path) && is_readable($path))
|
||||
{
|
||||
return sprintf(
|
||||
'=> /%s %s',
|
||||
$this->_filesystem->getPageUriByPath(
|
||||
$path
|
||||
),
|
||||
$this->_reader->getH1(
|
||||
$this->_reader->toGemini(
|
||||
file_get_contents(
|
||||
$path
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue