import type { MapStore } from 'nanostores'; import type { SectionMap } from '~/lib/stores/pages'; import type { Page } from '~/types/actions'; export const pagesToArtifacts = (pages: { [pageName: string]: Page }, sections: MapStore): string => { return Object.keys(pages) .map((pageName) => { const page = pages[pageName]; const sectionId = page.actionIds; if (sectionId.length === 0) { return ''; } return ` ${sectionId.map((sectionId) => { const section = sections.get()[sectionId]; if (section == null) { return ''; } return ` ${section.content} `; })} `; }) .filter(Boolean) .join('\n'); };