How to use the netlify-cms-lib-util.resolvePath function in netlify-cms-lib-util

To help you get started, we’ve selected a few netlify-cms-lib-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netlify / netlify-cms / packages / netlify-cms-core / src / reducers / medias.js View on Github external
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;
};
github netlify / netlify-cms / packages / netlify-cms-core / src / valueObjects / AssetProxy.js View on Github external
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;
}
github netlify / netlify-cms / packages / netlify-cms-core / src / components / Collection / Entries / EntryCard.js View on Github external
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) {
github netlify / netlify-cms / packages / netlify-cms-core / src / valueObjects / AssetProxy.js View on Github external
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;
}