basteyy / static-markdown-pages
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:plugin
Requires
- php: 8.1.*
- league/commonmark: 2.*
- symfony/yaml: v6.*
This package is auto-updated.
Last update: 2025-02-15 21:54:22 UTC
README
A tool for using static markdown pages inside your project.
Setup
composer require basteyy/static-markdown-pages
Usage
First you need to have your markdown pages. In the following example I expect, that you have stored a couple of files inside /var/www/storage/my_pages/
.
$ ls /var/www/storage/my_pages/ my_file_1.md my_file_2.md fancy-third-file.md
Every page needs to contain a few meta-data at the beginning of the document.
For example content of fancy-third-file.md
:
$ cat /var/www/storage/my_pages/fancy-third-file.md
title: I'm the fancy third file! url: /fancy-third/ author: John Doe === # Example Markdown Page As you can see .. this is markdown
/** @var \basteyy\StaticMarkdownPage\Archive $staticPages */ $staticPages = new \basteyy\StaticMarkdownPage\Archive('/var/www/storage/my_pages/');
To get the fancy-third-file, you need to pass the url to getByUrl-Method:
/** @var \basteyy\StaticMarkdownPage\Archive $staticPages */ /** @var \basteyy\StaticMarkdownPage\Page $page */ $page = $staticPages->getByUrl('/fancy-third/');
Now you can print the file:
/** @var \basteyy\StaticMarkdownPage\Archive $staticPages */ /** @var \basteyy\StaticMarkdownPage\Page $page */ echo $page->getHtml();
That's it.