core-maugli 1.2.16 → 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.16",
5
+ "version": "1.2.18",
6
6
  "license": "GPL-3.0-or-later OR Commercial",
7
7
  "repository": {
8
8
  "type": "git",
@@ -52,8 +52,8 @@ const cardImageAlt = seo?.image?.alt || image?.alt || title || 'Изображе
52
52
 
53
53
  // Используем уменьшенное превью, если оно существует
54
54
  let previewImage;
55
- if (cardImage) {
56
- previewImage = cardImage.replace(/\/([^\/]+)$/, '/previews/$1');
55
+ if (cardImage.src) {
56
+ previewImage = cardImage.src.replace(/\/([^\/]+)$/, '/previews/$1');
57
57
 
58
58
  const __filename = fileURLToPath(import.meta.url);
59
59
  const projectRoot = path.resolve(path.dirname(__filename), '../..');
@@ -64,7 +64,7 @@ if (cardImage) {
64
64
  }
65
65
  }
66
66
 
67
- const finalImage = previewImage || cardImage;
67
+ const finalImage = previewImage || cardImage.src;
68
68
 
69
69
  // Определяем контент для отображения
70
70
  const content = excerpt || description;
@@ -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"
@@ -194,23 +194,18 @@ if (import.meta.env.DEV) {
194
194
  class={`w-full h-[195px] border border-[var(--border-main)] rounded-custom card-bg hover:card-shadow hover:-translate-y-1 transition-all duration-300 p-6 flex flex-row gap-4 items-start ${className}`}
195
195
  >
196
196
  <!-- Левая часть: картинка и дата -->
197
- <<<<<<< HEAD
198
- <div class="flex flex-col items-end gap-2 w-[105px] h-[147px]">
199
- <img src={previewImageSrc} alt={image?.alt || title} class="w-[105px] h-[107px] object-cover rounded-custom" loading="lazy" decoding="async" />
200
- =======
201
- <div class="flex flex-col items-end gap-2 w-[105px] h-[147px] relative">
202
- <img src={previewImageSrc} alt={title} class="w-[105px] h-[107px] object-cover rounded-custom" loading="lazy" />
203
- {
204
- rubricInitials && (
205
- <span style="position:absolute;left:0;top:0;width:105px;height:107px;display:flex;align-items:center;justify-content:center;pointer-events:none;z-index:2;">
206
- <span style="position:absolute;left:0;top:0;width:105px;height:107px;background:rgba(0,0,0,0.10);border-radius:inherit;z-index:1;" />
207
- <span style="position:relative;z-index:2;font-size:48px;font-weight:700;font-family:inherit;color:var(--brand-color);letter-spacing:2px;">
208
- {rubricInitials}
209
- </span>
197
+ <div class="flex flex-col items-end gap-2 w-[105px] h-[147px] relative">
198
+ <img src={previewImageSrc} alt={title} class="w-[105px] h-[107px] object-cover rounded-custom" loading="lazy" />
199
+ {
200
+ rubricInitials && (
201
+ <span style="position:absolute;left:0;top:0;width:105px;height:107px;display:flex;align-items:center;justify-content:center;pointer-events:none;z-index:2;">
202
+ <span style="position:absolute;left:0;top:0;width:105px;height:107px;background:rgba(0,0,0,0.10);border-radius:inherit;z-index:1;" />
203
+ <span style="position:relative;z-index:2;font-size:48px;font-weight:700;font-family:inherit;color:var(--brand-color);letter-spacing:2px;">
204
+ {rubricInitials}
210
205
  </span>
211
- )
212
- }
213
- >>>>>>> 41e6ca2 (fix: always use default rubric image from config, initials overlay, preview logic)
206
+ </span>
207
+ )
208
+ }
214
209
  <div class="flex flex-col items-end gap-1 w-[74px] h-[32px]">
215
210
  <span class={`flex items-center gap-1 text-[12px] text-right ${isBrandDate ? 'text-[var(--brand-color)]' : 'text-[var(--text-muted)]'}`}>
216
211
  <svg