forked from orchidsoftware/orchid.software
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
102 lines (76 loc) · 2.87 KB
/
config.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
use Illuminate\Support\Str;
return [
'baseUrl' => 'http://localhost:3000',
'production' => false,
'siteName' => 'Orchid - Laravel Admin Panel',
'siteDescription' => 'A free Laravel package that abstracts standard business logic and allows code-driven rapid application development of back office applications like admin panels and dashboards.',
// Algolia DocSearch credentials
'docsearchApiKey' => '',
'docsearchIndexName' => '',
// navigation menu
'navigation' => require_once('navigation.php'),
// helpers
'isActive' => function ($page, $path) {
return Str::endsWith(trimPath($page->getPath()), trimPath($path));
},
'isActiveParent' => function ($page, $menuItem) {
if (is_object($menuItem) && $menuItem->children) {
return $menuItem->children->contains(function ($child) use ($page) {
return trimPath($page->getPath()) == trimPath($child);
});
}
},
'url' => function ($page, $path) {
return Str::startsWith($path, 'http') ? $path : '/'.trimPath($path);
},
'ahref' => function($page, $locale){
$pattern = "/$locale/";
$url = str_ireplace([
$page->baseUrl . '/ru',
$page->baseUrl . '/en',
], $pattern, $page->getUrl());
if(!Str::contains($url,$pattern)){
$url .= $pattern;
}
$url = $page->baseUrl . str_replace('//', '/', parse_url($url,PHP_URL_PATH));
return Str::finish($url, '/');
},
'editGitHub' => function($page) {
$path = trimPath($page->getPath());
if (is_dir(__DIR__ . '/source/' . $path)) {
$path .= '/index.md';
}else{
$path .= '.md';
}
return "https://github.com/orchidsoftware/orchid.software/edit/master/source/$path";
},
'icons' => function () {
return collect(scandir(Orchid\IconPack\Path::getFolder()))
->filter(function ($value){
return !($value === '.' || $value === '..');
})
->map(function ($value) {
return str_replace('.svg','', $value);
});
},
'getIcon' => function ($page, string $icon) {
if (file_exists(Orchid\IconPack\Path::getFolder() . "/$icon.svg")) {
return file_get_contents(Orchid\IconPack\Path::getFolder() . "/$icon.svg");
}
},
'getBlogItems' => function () {
if(isset($this->rssBlogItems)){
return $this->rssBlogItems;
}
try {
$lastNews = collect();
foreach (Feed::loadAtom('https://blog.orchid.software/feed.atom')->entry as $entry) {
$lastNews->push($entry);
}
return $this->rssBlogItems = $lastNews->take(3)->toArray();
} catch (\Exception $exception) {
return $this->rssBlogItems = [];
}
},
];