* Converts a Webflow CMS item to an ExternalDocument.
( item: WebflowItem, collectionId: string, collectionName: string )
| 343 | * Converts a Webflow CMS item to an ExternalDocument. |
| 344 | */ |
| 345 | function itemToDocument( |
| 346 | item: WebflowItem, |
| 347 | collectionId: string, |
| 348 | collectionName: string |
| 349 | ): ExternalDocument { |
| 350 | const plainText = itemToPlainText(item, collectionName) |
| 351 | const lastModified = item.lastUpdated || item.lastPublished || item.createdOn || '' |
| 352 | const contentHash = `webflow:${item.id}:${lastModified}` |
| 353 | const title = extractItemTitle(item) |
| 354 | const slug = (item.fieldData?.slug as string) || '' |
| 355 | |
| 356 | return { |
| 357 | externalId: `${collectionId}:${item.id}`, |
| 358 | title, |
| 359 | content: plainText, |
| 360 | mimeType: 'text/plain', |
| 361 | contentHash, |
| 362 | metadata: { |
| 363 | collectionName, |
| 364 | lastModified: item.lastUpdated || item.lastPublished || item.createdOn, |
| 365 | slug, |
| 366 | }, |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Fetches collection IDs for a site. If a specific collectionId is provided, |
no test coverage detected