Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my-theme/js/my-script.js
- my-library:
- js:
- js/my-script.js: {}
- name: my-theme
- type: theme
- description: my theme
- package: other
- core: 8.x
- libraries:
- - my-theme/global-effects
- - my-theme/my-library
- base theme: stable
- function mytheme_page_attachments_alter(&$page){
- $path = $current_path = Drupal::service('path.current')->getPath();
- if($path == '/node') {
- $page['#attached']['library'][] = 'my-theme/my-library';
- }
- }
- function mytheme_preprocess_page(&$variables){
- if ($variables['is_front'] == TRUE) {
- $variables['#attached']['library'][] = 'my-theme/my-library';
- }
- }
- {% if node.id == 1 %}
- {{ attach_library('my-theme/my-library') }}
- {% endif %}
Add Comment
Please, Sign In to add comment