A Laravel package for creating a Markdown driven blog in minutes.

Overview

Static Markdown Blog

A Laravel package for generating static blog posts from Markdown files.

Sometimes, you want a blog but don't necessarily want to create a CMS to manage your posts, or maybe you don't want to add the overhead of a database. This is where Static Markdown Blog comes in. Write your posts in Markdown, directly inside your project, and they'll be served up as static HTML. Helps you to create a Markdown driven blog in minutes.

Installation

composer require danielwinning/static-markdown-blog

Add the following to your service providers array inside config/app.php:

/*
 * Package Service Providers...
 */
\DanielWinning\StaticMarkdownBlog\StaticMarkdownBlogServiceProvider::class

Publish the config and views:

php artisan vendor:publish --provider="DanielWinning\StaticMarkdownBlog\StaticMarkdownBlogServiceProvider"

Usage

After publishing the package files, you will have a new config file at config/static-markdown-blog.php. Inside this config file, note the empty posts array. This is where you'll store a reference to your posts, like so:

[ [ "title" => "My first blog post", "slug" => "my-first-blog-post", "published_at" => "2018-01-01" ] ]">
"posts" => [
    [
        "title" => "My first blog post",
        "slug" => "my-first-blog-post",
        "published_at" => "2018-01-01"
    ]
]

By default, the package will use resources/posts as the source of your posts. You can change this by publishing the config file and changing the postsPath value. The package will expect your posts to be in Markdown format. So the above example would reference resources/posts/my-first-blog-post.md.

The only required fields are:

  • title
  • slug
  • published_at

Your blog index will be served at /blog by default - posts will be served up at /blog/{slug} by default. You can change this by publishing the config file and updating the postsUrl value. Using the above example, your blog post will be served at /blog/my-first-blog-post.

Displaying Posts Elsewhere

To display posts on other pages outside of the blog index, simply get the posts and pass them to a view. Inside your controller or route definition use the getPosts method:

\DanielWinning\StaticMarkdownBlog\StaticMarkdownBlog::getPosts($limit) ]);">
return view("app.index", [
    "posts" => \DanielWinning\StaticMarkdownBlog\StaticMarkdownBlog::getPosts($limit)
]);

Then displaying them on the frontend is as simple as looping through the posts and displaying them:

{{ $post->title }}

@endforeach">
@foreach($posts as $post)
    

{{ $post->title }}

@endforeach

Pagination

As of version 1.1, the package now supports pagination, which is enabled by default. To use the pagination features in your own views, you can create a new paginator and pass it to a view:

$paginator->posts, "paginator" => $paginator ]);">
$paginator = \DanielWinning\StaticMarkdownBlog\StaticMarkdownBlog::getPaginatedPosts($limit);

return view("app.index", [
    "posts => $paginator->posts,
    "paginator" => $paginator
]);

In your view, you can then display the posts and the pagination links:

@foreach($posts as $post)

{{ $post->title }}

@endforeach
@if(config("static-markdown-blog.indexPagination") && isset($paginator) && $paginator->hasMorePages()) @include("static-markdown-blog::posts.paginator", ["paginator" => $paginator]) @endif">
@foreach($posts as $post)

{{ $post->title }}

@endforeach
@if(config("static-markdown-blog.indexPagination") && isset($paginator) && $paginator->hasMorePages()) @include("static-markdown-blog::posts.paginator", ["paginator" => $paginator]) @endif
You might also like...
Tools for creating Laravel packages
Tools for creating Laravel packages

Tools for creating Laravel packages This package contains a PackageServiceProvider that you can use in your packages to easily register config files,

A simple blog app where a user can signup , login, like a post , delete a post , edit a post. The app is built using laravel , tailwind css and postgres

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

A Laravel Admin Starter project with Page Builder, Roles, Impersonation, Analytics, Blog, News, Banners, FAQ, Testimonials and more

Laravel CMS Starter Project A Laravel CMS Starter project with AdminLTE theme and core features. Preview project here User: [email protected]

A blog system made with Laravel 📦
A blog system made with Laravel 📦

This project utilizes all the tools avaiable on Laravel 9. It has a complete auth system, the option to create posts and save static image files.

A simple artisanal command framework for creating service layer classes

Introdução Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel para manipular a estrutura da

Source code behind the Laracasts Larabit: Creating and Using Custom Blade Directives

This is the source code behind the Laracasts Larabit: Creating and Using Custom Blade Directives, and features all of the files and code available in that video.

Jumpstart your web development journey with the HALT Stack Starter Kit, a one-command solution for creating dynamic, scalable, and clean web applications.

Welcome to the HALT Stack Starter Kit! This kit is designed to help you kickstart your web development projects using the HALT Stack, a powerful combi

Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

A Laravel chat package. You can use this package to create a chat/messaging Laravel application.
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.

Chat Create a Chat application for your multiple Models Table of Contents Click to expand Introduction Installation Usage Adding the ability to partic

Releases(1.1.4)
  • 1.1.4(May 23, 2022)

  • 1.1.3(May 11, 2022)

    Minor update - added perPage as a property on StaticMarkdownBlogPaginator and displaying results per page in pagination links.

    Full Changelog: https://github.com/DanielWinning/StaticMarkdownBlog/compare/1.1.2...1.1.3

    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(May 11, 2022)

    Added hasMorePages() method to paginator. Updated index view.

    Full Changelog: https://github.com/DanielWinning/StaticMarkdownBlog/compare/1.1.1...1.1.2

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(May 11, 2022)

    Minor update - added CSS classes to pagination links for easier styling.

    Full Changelog: https://github.com/DanielWinning/StaticMarkdownBlog/compare/1.1.0...1.1.1

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(May 8, 2022)

Owner
Danny
🏗️ Laravel 🪄 Vue 🎨 Tailwind
Danny
A blog website with blog details with laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

PreshDev 3 Mar 6, 2022
Projeto de um blog chamado Blog Codar feito durante o curso PHP: Do zero a maestria, ministrado pelo Matheus Baptisti

PJ- Blog Codar Este projeto é um blog fictício. Apesar de poder ser usado como um blog real, este projeto não tem conexão com banco de dados, então es

João Pedro Sassi Granado 4 Nov 5, 2021
Source Code for 'Domain-Driven Laravel' by Jesse Griffin

Apress Source Code This repository accompanies Domain-Driven Laravel by Jesse Griffin (Apress, 2020). Download the files as a zip using the green butt

Apress 63 Dec 17, 2022
Create and manage A Domain Driven Design (DDD) in your Laravel app, simply and efficiently.

Create and manage A Domain Driven Design (DDD) in your Laravel app, simply and efficiently.

Lucas Nepomuceno 4 Jun 11, 2022
Data driven home automation.

DataWhare Whare (Māori noun) house, building, residence, dwelling, shed, hut, habitation. Data driven home automation. Collects data from various sens

Mark Zeman 9 Sep 23, 2022
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.

Webdevetc BlogEtc - Complete Laravel Blog Package Quickly add a blog with admin panel to your existing Laravel project. It has everything included (ro

WebDevEtc. 227 Dec 25, 2022
Learning Websocket by creating Custom Websocket-server package provided by Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling.

Chisty Md.Muzammel Hossain 3 Oct 25, 2022
Laravel package for creating Word documents with Eloquent ORM dependencies.

Laravel Eloquent Word This package provides an elegant way to generate Word documents with Eloquent Models. Uses PHPOffice/PHPWord package to generate

Marvin Quezon 6 Aug 5, 2022
This package should help you with creating and managing a Laravel DDD Application

This package should help you with creating and managing a Laravel DDD Application. This package is heavily inspired by "Laravel beyond CRUD" from Spatie.

J. Regner 158 Dec 25, 2022
Laravel breeze is a PHP Laravel library that provides Authentication features such as Login page , Register, Reset Password and creating all Sessions Required.

About Laravel breeze To give you a head start building your new Laravel application, we are happy to offer authentication and application starter kits

null 3 Jul 30, 2022