Allow to create a style.css
file in the documentation to override some styles. #180
This commit is contained in:
parent
4d312a44e6
commit
db772b6a5e
@ -2,6 +2,11 @@ In its simplest form, a theme is an empty folder with a `config.json` file conta
|
||||
|
||||
After that, every setting is optional, but you can override everything if you'd like to.
|
||||
|
||||
> **Overriding styles**
|
||||
>
|
||||
> If you want to tweak a few styles, you can create a `style.css` file at the root of your documentation
|
||||
> directory and it will be included automatically. By doing this, you don't need to create a new theme.
|
||||
|
||||
## `config.json` options
|
||||
|
||||
Here is an example `config.json` file :
|
||||
|
@ -32,11 +32,18 @@ class DauxHelper
|
||||
*/
|
||||
protected static function getTheme(Config $config, $current_url)
|
||||
{
|
||||
static $cache = [];
|
||||
|
||||
$htmlTheme = $config->getHTML()->getTheme();
|
||||
|
||||
$theme_folder = $config->getThemesPath() . DIRECTORY_SEPARATOR . $htmlTheme;
|
||||
$theme_url = $config->getBaseUrl() . 'themes/' . $htmlTheme . '/';
|
||||
|
||||
$cache_key = "$current_url-$htmlTheme";
|
||||
if (array_key_exists($cache_key, $cache)) {
|
||||
return $cache[$cache_key];
|
||||
}
|
||||
|
||||
$theme = [];
|
||||
if (is_file($theme_folder . DIRECTORY_SEPARATOR . 'config.json')) {
|
||||
$theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . 'config.json'), true);
|
||||
@ -45,7 +52,7 @@ class DauxHelper
|
||||
}
|
||||
}
|
||||
|
||||
//Default parameters for theme
|
||||
// Default parameters for theme
|
||||
$theme += [
|
||||
'name' => $htmlTheme,
|
||||
'css' => [],
|
||||
@ -54,6 +61,7 @@ class DauxHelper
|
||||
'favicon' => '<base_url>themes/daux/img/favicon.png',
|
||||
'templates' => $theme_folder . DIRECTORY_SEPARATOR . 'templates',
|
||||
'variants' => [],
|
||||
'with_search' => $config->getHTML()->hasSearch()
|
||||
];
|
||||
|
||||
if ($config->getHTML()->hasThemeVariant()) {
|
||||
@ -77,6 +85,14 @@ class DauxHelper
|
||||
}
|
||||
}
|
||||
|
||||
if ($theme['with_search']) {
|
||||
$theme['css'][] = '<base_url>daux_libraries/search.css';
|
||||
}
|
||||
|
||||
if (is_file($config->getDocumentationDirectory() . DIRECTORY_SEPARATOR . 'style.css')) {
|
||||
$theme['css'][]= '<base_url>style.css';
|
||||
}
|
||||
|
||||
$substitutions = [
|
||||
'<local_base>' => $config->getLocalBase(),
|
||||
'<base_url>' => $current_url,
|
||||
@ -93,6 +109,8 @@ class DauxHelper
|
||||
}
|
||||
}
|
||||
|
||||
$cache[$cache_key] = $theme;
|
||||
|
||||
return $theme;
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,6 @@
|
||||
<?php foreach ($config->getTheme()->getCSS() as $css) { ?>
|
||||
<link href='<?= $css; ?>' rel='stylesheet' type='text/css'>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($config->getHTML()->hasSearch()) { ?>
|
||||
<!-- Search -->
|
||||
<link href="<?= $base_url; ?>daux_libraries/search.css" rel="stylesheet">
|
||||
<?php } ?>
|
||||
</head>
|
||||
<body class="<?= $this->section('classes'); ?>">
|
||||
<?= $this->section('content'); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user