← back to Dw Sarah Rowland Searchfix
apply-bio.mjs
18 lines
import { gql } from './lib.mjs'; import fs from 'node:fs';
const bio=fs.readFileSync(new URL('./coll-backups/sarah-rowland.body.BEFORE.html',import.meta.url),'utf8').trim();
let cdn=fs.readFileSync(new URL('./asset-url.txt',import.meta.url),'utf8').trim();
const imgSrc=cdn+(cdn.includes('?')?'&':'?')+'width=600';
const block=`<div class="dw-designer-bio" style="display:flex;gap:28px;align-items:flex-start;flex-wrap:wrap;margin:0 0 8px;">
<img src="${imgSrc}" alt="Sarah Rowland, wallcovering and textile designer" width="200" style="width:200px;height:auto;border-radius:8px;flex:0 0 auto;" loading="lazy">
<div style="flex:1 1 300px;min-width:260px;">
<h2 style="margin:0 0 2px;font-size:1.35rem;letter-spacing:.02em;">Sarah Rowland</h2>
<p style="margin:0 0 14px;font-style:italic;color:#777;">Wallcovering & Textile Designer · Richmond, Virginia</p>
${bio}
</div>
</div>`;
fs.writeFileSync(new URL('./coll-backups/sarah-rowland.body.AFTER.html',import.meta.url), block);
const M=`mutation($id:ID!,$html:String!){ collectionUpdate(input:{id:$id, descriptionHtml:$html}){ collection{ id } userErrors{ field message } } }`;
const d=await gql(M,{id:'gid://shopify/Collection/291337273395', html:block});
const ue=d.collectionUpdate.userErrors;
console.log(ue.length?('userErrors: '+JSON.stringify(ue)):'✓ collection description updated');