mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-05-07 21:03:53 -04:00
refactor(frontend): replace legacy settings init/settings pattern with typed config functions
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
import { DeepPartial, GlobalMediaCMS, MediaCMSConfig } from '../../types';
|
||||
|
||||
export function mediaConfig(
|
||||
item?: DeepPartial<GlobalMediaCMS['features']['mediaItem']>,
|
||||
shareOptions?: DeepPartial<GlobalMediaCMS['features']['media']['shareOptions']>
|
||||
) {
|
||||
const ret: MediaCMSConfig['media'] = {
|
||||
item: {
|
||||
displayAuthor: item?.hideAuthor === true ? false : true,
|
||||
displayViews: item?.hideViews === true ? false : true,
|
||||
displayPublishDate: item?.hideDate === true ? false : true,
|
||||
},
|
||||
share: { options: [] },
|
||||
};
|
||||
|
||||
if (shareOptions) {
|
||||
const validShareOptions = ['embed', 'email']; // @todo: Check this
|
||||
|
||||
for (const option of shareOptions) {
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const opt = option.trim();
|
||||
|
||||
if (validShareOptions.includes(opt)) {
|
||||
ret.share.options.push(opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user