25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
|
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.';
|
||
|
|
||
|
const NETLIFY_CMS_LABEL_PREFIX = 'netlify-cms/';
|
||
|
export const isCMSLabel = (label: string) => label.startsWith(NETLIFY_CMS_LABEL_PREFIX);
|
||
|
export const labelToStatus = (label: string) => label.substr(NETLIFY_CMS_LABEL_PREFIX.length);
|
||
|
export const statusToLabel = (status: string) => `${NETLIFY_CMS_LABEL_PREFIX}${status}`;
|
||
|
|
||
|
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}`;
|
||
|
};
|