diff options
Diffstat (limited to 'scripts/php/functions.php')
| -rw-r--r-- | scripts/php/functions.php | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/scripts/php/functions.php b/scripts/php/functions.php index 3e8e7a4..fdedc00 100644 --- a/scripts/php/functions.php +++ b/scripts/php/functions.php @@ -32,8 +32,7 @@ function getPageMetaData(\SplFileInfo $fileInfo, string $src, string $output): a $input = $fileInfo->getRealPath(); $pathData = parsePath($input); - - $url = str_replace([$src, '.gmi'], ['', '.html'], $input); + $url = str_replace([$src, 'index.gmi'], ['', ''], $input); $contentData = parseContent(file_get_contents($input)); @@ -47,7 +46,7 @@ function getPageMetaData(\SplFileInfo $fileInfo, string $src, string $output): a 'title' => $contentData['title'], 'author' => $contentData['author'], 'html' => gemtext2hmtl(file_get_contents($input)), - 'output' => "$output$url", + 'output' => "$output{$url}index.html", ]; } @@ -253,7 +252,7 @@ function generateAtomFeeds(array $pages, string $hostname): void /** * Get the page that lists all posts. */ - $allPostsIndex = array_values(array_filter($pages, fn ($post) => preg_match('/posts\/index/', $post['url']) == 1))[0]; + $allPostsIndex = array_values(array_filter($pages, fn ($post) => preg_match('/posts\/index/', $post['output']) == 1))[0]; $allPostsIndex['posts'] = $posts; @@ -266,7 +265,7 @@ function tagToAtomFeed(array $tag, string $hostname): void str_replace('index.html', 'atom.xml', $tag['output']), buildAtomFeed( $tag['title'], - "https://$hostname".str_replace('index.html', 'atom.xml', $tag['url']), + "https://$hostname{$tag['url']}atom.xml", "https://$hostname".$tag['url'], $tag['posts'][0]['date'].'T12:00:00Z', implode('', array_map(fn ($post) => postToAtomEntry($post, $hostname), $tag['posts'])) |
