This commit is contained in:
lovebird 2025-03-17 14:12:34 +01:00
parent aa2c459861
commit c1c5d84a9f
3 changed files with 31 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
export default {
"environment": "build",
"environment": "dev",
"isSsrBuild": false,
"projectBase": "",
"publicDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\public\\",
"rootDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\",
"mode": "production",
"outDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\dist\\",
"assetsDir": "_astro",
"mode": "dev",
"outDir": "dist",
"assetsDir": "/_astro",
"sourcemap": false,
"assetFileNames": "/_astro/[name]@[width].[hash][extname]"
}

View File

@ -10,14 +10,18 @@ import { resolve } from '@polymech/commons'
import { files } from '@polymech/commons'
import { sync as exists } from '@polymech/fs/exists'
import { sync as read } from '@polymech/fs/read'
import { sync as mv } from '@polymech/fs/move'
import { logger } from '@/base/index.js'
import { removeArrayValues, removeArrays, removeBufferValues, removeEmptyObjects } from '@/base/objects.js'
import { ITEM_ASSET_URL, PRODUCT_CONFIG, PRODUCT_ROOT, DEFAULT_IMAGE_URL } from '../app/config.js'
import { GalleryImage, MetaJSON } from './images.js'
import { validateFilename, sanitizeFilename } from "@polymech/fs/utils"
import { env } from './index.js'
const IMAGES_GLOB = '*.+(JPG|jpg|png|PNG|gif)'
const IMAGES_GLOB = '*.+(JPG|jpg|jpeg|png|PNG|gif)'
export const default_sort = (files: string[]): string[] => {
const getSortableParts = (filename: string) => {
@ -27,8 +31,7 @@ export const default_sort = (files: string[]): string[] => {
const textPart = match ? match[2] : baseName; // Extract text part
return { numPart, textPart };
};
}
return files.sort((a, b) => {
const { numPart: aNum, textPart: aText } = getSortableParts(a)
const { numPart: bNum, textPart: bText } = getSortableParts(b)
@ -36,8 +39,28 @@ export const default_sort = (files: string[]): string[] => {
return aNum - bNum || aText.localeCompare(bText, undefined, { numeric: true, sensitivity: 'base' })
}
return aText.localeCompare(bText, undefined, { numeric: true, sensitivity: 'base' })
})
}
export const default_sanitize = (paths: string[]): string[] =>{
return paths.map((filePath) => {
const dir = path.dirname(filePath);
const originalFilename = path.basename(filePath);
const sanitizedFilename = sanitizeFilename(originalFilename, { lowercase: false, whitespace: true });
if (originalFilename === sanitizedFilename) {
return filePath;
}
const newPath = path.join(dir, sanitizedFilename);
try {
mv(filePath, newPath);
return newPath;
} catch (error) {
return filePath; // Return the original path in case of failure
}
});
}
export const default_filter = async (url: string) => {
try {
const response = await fetch(url, { method: 'HEAD' })