(assetValue: unknown)
| 37 | |
| 38 | // TODO implementation can be completed/enhanced |
| 39 | function createAssetValueCode(assetValue: unknown): string | undefined { |
| 40 | if (Array.isArray(assetValue)) { |
| 41 | const arrayItemCodes = assetValue.map( |
| 42 | (item: unknown) => createAssetValueCode(item) ?? 'undefined', |
| 43 | ); |
| 44 | return `[${arrayItemCodes.join(', ')}]`; |
| 45 | } |
| 46 | // Only process string values starting with ./ |
| 47 | // We could enhance this logic and check if file exists on disc? |
| 48 | if (typeof assetValue === 'string' && assetValue.startsWith('./')) { |
| 49 | // TODO do we have other use-cases than image assets? |
| 50 | // Probably not worth adding more support, as we want to move to Webpack 5 new asset system (https://github.com/facebook/docusaurus/pull/4708) |
| 51 | return `require("${inlineMarkdownAssetImageFileLoader}${escapePath( |
| 52 | assetValue, |
| 53 | )}").default`; |
| 54 | } |
| 55 | return undefined; |
| 56 | } |
| 57 | |
| 58 | const assetEntries = Object.entries(assets); |
| 59 |
no test coverage detected
searching dependent graphs…