sinri/ark-static-docs

一个使用 Ark Web 的静态文档库项目

0.2.7 2021-07-05 07:55 UTC

This package is auto-updated.

Last update: 2024-09-05 15:17:00 UTC


README

Packagist Version

composer require sinri/ark-static-docs

Ark Static Docs 是一个简单的开箱即用的库项目,用于支持文档。

使用方法

首先,将文档以 Markdown 格式准备好,并将它们放入一个目录中;允许有子目录,但每个子目录中需要一个 index.md。文件系统名称将根据简单规则转换为可读的标题:下划线 (_) 转换为空格( );

// If you give an array of ArkRequestFilter
$filters=[];
// The directory path where documents store
$docRootPath='/path/to/docs';
(new sinri\ark\StaticDocs\ArkStaticDocsService(Ark()->webService(),'/path/to/docs'))
    ->install($filters)
    // If the ArkWebService instance is shared, install is enough;
    // If this service is running independently, you may run it as a swift way. 
    ->run();

其他信息

页面渲染参考

我们使用 erusev/parsedown (版本 1.7.4) 进行 Markdown 渲染。

我们使用 github-markdown-css (版本 4.0.0) 进行 HTML 样式。

<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css'
      integrity='sha512-Oy18vBnbSJkXTndr2n6lDMO5NN31UljR8e/ICzVPrGpSud4Gkckb8yUpqhKuUNoE+o9gAb4O/rAxxw1ojyUVzg=='
      crossorigin='anonymous'/>

服务器配置参考(相关:Ark-Web)

如果你使用 Apache 来加载项目,你需要添加 .htaccess 文件并开启 allow override 选项。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

对于 Nginx,你应该使用 try_files。

server {
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
}