mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 16:22:59 +10:00
feat: additional work sections
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { find } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import React from 'react';
|
||||
import { validate } from 'uuid';
|
||||
@ -44,11 +45,21 @@ const sectionMap = (Section: React.FC<SectionProps>): Record<string, JSX.Element
|
||||
});
|
||||
|
||||
export const getSectionById = (id: string, Section: React.FC<SectionProps>): JSX.Element => {
|
||||
// Check if section id is a custom section (an uuid)
|
||||
if (validate(id)) {
|
||||
return <Section key={id} path={`sections.${id}`} />;
|
||||
}
|
||||
|
||||
return get(sectionMap(Section), id);
|
||||
// Check if section id is a predefined seciton in config
|
||||
const predefinedSection = get(sectionMap(Section), id);
|
||||
|
||||
if(predefinedSection) {
|
||||
return predefinedSection;
|
||||
}
|
||||
|
||||
// Other ways section should be a cloned section
|
||||
const section = find(sectionMap(Section), (element, key) => id.includes(key));
|
||||
return React.cloneElement(section!, { path: `sections.${id}` });
|
||||
};
|
||||
|
||||
export default sectionMap;
|
||||
|
||||
Reference in New Issue
Block a user