fixed typographic traitment, moved js alog to header defer script for speed, no more flickering
This commit is contained in:
@@ -12,8 +12,29 @@ function leshed_page_attachments_alter(&$page) {
|
||||
// $attachments['#attached']['html_head'][] = [['src' => 'http://localhost:5173/assets/js/main.js', 'type' => 'module'],'vite-main'];
|
||||
// $page['#attached']['library'][] = 'http://localhost:5173/assets/js/main.js';
|
||||
$page['#attached']['library'][] = 'leshed/vitehmr';
|
||||
$page['#attached']['library'][] = 'leshed/titles_hmr';
|
||||
}else{
|
||||
$page['#attached']['library'][] = 'leshed/global';
|
||||
$page['#attached']['library'][] = 'leshed/titles';
|
||||
|
||||
// Must match exactly the url() resolved from assets/dist/main.css, or the
|
||||
// font is downloaded twice.
|
||||
$fonts_path = base_path() . \Drupal::service('extension.list.theme')->getPath('leshed') . '/assets/dist/fonts/';
|
||||
foreach (['Epilogue-VariableFont_wght.ttf', 'Epilogue-Italic-VariableFont_wght.ttf'] as $font) {
|
||||
$page['#attached']['html_head'][] = [
|
||||
[
|
||||
'#tag' => 'link',
|
||||
'#attributes' => [
|
||||
'rel' => 'preload',
|
||||
'href' => $fonts_path . $font,
|
||||
'as' => 'font',
|
||||
'type' => 'font/ttf',
|
||||
'crossorigin' => 'anonymous',
|
||||
],
|
||||
],
|
||||
'leshed_preload_' . $font,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user