refactor: convert function expressions to declarations (#4926)
This commit is contained in:
committed by
GitHub
parent
c0236536dd
commit
141a2eba56
@ -3,27 +3,36 @@ export const DEFAULT_PR_BODY = 'Automatically generated by Netlify CMS';
|
||||
export const MERGE_COMMIT_MESSAGE = 'Automatically generated. Merged on Netlify CMS.';
|
||||
|
||||
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}`;
|
||||
function getLabelPrefix(labelPrefix: string) {
|
||||
return labelPrefix || DEFAULT_NETLIFY_CMS_LABEL_PREFIX;
|
||||
}
|
||||
|
||||
export const generateContentKey = (collectionName: string, slug: string) =>
|
||||
`${collectionName}/${slug}`;
|
||||
export function isCMSLabel(label: string, labelPrefix: string) {
|
||||
return label.startsWith(getLabelPrefix(labelPrefix));
|
||||
}
|
||||
|
||||
export const parseContentKey = (contentKey: string) => {
|
||||
export function labelToStatus(label: string, labelPrefix: string) {
|
||||
return label.substr(getLabelPrefix(labelPrefix).length);
|
||||
}
|
||||
|
||||
export function statusToLabel(status: string, labelPrefix: string) {
|
||||
return `${getLabelPrefix(labelPrefix)}${status}`;
|
||||
}
|
||||
|
||||
export function generateContentKey(collectionName: string, slug: string) {
|
||||
return `${collectionName}/${slug}`;
|
||||
}
|
||||
|
||||
export function parseContentKey(contentKey: string) {
|
||||
const index = contentKey.indexOf('/');
|
||||
return { collection: contentKey.substr(0, index), slug: contentKey.substr(index + 1) };
|
||||
};
|
||||
}
|
||||
|
||||
export const contentKeyFromBranch = (branch: string) => {
|
||||
export function contentKeyFromBranch(branch: string) {
|
||||
return branch.substring(`${CMS_BRANCH_PREFIX}/`.length);
|
||||
};
|
||||
}
|
||||
|
||||
export const branchFromContentKey = (contentKey: string) => {
|
||||
export function branchFromContentKey(contentKey: string) {
|
||||
return `${CMS_BRANCH_PREFIX}/${contentKey}`;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user