Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.04 KB

documentation.md

File metadata and controls

36 lines (27 loc) · 1.04 KB

Documentation

This package provides the discovery, parsing and rendering of documentation via CommonMark. The structure of the documentation has to adhere to https://github.com/ArkEcosystem/docs or discovery will fail.

Controller

<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use ARKEcosystem\Foundation\Documentation\Document;
use ARKEcosystem\Foundation\Documentation\DocumentView;

class ShowDocumentationController extends Controller
{
    public function __invoke(string $documentation, ?string $page = null)
    {
        return view('app.documentation', [
            'index'    => DocumentView::getIndex('docs', $documentation),
            'content'  => DocumentView::get('docs', $documentation, $page ?? 'intro'),
            'document' => Document::findBySlug($page ? "$documentation/$page" : "$documentation/intro"),
        ]);
    }
}

Route

Route::get('/docs/{documentation}/{page?}', App\Http\Controllers\ShowDocumentationController::class)
    ->name('documentation')
    ->where(['page' => '.*']);