getType() == 'file' && strpos($file->getFilename(),'.md') ) { $files[] = $file->getFilename(); } } rsort($files); foreach ($files as $file) { $filename_no_ext = substr($file, 0, strrpos($file, ".")); $file_path = __DIR__.'/../content/'.$file; $file = fopen($file_path, 'r'); $post_title = trim(fgets($file),'#'); $post_slug = create_slug($filename_no_ext.$post_title); fclose($file); $parsedown = new ParsedownExtraPlugin(); // Allow single line breaks $parsedown->setBreaksEnabled(true); // Add image dimensions, lazy loading and figures $parsedown->imageAttributes = ['width', 'height']; $parsedown->imageAttributes = ['loading' => 'lazy']; $parsedown->figuresEnabled = true; // Remove the id and #links on footnotes $parsedown->footnoteLinkAttributes = function() {return ['href' => '#'];}; $parsedown->footnoteReferenceAttributes = function() {return ['id' => null];}; $parsedown->footnoteBackLinkAttributes = function() {return ['href' => '#'];}; $parsedown->footnoteBackReferenceAttributes = function() {return ['id' => null];}; $toc .= '
  • '.$post_title.'
  • '; $posts .= '
    '.$parsedown->text(file_get_contents($file_path)).'
    '; $rss_items .= ' '.trim($post_title, " \t\n\r").' '.substr($filename_no_ext, 0, 10).'T00:00:00+00:00 '.$site_url.'/#'.$post_slug.' '.htmlspecialchars($parsedown->text(file_get_contents($file_path)), ENT_XML1, 'UTF-8').' '; } $files_pages = []; foreach (new DirectoryIterator(__DIR__.'/../content/_pages/') as $file_page) { if ( $file_page->getType() == 'file' && strpos($file_page->getFilename(),'.md') ) { $files_pages[] = $file_page->getFilename(); } } rsort($files_pages); foreach ($files_pages as $file_page) { $filename_no_ext_page = substr($file_page, 0, strrpos($file_page, ".")); $file_path_page = __DIR__.'/../content/_pages/'.$file_page; $file_page = fopen($file_path_page, 'r'); $page_title = trim(fgets($file_page),'# '); $page_slug = create_slug($filename_no_ext_page); fclose($file_page); $parsedown = new ParsedownExtraPlugin(); // Allow single line breaks $parsedown->setBreaksEnabled(true); // Add image dimensions, lazy loading and figures $parsedown->imageAttributes = ['width', 'height']; $parsedown->imageAttributes = ['loading' => 'lazy']; $parsedown->figuresEnabled = true; // Remove the id and #links on footnotes $parsedown->footnoteLinkAttributes = function() {return ['href' => '#'];}; $parsedown->footnoteReferenceAttributes = function() {return ['id' => null];}; $parsedown->footnoteBackLinkAttributes = function() {return ['href' => '#'];}; $parsedown->footnoteBackReferenceAttributes = function() {return ['id' => null];}; if ($page_slug != 'home-content') { $pages .= '
    '.$parsedown->text(file_get_contents($file_path_page)).'
    '; } $pages_footer .=''.trim($page_title, " \t\n\r").'/'; } ?>