Skip to content

basteyy/static-markdown-pages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Static Markdown Pages

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages