You are here

function mathjax_library_info_build in MathJax: LaTeX for Drupal 8.2

Same name and namespace in other branches
  1. 3.0.x mathjax.module \mathjax_library_info_build()

Implements hook_library_info_build().

File

./mathjax.module, line 49
MathJax module.

Code

function mathjax_library_info_build() {
  $config = Drupal::config('mathjax.settings');
  $libraries = [];
  $libraries['source'] = [
    'dependencies' => [
      'mathjax/config',
    ],
    'remote' => 'https://www.mathjax.org/',
    'license' => [
      'name' => 'Apache',
      'url' => 'http://cdn.mathjax.org/mathjax/2.0-latest/LICENSE',
      'gpl-compatible' => TRUE,
    ],
  ];
  if ($config
    ->get('use_cdn') == FALSE) {
    $libraries['source']['js'] = [
      \Drupal::request()
        ->getBaseUrl() . '/libraries/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML' => [
        'type' => 'external',
        'minified' => TRUE,
      ],
    ];
  }
  else {
    $libraries['source']['js'] = [
      $config
        ->get('cdn_url') => [
        'type' => 'external',
        'minified' => TRUE,
      ],
    ];
  }
  return $libraries;
}