laravel / folio

Page based routing for Laravel.
MIT License
568 stars 46 forks source link

Automatically route & render markdown files #70

Closed snellingio closed 1 year ago

snellingio commented 1 year ago

Originally from a tweet: https://twitter.com/snellingio/status/1688646569157939201?s=20

Followed up with a pitch inside the internals discord.

Putting this here as a placeholder for a PR.

Currently: To render a markdown file, you need to wrap in a .blade.php. So, to render something like a post, or a terms of service, etc, you end up needing a blade file.

pages
└── terms-of-service.blade.php

And the content would look something like

<x-layouts.app title="Terms of Service">
<x-markdown>
# Terms of Service

[...]
</x-markdown>
</x-layouts.app>

What I really want to do is just have a markdown file.

pages
└── terms-of-service.md

And the content could use YAML front matter (as is the standard in other page / routing frameworks) to pass in blade options. The actual content would go into the $slot variable as one would expect.

---
component: x-layouts.app
title: Terms of Service
---

# Terms of Service

[...]

Unsure if it would be best named as component or layout but that's all I would really need to wrap it all up.

This has a lot of benefits, from cross-platform drag and drop, to editor preview rendering!

driesvints commented 1 year ago

It seems you already sent in a PR so let's see how it goes 👍