From 544a236233c0bf3e8f48592769a7facb9bdab95c Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 22 Sep 2022 02:19:48 +0100 Subject: [PATCH] feat: home optimization - prevent avatars and banners rerendering --- src/models/site.model.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/models/site.model.ts b/src/models/site.model.ts index 21453b4e..2f5685a9 100644 --- a/src/models/site.model.ts +++ b/src/models/site.model.ts @@ -1,9 +1,8 @@ import { SiteNavigationItem, Profile } from "~/lib/types" import { nanoid } from "nanoid" -import { checkReservedWords } from "~/lib/reserved-words" import unidata from "~/lib/unidata" -import { indexer, getContract } from "~/lib/crossbell" import { renderPageContent } from "~/markdown" +import { toGateway } from "~/lib/ipfs-parser" export const checkSubdomain = async ({ subdomain, @@ -59,6 +58,16 @@ const expandSite = async (site: Profile) => { site.name = site.name || site.username site.description = (await renderPageContent(site.bio || "")).contentHTML + if (site.avatars) { + site.avatars = site.avatars.map((avatar) => toGateway(avatar)) + } + if (site.banners) { + site.banners.map((banner) => { + banner.address = toGateway(banner.address) + return banner + }) + } + return site }