function mathjax_page_attachments in MathJax: LaTeX for Drupal 8.2
Same name and namespace in other branches
- 3.0.x mathjax.module \mathjax_page_attachments()
Implements hook_page_attachments().
File
- ./
mathjax.module, line 26 - MathJax module.
Code
function mathjax_page_attachments(&$page) {
$config = Drupal::config('mathjax.settings');
// Exit if MathJax is not allowed on admin pages and we are on an admin page.
if (!$config
->get('enable_for_admin') && \Drupal::service('router.admin_context')
->isAdminRoute()) {
return;
}
$config_type = $config
->get('config_type');
if ($config_type == 1) {
$page['#attached']['drupalSettings']['mathjax'] = [
'config_type' => $config_type,
'config' => json_decode($config
->get('config_string')),
];
$page['#attached']['library'][] = 'mathjax/config';
$page['#attached']['library'][] = 'mathjax/source';
$page['#attached']['library'][] = 'mathjax/setup';
}
}