Skip to content

Commit

Permalink
feat: add ouput processing function
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Mar 8, 2021
1 parent a62fcf3 commit 3af3fb3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const metadataOutput = (src:URL, outputMetadatas: Record<string, any>[]) => {
if(!src.searchParams.has('metadata') && !src.searchParams.has('meta')) return null

return outputMetadatas.length === 1 ? outputMetadatas[0] : outputMetadatas
}

export const srcsetOutput = (src:URL, outputMetadatas: Record<string, any>[]) => {
if(!src.searchParams.has('srcset')) return null

return outputMetadatas.length === 1 ? outputMetadatas[0] : outputMetadatas
}

export const urlOutput = (src:URL, outputMetadatas: Record<string, any>[]) => {
const out:string[] = outputMetadatas.map(metadata => metadata.src)

return out.length == 1 ? out[0] : out
}

0 comments on commit 3af3fb3

Please sign in to comment.