diff --git a/packages/crypto-frontmatter/index.ts b/packages/crypto-frontmatter/index.ts index a37975920..dfcac2f01 100644 --- a/packages/crypto-frontmatter/index.ts +++ b/packages/crypto-frontmatter/index.ts @@ -9,7 +9,7 @@ export interface FrontmatterLink { export interface FrontmatterImage { type: string; - mine: string; + mime: string; size: { width: number; height: number; diff --git a/packages/crypto-frontmatter/index.unit.ts b/packages/crypto-frontmatter/index.unit.ts index a18855ef2..3c8492023 100644 --- a/packages/crypto-frontmatter/index.unit.ts +++ b/packages/crypto-frontmatter/index.unit.ts @@ -36,8 +36,8 @@ it('should getFrontmatter of eip155:1/erc20:0x00000000008943c65cAf789FFFCF953bE1 ], images: [ { - type: 'logo', - mine: 'image/png', + type: 'icon', + mime: 'image/png', size: { width: 512, height: 512, diff --git a/website/app/[caip2]/[slug]/AssetPage.tsx b/website/app/[caip2]/[slug]/AssetPage.tsx index cbc01ff47..0ba56ed5c 100644 --- a/website/app/[caip2]/[slug]/AssetPage.tsx +++ b/website/app/[caip2]/[slug]/AssetPage.tsx @@ -37,7 +37,7 @@ export async function generateMetadata(caip19: string): Promise { export async function Page(props: { caip19: string }): Promise { const frontmatter = await fetchFrontmatter(props.caip19); - const image = frontmatter.fields.images?.find((image) => image.type === 'logo'); + const image = frontmatter.fields.images?.find((image) => image.type === 'icon'); return (
diff --git a/workspace/contented-config/index.mjs b/workspace/contented-config/index.mjs index 558cbc665..9d096f583 100644 --- a/workspace/contented-config/index.mjs +++ b/workspace/contented-config/index.mjs @@ -50,30 +50,47 @@ async function generateContentHash(filePath) { * @param fileId {string} * @param namespace {string} * @param filePath {string} - * @return {Promise<[{mine: string, path: string}]>} + * @return {Promise<[{mime: string, path: string}]>} */ async function computeImageField(fileId, namespace, filePath) { const reference = filePath.replace(/\/README\.md$/, ''); - const pngLogoPath = join('frontmatter', namespace, reference, 'logo.png'); - if (existsSync(pngLogoPath) === false) { - return []; - } - const size = imageSize(pngLogoPath); + async function computeAs({ type, from, ext, mime }) { + const pngLogoPath = join('frontmatter', namespace, reference, from); + if (existsSync(pngLogoPath) === false) { + return []; + } - const imagePath = (await generateContentHash(pngLogoPath)) + '.png'; - await copyFile(pngLogoPath, join(`_${namespace}`, imagePath)); + const size = imageSize(pngLogoPath); + const imagePath = (await generateContentHash(pngLogoPath)) + ext; + await copyFile(pngLogoPath, join(`_${namespace}`, imagePath)); - return [ - { - type: 'logo', - mine: 'image/png', - size: { - width: size.width, - height: size.height, + return [ + { + type: type, + mime: mime, + size: { + width: size.width, + height: size.height, + }, + path: imagePath, }, - path: imagePath, - }, + ]; + } + + return [ + ...(await computeAs({ + type: 'icon', + from: 'logo.png', + ext: '.png', + mime: 'image/png', + })), + ...(await computeAs({ + type: 'icon', + from: 'logo.svg', + ext: '.svg', + mime: 'image/svg+xml', + })), ]; }