-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.php
68 lines (63 loc) · 2.64 KB
/
docs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
$page = 'docs';
// Gets the version list and latest version
$versionList = glob('documentation/*', GLOB_ONLYDIR);
$lastVersion = str_replace('documentation/', '', end($versionList));
// Gets the URL version
if(!empty($_GET['version']) && $_GET['version'] != 'latest'){
$version = trim(strtolower($_GET['version']));
}else{
$version = $lastVersion;
}
// Gets the URL route
if(empty($_GET['route'])){
$file = "documentation/{$version}/home.md";
}else{
$file = trim(strtolower($_GET['route']));
$file = "documentation/{$version}/{$file}.md";
}
// Gets docs content
if(!file_exists($file)) header('Location: https://gabrielsilva.dev.br/glowie/404');
$content = file_get_contents($file);
$menu = file_get_contents("documentation/{$version}/_menu.md");
$title = str_replace('# ', '', strtok($content, "\n"));
// Parses the content
require_once 'includes/lib/bootstrap.php';
$parser = new ParsedownToC([
'selectors' => ['h2', 'h3', 'h4', 'h5', 'h6'],
'url' => $_SERVER['REQUEST_URI']
]);
$content = str_replace('%%version%%', $version, $parser->text($content));
$menu = str_replace('%%version%%', $version, $parser->body($menu));
?>
<html>
<head>
<title><?=$title?> | Glowie Documentation</title>
<?php include 'includes/head.php';?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/default.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/github.min.css" id="hljs-light">
<link rel="stylesheet" disabled href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/github-dark.min.css" id="hljs-dark">
</head>
<body>
<?php include 'includes/header.php';?>
<main>
<?php include 'includes/docs-header.php';?>
<section class="docs">
<div class="container">
<div class="row">
<div class="col-12 col-lg-8 col-xl-9">
<?=$content; ?>
</div>
<div class="col-12 col-lg-4 col-xl-3 mt-4 mt-lg-0">
<div class="menu">
<?=$menu; ?>
</div>
</div>
</div>
</div>
</section>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/highlight.min.js"></script>
<?php include 'includes/footer.php'; ?>
</body>
</html>