michalsn / codeigniter-markdown-pages
Markdown pages for CodeIgniter 4 framework
Installs: 1 865
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 5
Forks: 1
Open Issues: 1
Requires
- php: ^8.1
- mnapoli/front-yaml: ^2.0
- myth/collection: dev-master
Requires (Dev)
- codeigniter4/devkit: ^1.0
- codeigniter4/framework: ^4.1
This package is auto-updated.
Last update: 2024-10-18 03:04:23 UTC
README
Markdown based pages for the CodeIgniter 4 framework.
Installation
composer require michalsn/codeigniter-markdown-pages
Basic usage
To easily demonstrate how the things are working we will assume for a moment that this is our folder structure.
├── app ├── content │ ├── 1_quick-start │ │ ├── 1_installation.md │ │ ├── 2_database-migration.md │ │ ├── what-next.md │ │ └── subfolder │ │ └── one-file.md │ └── first-steps │ ├── available-methods.md │ └── how-to-use-this.md ├── public ├── tests ├── vendor └── writable
Now we have to initialize Markdown Pages with our folder:
$markdownPages = services('markdownpages', ROOTPATH . 'content'); $dir = $markdownPages->dirs()->first(); echo $dir->getName() // prints: Quick Start echo $dir->getSlug() // prints: quick-start foreach($dir->getFiles()->items() as $file) { echo $file->getName(); // prints: Installation echo $file->getSlug(); // prints: installation echo $file->getPath(); // prints: quick-start/installation echo $content->parse()->getContent(); // prints: parsed markdown from file echo $content->parse()->getMeta(); // prints: parsed YAML as key -> value }
We use Collection class pretty much everywhere so please get familiar with it to use this package comfortably.