PHP code example of paulund / content-markdown

1. Go to this page and download the library: Download paulund/content-markdown library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paulund / content-markdown example snippets


'disks' => [
    'content' => [
        'driver' => 'local',
        'root' => storage_path('content'),
        'visibility' => 'private',
        'serve' => false,
        'throw' => false,
    ],
],

'database' => [
    'connection' => env('CONTENT_DATABASE_CONNECTION', 'sqlite'),
    'content_table_name' => env('CONTENT_DATABASE_TABLE', 'contents'),
    'tags_table_name' => env('TAG_DATABASE_TABLE', 'tags'),
    'content_tags_table_name' => env('CONTENT_TAGS_DATABASE_TABLE', 'content_tag'),
],

'drafts' => [
    'prefix' => '.',
],

'commonmark' => [
    'config' => [
        'heading_permalink' => [
            'html_class' => 'heading-permalink',
            'id_prefix' => 'content',
            'apply_id_to_heading' => true,
            'heading_class' => '',
            'fragment_prefix' => 'content',
            'insert' => 'after',
            'min_heading_level' => 1,
            'max_heading_level' => 6,
            'title' => 'Permalink',
            'symbol' => '#',
            'aria_hidden' => true,
        ],
    ],
],

Content::get();

Content::folder('blog')->get();

Content::latest()->limit(10)->get();

Content::slug('content-slug')->first();

Content::hasTag('blog')->get();

$content = Content::slug('content-slug')->first();
$content->populate();

echo $content->title;
echo $content->description;
echo $content->content;

Route::get('/content/{slug}', function ($slug) {
    $content = Content::slug($slug)->first();
    $content->populate();

    return response()->json($content);
})->middleware(\Paulund\ContentMarkdown\Http\Middleware\CacheResponse::class);

/*
|--------------------------------------------------------------------------
| Cache Configuration
|--------------------------------------------------------------------------
|
| Configure the Cache for your content. This is enabled by middleware
|
*/
'cache' => [
    /**
     * Enable or disable the cache
     */
    'enabled' => env('CONTENT_CACHE_ENABLED', true),
        
    /**
     * Cache store to use
     */
    'store' => env('CONTENT_CACHE_STORE', 'file'),

    /**
     * Seconds to cache the content for 3600 = 1 hour
     */
    'ttl' => env('CONTENT_CACHE_TTL', 3600),
]

CONTENT_CACHE_ENABLED=false
bash
php artisan vendor:publish --provider="Paulund\ContentMarkdown\ContentMarkdownServiceProvider"
php artisan migrate 
bash
php artisan migrate
markdown
---
title: Content Title
slug: content-slug
tags:
    - blog
    - writing
published: true
createdAt: 2022-09-03 15:00:00
---
bash
php artisan content:index