core-maugli 1.2.5 → 1.2.7
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 +1 -1
- package/public/img/default/previews/autor_default.webp +0 -0
- package/public/img/default/previews/blog_default.webp +0 -0
- package/public/img/default/previews/default.webp +0 -0
- package/public/img/default/previews/product_default.webp +0 -0
- package/public/img/default/previews/project_default.webp +0 -0
- package/public/img/default/previews/rubric_default.webp +0 -0
- package/public/img/default/previews/test.webp +0 -0
- package/public/img/default/previews/test2.webp +0 -0
- package/scripts/generate-previews.js +30 -2
- package/scripts/test-package-update.js +64 -0
- package/scripts/test-version-update.js +54 -0
- package/scripts/update-components.js +80 -1
- package/scripts/upgrade-config.js +1 -1
- package/src/components/RubricCard.astro +19 -7
- package/public/tr-about-1200.webp +0 -0
- package/public/tr-about-400.webp +0 -0
- package/public/tr-about-800.webp +0 -0
- package/public/tr-about.webp +0 -0
- package/public/tr-post-1-1200.webp +0 -0
- package/public/tr-post-1-400.webp +0 -0
- package/public/tr-post-1-800.webp +0 -0
- package/public/tr-post0-1200.webp +0 -0
- package/public/tr-post0-400.webp +0 -0
- package/public/tr-post0-800.webp +0 -0
- package/public/tr-post0.webp +0 -0
- package/public/tr-prewiew.webp +0 -0
package/package.json
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -11,8 +11,11 @@ const rootDir = __dirname.includes('node_modules')
|
|
11
11
|
? path.join(__dirname, '../../..')
|
12
12
|
: path.join(__dirname, '..');
|
13
13
|
|
14
|
-
|
15
|
-
const
|
14
|
+
// Размеры для разных типов контента
|
15
|
+
const blogPreviewWidth = 400;
|
16
|
+
const blogPreviewHeight = 210;
|
17
|
+
const rubricPreviewWidth = 210; // Увеличенный размер для качества на retina дисплеях (105px * 2)
|
18
|
+
const rubricPreviewHeight = 214; // Увеличенный размер для качества на retina дисплеях (107px * 2)
|
16
19
|
|
17
20
|
// Функция для извлечения путей изображений из markdown файлов
|
18
21
|
function extractImagePaths() {
|
@@ -94,6 +97,17 @@ function extractImagePaths() {
|
|
94
97
|
addExampleImages(examplesDir);
|
95
98
|
}
|
96
99
|
|
100
|
+
// Добавляем дефолтные изображения (включая изображения рубрик)
|
101
|
+
const defaultDir = path.join(rootDir, 'public/img/default');
|
102
|
+
if (fs.existsSync(defaultDir)) {
|
103
|
+
const items = fs.readdirSync(defaultDir);
|
104
|
+
for (const item of items) {
|
105
|
+
if (item.match(/\.(webp|jpg|jpeg|png)$/i)) {
|
106
|
+
imagePaths.add(`/img/default/${item}`);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
97
111
|
return Array.from(imagePaths);
|
98
112
|
}
|
99
113
|
|
@@ -138,6 +152,20 @@ async function createPreview(imagePath) {
|
|
138
152
|
const name = path.basename(fullImagePath, ext);
|
139
153
|
const previewPath = path.join(dir, 'previews', `${name}${ext}`);
|
140
154
|
|
155
|
+
// Определяем размер превью в зависимости от типа изображения
|
156
|
+
let previewWidth, previewHeight;
|
157
|
+
if (imagePath.includes('/img/default/') && (name.includes('rubric') || name.includes('tag'))) {
|
158
|
+
// Для изображений рубрик используем меньший размер
|
159
|
+
previewWidth = rubricPreviewWidth;
|
160
|
+
previewHeight = rubricPreviewHeight;
|
161
|
+
console.log(`Creating rubric preview (${previewWidth}x${previewHeight}): ${name}`);
|
162
|
+
} else {
|
163
|
+
// Для блог-постов и других изображений используем стандартный размер
|
164
|
+
previewWidth = blogPreviewWidth;
|
165
|
+
previewHeight = blogPreviewHeight;
|
166
|
+
console.log(`Creating blog preview (${previewWidth}x${previewHeight}): ${name}`);
|
167
|
+
}
|
168
|
+
|
141
169
|
// Создаем папку previews если её нет
|
142
170
|
const previewDir = path.dirname(previewPath);
|
143
171
|
if (!fs.existsSync(previewDir)) {
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import fs from 'fs/promises';
|
4
|
+
import path from 'path';
|
5
|
+
import { fileURLToPath } from 'url';
|
6
|
+
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
8
|
+
const __dirname = path.dirname(__filename);
|
9
|
+
|
10
|
+
async function testPackageJsonUpdate() {
|
11
|
+
console.log('🧪 Testing package.json version update...');
|
12
|
+
|
13
|
+
// Создаем тестовый package.json
|
14
|
+
const testPackageJson = {
|
15
|
+
"name": "test-blog",
|
16
|
+
"version": "1.0.0",
|
17
|
+
"dependencies": {
|
18
|
+
"core-maugli": "^1.2.3",
|
19
|
+
"astro": "^5.5.6"
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const testPath = path.join(__dirname, 'test-package.json');
|
24
|
+
await fs.writeFile(testPath, JSON.stringify(testPackageJson, null, 2), 'utf-8');
|
25
|
+
|
26
|
+
try {
|
27
|
+
// Получаем текущую версию из основного package.json
|
28
|
+
const packageJsonPath = path.join(__dirname, '../package.json');
|
29
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
30
|
+
const packageData = JSON.parse(packageJsonContent);
|
31
|
+
const newVersion = packageData.version;
|
32
|
+
|
33
|
+
// Читаем тестовый package.json
|
34
|
+
const testPackageContent = await fs.readFile(testPath, 'utf-8');
|
35
|
+
const testPackageData = JSON.parse(testPackageContent);
|
36
|
+
|
37
|
+
console.log(`📦 Current test dependency: core-maugli@${testPackageData.dependencies['core-maugli']}`);
|
38
|
+
console.log(`📦 New version: ${newVersion}`);
|
39
|
+
|
40
|
+
// Обновляем версию
|
41
|
+
if (testPackageData.dependencies && testPackageData.dependencies['core-maugli']) {
|
42
|
+
const currentVersion = testPackageData.dependencies['core-maugli'];
|
43
|
+
if (currentVersion !== `^${newVersion}`) {
|
44
|
+
testPackageData.dependencies['core-maugli'] = `^${newVersion}`;
|
45
|
+
|
46
|
+
await fs.writeFile(testPath, JSON.stringify(testPackageData, null, 2) + '\n', 'utf-8');
|
47
|
+
console.log(`✅ Updated dependency: ${currentVersion} → ^${newVersion}`);
|
48
|
+
} else {
|
49
|
+
console.log(`✅ Dependency already up to date: ^${newVersion}`);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
// Показываем результат
|
54
|
+
const updatedContent = await fs.readFile(testPath, 'utf-8');
|
55
|
+
console.log('\n📋 Updated test package.json:');
|
56
|
+
console.log(updatedContent);
|
57
|
+
|
58
|
+
} finally {
|
59
|
+
// Удаляем тестовый файл
|
60
|
+
await fs.unlink(testPath);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
testPackageJsonUpdate();
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
import fs from 'fs/promises';
|
4
|
+
import path from 'path';
|
5
|
+
import { fileURLToPath } from 'url';
|
6
|
+
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
8
|
+
const __dirname = path.dirname(__filename);
|
9
|
+
|
10
|
+
async function testVersionUpdate() {
|
11
|
+
console.log('🧪 Testing version update function...');
|
12
|
+
|
13
|
+
try {
|
14
|
+
// Получаем версию из package.json
|
15
|
+
const packageJsonPath = path.join(__dirname, '../package.json');
|
16
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
17
|
+
const packageData = JSON.parse(packageJsonContent);
|
18
|
+
const newVersion = packageData.version;
|
19
|
+
|
20
|
+
// Путь к конфигу
|
21
|
+
const configPath = path.join(__dirname, '../src/config/maugli.config.ts');
|
22
|
+
|
23
|
+
// Читаем конфиг
|
24
|
+
const configContent = await fs.readFile(configPath, 'utf-8');
|
25
|
+
|
26
|
+
// Ищем строку с MAUGLI_CONFIG_VERSION
|
27
|
+
const versionRegex = /export const MAUGLI_CONFIG_VERSION = ['"`]([^'"`]+)['"`];/;
|
28
|
+
const match = configContent.match(versionRegex);
|
29
|
+
|
30
|
+
if (match) {
|
31
|
+
const currentVersion = match[1];
|
32
|
+
console.log(`📦 Current config version: ${currentVersion}`);
|
33
|
+
console.log(`📦 Package version: ${newVersion}`);
|
34
|
+
|
35
|
+
if (currentVersion !== newVersion) {
|
36
|
+
const updatedContent = configContent.replace(
|
37
|
+
versionRegex,
|
38
|
+
`export const MAUGLI_CONFIG_VERSION = '${newVersion}';`
|
39
|
+
);
|
40
|
+
|
41
|
+
await fs.writeFile(configPath, updatedContent, 'utf-8');
|
42
|
+
console.log(`✅ Updated config version: ${currentVersion} → ${newVersion}`);
|
43
|
+
} else {
|
44
|
+
console.log(`✅ Config version already up to date: ${newVersion}`);
|
45
|
+
}
|
46
|
+
} else {
|
47
|
+
console.log('❌ Config version line not found');
|
48
|
+
}
|
49
|
+
} catch (error) {
|
50
|
+
console.error('❌ Test failed:', error.message);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
testVersionUpdate();
|
@@ -28,6 +28,9 @@ const FORCE_UPDATE_PATHS = [
|
|
28
28
|
'src/scripts',
|
29
29
|
'src/icons',
|
30
30
|
'src/i18n',
|
31
|
+
'scripts', // Скрипты в корне проекта (включая generate-previews.js)
|
32
|
+
'typograf-batch.js', // Отдельный файл
|
33
|
+
'resize-all.cjs', // Отдельный файл для ресайза
|
31
34
|
'public/flags',
|
32
35
|
'public/img/default'
|
33
36
|
// Исключили src/styles - может содержать пользовательские стили
|
@@ -41,9 +44,82 @@ const PRESERVE_PATHS = [
|
|
41
44
|
'package.json',
|
42
45
|
'astro.config.mjs',
|
43
46
|
'tailwind.config.js',
|
44
|
-
'tsconfig.json'
|
47
|
+
'tsconfig.json',
|
48
|
+
'scripts/custom-*' // Пользовательские скрипты с префиксом custom-
|
45
49
|
];
|
46
50
|
|
51
|
+
async function updateConfigVersion() {
|
52
|
+
try {
|
53
|
+
// Получаем версию из package.json пакета
|
54
|
+
const packageJsonPath = path.join(packageRoot, 'package.json');
|
55
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
56
|
+
const packageData = JSON.parse(packageJsonContent);
|
57
|
+
const newVersion = packageData.version;
|
58
|
+
|
59
|
+
// Путь к package.json пользователя
|
60
|
+
const userPackageJsonPath = path.join(userRoot, 'package.json');
|
61
|
+
|
62
|
+
try {
|
63
|
+
// Читаем package.json пользователя
|
64
|
+
const userPackageContent = await fs.readFile(userPackageJsonPath, 'utf-8');
|
65
|
+
const userPackageData = JSON.parse(userPackageContent);
|
66
|
+
|
67
|
+
let updated = false;
|
68
|
+
|
69
|
+
// Обновляем версию зависимости
|
70
|
+
if (userPackageData.dependencies && userPackageData.dependencies['core-maugli']) {
|
71
|
+
const currentVersion = userPackageData.dependencies['core-maugli'];
|
72
|
+
if (currentVersion !== `^${newVersion}`) {
|
73
|
+
userPackageData.dependencies['core-maugli'] = `^${newVersion}`;
|
74
|
+
updated = true;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
if (userPackageData.devDependencies && userPackageData.devDependencies['core-maugli']) {
|
79
|
+
const currentVersion = userPackageData.devDependencies['core-maugli'];
|
80
|
+
if (currentVersion !== `^${newVersion}`) {
|
81
|
+
userPackageData.devDependencies['core-maugli'] = `^${newVersion}`;
|
82
|
+
updated = true;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
// Обновляем build скрипт для включения генерации превью
|
87
|
+
if (userPackageData.scripts) {
|
88
|
+
const expectedBuildScript = "node typograf-batch.js && node scripts/generate-previews.js && node scripts/verify-assets.js && astro build";
|
89
|
+
const currentBuildScript = userPackageData.scripts.build;
|
90
|
+
|
91
|
+
// Проверяем, содержит ли build скрипт генерацию превью
|
92
|
+
if (currentBuildScript && !currentBuildScript.includes('generate-previews.js')) {
|
93
|
+
// Добавляем генерацию превью в build процесс
|
94
|
+
if (currentBuildScript.includes('astro build')) {
|
95
|
+
userPackageData.scripts.build = currentBuildScript.replace(
|
96
|
+
'astro build',
|
97
|
+
'node scripts/generate-previews.js && astro build'
|
98
|
+
);
|
99
|
+
updated = true;
|
100
|
+
console.log('📦 Added generate-previews.js to build script');
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
if (updated) {
|
106
|
+
await fs.writeFile(userPackageJsonPath, JSON.stringify(userPackageData, null, 2) + '\n', 'utf-8');
|
107
|
+
console.log(`📦 Updated package.json with version ^${newVersion}`);
|
108
|
+
} else {
|
109
|
+
console.log(`📦 Package.json already up to date`);
|
110
|
+
}
|
111
|
+
} catch (error) {
|
112
|
+
if (error.code === 'ENOENT') {
|
113
|
+
console.log('📦 User package.json not found, skipping version update');
|
114
|
+
} else {
|
115
|
+
console.warn('Warning: Could not update package.json version:', error.message);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
} catch (error) {
|
119
|
+
console.warn('Warning: Could not read package version:', error.message);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
47
123
|
async function copyDirectory(src, dest) {
|
48
124
|
try {
|
49
125
|
await fs.mkdir(dest, { recursive: true });
|
@@ -154,6 +230,9 @@ async function updateComponents() {
|
|
154
230
|
// Обрабатываем стили отдельно
|
155
231
|
await updateStyles();
|
156
232
|
|
233
|
+
// Обновляем версию в конфиге
|
234
|
+
await updateConfigVersion();
|
235
|
+
|
157
236
|
console.log(`✅ Updated ${updatedCount} component directories/files`);
|
158
237
|
}
|
159
238
|
|
@@ -93,7 +93,7 @@ async function main() {
|
|
93
93
|
const defText = await fs.readFile(defaultConfigPath, 'utf8');
|
94
94
|
const headerEnd = defText.indexOf('export const maugliConfig');
|
95
95
|
let header = defText.slice(0, headerEnd);
|
96
|
-
|
96
|
+
// Не обновляем MAUGLI_CONFIG_VERSION автоматически - только вручную при добавлении новых полей
|
97
97
|
let bracePos = defText.indexOf('{', headerEnd);
|
98
98
|
let count = 0,
|
99
99
|
i = bracePos;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
import { getFilteredCollection } from '../utils/content-loader';
|
3
2
|
import { maugliConfig } from '../config/maugli.config';
|
4
3
|
import { slugify } from '../utils/common-utils';
|
4
|
+
import { getFilteredCollection } from '../utils/content-loader';
|
5
5
|
import { getPostsByTag } from '../utils/data-utils';
|
6
6
|
import CountBadge from './CountBadge.astro';
|
7
7
|
|
@@ -89,6 +89,23 @@ const yesterday = new Date(now);
|
|
89
89
|
yesterday.setDate(now.getDate() - 1);
|
90
90
|
const isYesterday = dateObj && dateObj.toDateString() === yesterday.toDateString();
|
91
91
|
const isBrandDate = isToday || isYesterday;
|
92
|
+
|
93
|
+
// Функция для получения пути к превью изображения
|
94
|
+
function getPreviewImageSrc(imageSrc: string): string {
|
95
|
+
if (!imageSrc) return maugliConfig.defaultRubricImage;
|
96
|
+
|
97
|
+
// Проверяем, есть ли превью для этого изображения
|
98
|
+
const pathParts = imageSrc.split('/');
|
99
|
+
const fileName = pathParts.pop();
|
100
|
+
const directory = pathParts.join('/');
|
101
|
+
const previewPath = `${directory}/previews/${fileName}`;
|
102
|
+
|
103
|
+
// Возвращаем путь к превью (браузер покажет оригинал, если превью не найдено)
|
104
|
+
return previewPath;
|
105
|
+
}
|
106
|
+
|
107
|
+
const imageSrc = image?.src || maugliConfig.defaultRubricImage;
|
108
|
+
const previewImageSrc = getPreviewImageSrc(imageSrc);
|
92
109
|
---
|
93
110
|
|
94
111
|
<a href={`/tags/${slug}/`} class="block w-full">
|
@@ -97,12 +114,7 @@ const isBrandDate = isToday || isYesterday;
|
|
97
114
|
>
|
98
115
|
<!-- Левая часть: картинка и дата -->
|
99
116
|
<div class="flex flex-col items-end gap-2 w-[105px] h-[147px]">
|
100
|
-
<img
|
101
|
-
src={image?.src ? image.src : maugliConfig.defaultRubricImage}
|
102
|
-
alt={image?.alt || title}
|
103
|
-
class="w-[105px] h-[107px] object-cover rounded-custom"
|
104
|
-
loading="lazy"
|
105
|
-
/>
|
117
|
+
<img src={previewImageSrc} alt={image?.alt || title} class="w-[105px] h-[107px] object-cover rounded-custom" loading="lazy" />
|
106
118
|
<div class="flex flex-col items-end gap-1 w-[74px] h-[32px]">
|
107
119
|
<span class={`flex items-center gap-1 text-[12px] text-right ${isBrandDate ? 'text-[var(--brand-color)]' : 'text-[var(--text-muted)]'}`}>
|
108
120
|
<svg
|
Binary file
|
package/public/tr-about-400.webp
DELETED
Binary file
|
package/public/tr-about-800.webp
DELETED
Binary file
|
package/public/tr-about.webp
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
package/public/tr-post0-400.webp
DELETED
Binary file
|
package/public/tr-post0-800.webp
DELETED
Binary file
|
package/public/tr-post0.webp
DELETED
Binary file
|
package/public/tr-prewiew.webp
DELETED
Binary file
|