feat: scaffold mvp shell and content runtime
This commit is contained in:
24
js/content/validation/validate-assets.js
Normal file
24
js/content/validation/validate-assets.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export function validateAssets(city, assetExists) {
|
||||
const errors = []
|
||||
const warnings = []
|
||||
|
||||
if (typeof assetExists !== 'function') {
|
||||
return { errors, warnings }
|
||||
}
|
||||
|
||||
const assetPaths = [
|
||||
city.cover?.catImage,
|
||||
city.cover?.catThumb,
|
||||
...(city.elements ?? []).map((element) => element.image),
|
||||
].filter(Boolean)
|
||||
|
||||
for (const assetPath of assetPaths) {
|
||||
if (!assetExists(assetPath)) {
|
||||
errors.push(`City "${city.id}" asset is missing: ${assetPath}`)
|
||||
}
|
||||
}
|
||||
|
||||
return { errors, warnings }
|
||||
}
|
||||
|
||||
export default validateAssets
|
||||
Reference in New Issue
Block a user