abr4xas / simple-blog
A witty description goes here
Fund package maintenance!
angelcruz.dev/donate
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.7
- league/commonmark: ^2.4
- simonvomeyser/commonmark-ext-lazy-image: ^2.0
- spatie/laravel-enum: ^3.0
- spatie/laravel-package-tools: ^1.16
- torchlight/torchlight-commonmark: ^0.5.5
Requires (Dev)
- laravel/pint: ^1.11
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.6
- orchestra/testbench: ^8.9
- pestphp/pest: ^2.15
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.2
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.32
README
Installation
You can install the package via composer:
composer require abr4xas/simple-blog
You can publish and run the migrations and everything else with:
php artisan vendor:publish --provider="Abr4xas\SimpleBlog\SimpleBlogServiceProvider" --tag="simple-blog-migrations" php artisan migrate
Usage
This package uses a polymorphic relationship to associate the Items model with the model of your choice, the only thing you have to do is add the following trait: Abr4xas\SimpleBlog\Traits\HasArticle
to the model you want to use.
To create an article you need to do something like this:
$user->articles()->create([ 'title' => 'My first fake post', 'slug' => 'my-first-post', 'excerpt' => 'The excerpt of this fake post', 'body' => 'The body of this fake post', 'status' => ArticleStatus::PUBLISHED(), // ArticleStatus::DRAFT() 'file' => 'https://i.pinimg.com/originals/4f/e7/06/4fe7066d4f3aa7201e38484230fc32b3.jpg', ]);
Syntax highlighting
This package uses: Torchlight CommonMark, so, you need an api key to make it work. Follow this docs: https://torchlight.dev/docs/clients/commonmark-php
If you want to activate the copyable option to torchlight you need to do the following:
Edit your config/torchlight.php
file to include the following in the options array:
'copyable' => true,
Next, make sure to register this javascript snippet inside your app.js
file like this:
import Alpine from "alpinejs"; window.Alpine = Alpine; Alpine.data("codeBlock", () => ({ showMessage: false, copyToClipboard() { text = document.querySelector(".torchlight-copy-target").textContent; navigator.clipboard.writeText(text); // show the "copied" message for 2 seconds this.showMessage = true; setTimeout(() => (this.showMessage = false), 2000); }, })); Alpine.start();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.