Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getAsset = (publicFolder, state, path) => {
// No path provided, skip
if (!path) return null;
let proxy = state.get(path) || memoizedProxies[path];
if (proxy) {
// There is already an AssetProxy in memory for this path. Use it.
return proxy;
}
// Create a new AssetProxy (for consistency) and return it.
proxy = memoizedProxies[path] = new AssetProxy(resolvePath(path, publicFolder), null, true);
return proxy;
};
export default function AssetProxy(value, fileObj, uploaded = false, asset) {
const config = store.getState().config;
this.value = value;
this.fileObj = fileObj;
this.uploaded = uploaded;
this.sha = null;
this.path =
config.get('media_folder') && !uploaded
? resolvePath(value, config.get('media_folder'))
: value;
this.public_path = !uploaded ? resolvePath(value, config.get('public_folder')) : value;
this.asset = asset;
}
collectionLabel,
viewStyle = VIEW_STYLE_LIST,
}) => {
const label = entry.get('label');
const entryData = entry.get('data');
const defaultTitle = label || entryData.get(inferedFields.titleField);
const path = `/collections/${collection.get('name')}/entries/${entry.get('slug')}`;
const summary = collection.get('summary');
const date = parseDateFromEntry(entry, collection) || null;
const identifier = entryData.get(selectIdentifier(collection));
const title = summary
? compileStringTemplate(summary, date, identifier, entryData)
: defaultTitle;
let image = entryData.get(inferedFields.imageField);
image = resolvePath(image, publicFolder);
if (image) {
image = encodeURI(image);
}
if (viewStyle === VIEW_STYLE_LIST) {
return (
{collectionLabel ? {collectionLabel} : null}
{title}
);
}
if (viewStyle === VIEW_STYLE_GRID) {
export default function AssetProxy(value, fileObj, uploaded = false, asset) {
const config = store.getState().config;
this.value = value;
this.fileObj = fileObj;
this.uploaded = uploaded;
this.sha = null;
this.path =
config.get('media_folder') && !uploaded
? resolvePath(value, config.get('media_folder'))
: value;
this.public_path = !uploaded ? resolvePath(value, config.get('public_folder')) : value;
this.asset = asset;
}