function olivero_preprocess_html in Drupal 9
Implements hook_preprocess_HOOK() for HTML document templates.
Adds body classes if certain regions have content.
File
- core/
themes/ olivero/ olivero.theme, line 20 - Functions to support theming in the Olivero theme.
Code
function olivero_preprocess_html(&$variables) {
if (theme_get_setting('mobile_menu_all_widths') === 1) {
$variables['attributes']['class'][] = 'is-always-mobile-nav';
}
// So fonts can be preloaded from base theme in the event Olivero is used as a subtheme.
$variables['olivero_path'] = \Drupal::request()
->getBasePath() . '/' . \Drupal::service('extension.list.theme')
->getPath('olivero');
$query_string = \Drupal::state()
->get('system.css_js_query_string') ?: '0';
// Create render array with noscript tag to output non-JavaScript
// stylesheet for primary menu.
$variables['noscript_styles'] = [
'#type' => 'html_tag',
'#noscript' => TRUE,
'#tag' => 'link',
'#attributes' => [
'rel' => 'stylesheet',
'href' => $variables['olivero_path'] . '/css/components/navigation/nav-primary-no-js.css?' . $query_string,
],
];
}