fix: broken json (#66)

* fix: fix broken json error. saving the description correctly

* fix: fix pr review comments

* fix: fix text display when theres no breakline

* fix: fix break lines text on details view. Move the \n replacing to the lib
This commit is contained in:
Camila Sosa Morales 2023-01-09 17:01:38 -05:00 committed by GitHub
parent 23dc080c7a
commit 99155edf2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -10,7 +10,7 @@ export const FleekERC721 = {
const response = await contract.mint(
params.owner,
params.name,
params.description,
params.description.replaceAll(/\n/g, '\\n'), //replace break lines with \\n so it doesn't break the json,
params.image,
params.externalUrl,
params.ens,
@ -27,7 +27,9 @@ export const FleekERC721 = {
const response = await contract.tokenURI(Number(tokenId));
const parsed = JSON.parse(
Buffer.from(response.slice(29), 'base64').toString('utf-8')
Buffer.from(response.slice(29), 'base64')
.toString('utf-8')
.replaceAll(/\n/g, '\\n') // replace escaped newlines
);
return parsed;
@ -35,7 +37,7 @@ export const FleekERC721 = {
async lastTokenId(): Promise<number> {
// TODO: fetch last token id
return 6;
return 7;
},
};

View File

@ -69,7 +69,15 @@ export const MintedSiteDetail = () => {
heading="Description"
minH={120}
maxH="auto"
children={<p>{description}</p>}
children={
<p
style={{
whiteSpace: 'pre-line',
}}
>
{description}
</p>
}
/>
<AccordionItem
heading="Attributes"