2020-04-01 11:44:39 +03:00
|
|
|
export const CMS_BRANCH_PREFIX = 'cms';
|
|
|
|
export const DEFAULT_PR_BODY = 'Automatically generated by Netlify CMS';
|
|
|
|
export const MERGE_COMMIT_MESSAGE = 'Automatically generated. Merged on Netlify CMS.';
|
|
|
|
|
2020-09-06 20:13:46 +02:00
|
|
|
const DEFAULT_NETLIFY_CMS_LABEL_PREFIX = 'netlify-cms/';
|
|
|
|
const getLabelPrefix = (labelPrefix: string) => labelPrefix || DEFAULT_NETLIFY_CMS_LABEL_PREFIX;
|
|
|
|
|
|
|
|
export const isCMSLabel = (label: string, labelPrefix: string) =>
|
|
|
|
label.startsWith(getLabelPrefix(labelPrefix));
|
|
|
|
export const labelToStatus = (label: string, labelPrefix: string) =>
|
|
|
|
label.substr(getLabelPrefix(labelPrefix).length);
|
|
|
|
export const statusToLabel = (status: string, labelPrefix: string) =>
|
|
|
|
`${getLabelPrefix(labelPrefix)}${status}`;
|
2020-04-01 11:44:39 +03:00
|
|
|
|
|
|
|
export const generateContentKey = (collectionName: string, slug: string) =>
|
|
|
|
`${collectionName}/${slug}`;
|
|
|
|
|
|
|
|
export const parseContentKey = (contentKey: string) => {
|
|
|
|
const index = contentKey.indexOf('/');
|
|
|
|
return { collection: contentKey.substr(0, index), slug: contentKey.substr(index + 1) };
|
|
|
|
};
|
|
|
|
|
|
|
|
export const contentKeyFromBranch = (branch: string) => {
|
|
|
|
return branch.substring(`${CMS_BRANCH_PREFIX}/`.length);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const branchFromContentKey = (contentKey: string) => {
|
|
|
|
return `${CMS_BRANCH_PREFIX}/${contentKey}`;
|
|
|
|
};
|