--- // میری لائبریری: the reader's saved poets and works, bookmarked couplets and saved words, // each with its full path in the site (poet » book » section » work) and a link to the couplet import Base from '../layouts/Base.astro'; import { asUser, COOKIE } from '../lib/auth'; import { ud } from '../lib/urdu'; import { phraseParts, phraseRe } from '../lib/phrases'; const me = Astro.locals.user; if (!me) return Astro.redirect('/signin?next=/library'); const token = Astro.cookies.get(COOKIE)!.value; if (Astro.request.method === 'POST') { const f = await Astro.request.formData(), id = Number(f.get('id')) || 0; if (f.get('act') === 'delete') await asUser(token, `/api/library/${id}/delete`, {}); if (f.get('act') === 'note') await asUser(token, `/api/library/${id}/note`, { note: f.get('note') }); return Astro.redirect(`/library#i${id}`, 303); } const lib = (await asUser(token, '/api/library')).data; const total = lib.poets.length + lib.poems.length + lib.couplets.length + lib.phrases.length + lib.words.length; // a bookmarked phrase shown inside its couplet: [before, phrase, after] per line const marked = (lines: string[], phrase: string) => phraseParts(lines, phrase).map((part, i) => { if (!part) return [lines[i], '', '']; const m = lines[i].match(phraseRe(part))!; return [lines[i].slice(0, m.index), m[0], lines[i].slice(m.index! + m[0].length)]; }); const at = (item: any) => (item.poem ? `${item.poem.url}${item.poem.couplet != null ? `#c${item.poem.couplet}` : ''}` : '#'); ---

{me.full_name || 'میری لائبریری'}

{me.bio &&

{me.bio}

}

میری لائبریری · {ud(total)} اندراجات · پروفائل

{total === 0 && (

ابھی کچھ محفوظ نہیں۔ کسی شاعر یا کلام پر "پسندیدہ" دبائیں، کسی شعر کے ساتھ 🔖 لگائیں، کوئی عبارت منتخب کر کے "نشان" لگائیں، یا لفظ منتخب کر کے "محفوظ" کریں۔

)} {lib.poets.length > 0 && (

پسندیدہ شعرا

{lib.poets.map((p: any) => p.poet && {p.poet.name})}
)} {lib.poems.length > 0 && (

پسندیدہ کلام

)} {lib.couplets.length > 0 && (

نشان زدہ اشعار

)} {lib.phrases.length > 0 && (

نشان زدہ عبارتیں

)} {lib.words.length > 0 && (

محفوظ الفاظ

)}