/** * Copyright (c) 2022 Amorphous * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { ObjectWithMeta } from '../types' /** * Pulls out ids and classes of an object. * Modifies in place, so does not return anything. * @param obj */ export const exposeMeta = (obj: ObjectWithMeta): void => { if (!obj.meta) { return } // pull out id and classes if (obj.meta.id) { obj.id = obj.meta.id } if (obj.meta.classes) { obj.classes = obj.meta.classes } if (obj.id) { obj.primary = obj.id } else if (obj.classes && obj.classes.length) { obj.primary = obj.classes[0] } if (obj.meta.title) { obj.title = obj.meta.title } }