Blurring the lines between Blade and Markdown
This package is currently a proof of concept, and is not even remotely ready for production use.
You can install the package via Composer:
composer require hyde/bladedown
This package adds a new "Bladematter" page type using .blade.md
, which is a combination of Blade and Markdown. This allows you to use Blade directives in your Markdown files.
---
name: World
---
# Hello, {{ $name }}!
<x-header image="media/my-image.png">
<x-slot name="title">
Lorem Ipsum
</x-slot>
Lorem ipsum dolor sit amet
</x-header>
## More stuff
Lorem ipsum dolor sit amet.
@include('related-posts')
@push('footer')
<script src="https://example.com/script.js"></script>
@endpush
We currently support the following subset of components.
As you can see, dynamic features like conditionals and loops are not supported. This is because those kinds of things can quickly get complex, and it's more maintainable to keep that logic in dedicated component files. Instead, the idea with this package is that you can easily include those components, and pass in the data you need.
All front matter properties are available as variables in the Bladedown file.
---
name: World
---
# Hello, {{ $name }}! <!-- World -->
@include('related-posts')
@include('related-posts', ['limit' => 5])
@component('faq-item')
@slot('question') How do I get started? @endslot
@slot('answer') Check our detailed documentation for step-by-step instructions. @endslot
@endcomponent
@component('faq-item')
@slot('question') Can I customize the appearance? @endslot
@slot('answer') Yes, the styles are easily customizable to fit your design. @endslot
@endcomponent
<x-news-banner />
<x-news-banner message="New package released!" />
<x-feature-card image="media/feature-image.png">
<x-slot name="title">Exciting Feature</x-slot>
<p>This feature allows you to do incredible things!</p>
</x-feature-card>
The push directive allows you to push to any stack in your layout. Perfect if you need to add a script or style for a specific page.
@push('header')
## My header
@endpush
@push('footer')
<script>
console.log('Hello, World!');
</script>
@endpush
Note that only @push
is supported and not similar ones like @prepend
or conditional pushes.
Contributions are welcome. Please see the hydephp/develop monorepo for details.
Remember that this package by design allows you to execute any arbitrary PHP code, regardless of the default HydePHP Markdown security settings.
The package assumes that you trust the authors of the Bladedown files, and take the same care as you would with any other PHP file in your project.
Please review the security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.