core-maugli 1.2.17 → 1.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "core-maugli",
3
3
  "description": "Astro & Tailwind CSS blog theme for Maugli.",
4
4
  "type": "module",
5
- "version": "1.2.17",
5
+ "version": "1.2.18",
6
6
  "license": "GPL-3.0-or-later OR Commercial",
7
7
  "repository": {
8
8
  "type": "git",
@@ -81,7 +81,7 @@ const content = excerpt || description;
81
81
  <!-- Изображение -->
82
82
  <div class="w-full aspect-[1200/630] bg-[var(--bg-muted)] overflow-hidden relative">
83
83
  <img
84
- src={cardImage.src}
84
+ src={finalImage}
85
85
  srcset={cardImage.srcset}
86
86
  sizes={cardImage.sizes}
87
87
  alt={cardImageAlt}
@@ -1,5 +1,9 @@
1
1
  ---
2
2
  // src/components/HeroImage.astro
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
3
7
  export interface Props {
4
8
  src: string;
5
9
  alt?: string;
@@ -9,11 +13,12 @@ export interface Props {
9
13
  className?: string;
10
14
  srcset?: string;
11
15
  }
12
- const defaultWidth = 800;
13
- const { src, alt = '', caption, width = defaultWidth, height, className = '', srcset = '' } = Astro.props;
16
+ const defaultWidth = 1200;
17
+ const defaultHeight = 630;
18
+ const { src, alt = '', caption, width = defaultWidth, height = defaultHeight, className = '', srcset = '' } = Astro.props;
14
19
 
15
- // Вариант aspect-ratio: если есть оба размера, рассчитываем; иначе не пишем!
16
- const aspectRatio = width && height ? `${width} / ${height}` : undefined;
20
+ // Фиксированные пропорции 1200:630
21
+ const aspectRatio = '1200 / 630';
17
22
 
18
23
  // Генерируем адаптивные версии изображений
19
24
  function getResponsiveImages(imagePath: string) {
@@ -39,17 +44,33 @@ if (srcset) {
39
44
  // Генерируем адаптивные изображения
40
45
  imageData = getResponsiveImages(src);
41
46
  }
47
+
48
+ // Используем уменьшенное превью, если оно существует
49
+ let previewImage;
50
+ if (imageData.src) {
51
+ previewImage = imageData.src.replace(/\/([^\/]+)$/, '/previews/$1');
52
+
53
+ const __filename = fileURLToPath(import.meta.url);
54
+ const projectRoot = path.resolve(path.dirname(__filename), '../..');
55
+ const previewFilePath = path.join(projectRoot, 'public', previewImage.replace(/^\//, ''));
56
+
57
+ if (!fs.existsSync(previewFilePath)) {
58
+ previewImage = undefined;
59
+ }
60
+ }
61
+
62
+ const finalImage = previewImage || imageData.src;
42
63
  ---
43
64
 
44
65
  <figure class={`w-full max-w-[${width}px] mx-auto rounded-custom overflow-hidden bg-[var(--bg-muted)] ${className}`}>
45
66
  <img
46
- src={imageData.src}
67
+ src={finalImage}
47
68
  srcset={imageData.srcset}
48
69
  sizes={imageData.sizes}
49
70
  alt={alt}
50
71
  width={width}
51
72
  height={height}
52
- style={aspectRatio ? `aspect-ratio: ${aspectRatio}; width: 100%; height: auto;` : 'width: 100%; height: auto;'}
73
+ style={`aspect-ratio: ${aspectRatio}; width: 100%; height: auto;`}
53
74
  class="block rounded-custom object-cover"
54
75
  loading="eager"
55
76
  decoding="async"