本文最后更新于 414 天前,其中的信息可能已经有所发展或是发生改变。
上周作业…时间太紧了就随手做了个…
用 Parsedown 解析md达到的…(自行去官网下载Parsedown.php才能食用哦)
目录和文章需要手动建立…
demo:(完全没有小屏幕适配)
Source:
<!doctype html>
<html>
<head>
<title>Simple Blog</title>
<link href="//cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<div class="container-fluid">
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
<nav class="my-0 mr-md-auto font-weight-normal">
<a class="p-2 text-dark" href="index.php">首页</a>
<a class="p-2 text-dark" href="index.php?list">目录</a>
</nav>
<h5 class="my-2 my-md-0 mr-md-3">博客</h5>
</div>
</div>
<div style="width: 90%; max-width: 800px; margin: 0 auto;">
<?php
header("content-type:text/html;charset=utf-8");
require_once('Parsedown.php');
function output($passage)
{
if(file_exists($passage)){
$fp = fopen($passage,"r");
$text = fread($fp,filesize($passage));
fclose($fp);
$result = Parsedown::instance()->parse($text);
echo $result;
}
else echo '<div style="margin-top:170px;"><h2>Sorry , 文章不存在</h2></div>';
}
if(isset($_GET['p']))output($_GET['p'].".md");
else if(isset($_GET['list']))output('list.md');
else echo '<div style="margin-top:170px;"><h2>这是个博客...</h2><br><br><br><h4>嗯,这是个博客</h4><br><br><h5>文章看目录8</h5></div>';
?>
</div>
</html>