top 8 feature

This commit is contained in:
Moon.eth
2026-08-03 16:40:37 +09:00
parent 7d16969f02
commit 80c6134359
11 changed files with 684 additions and 8 deletions
+8 -2
View File
@@ -15,6 +15,7 @@
import type { Account } from '../api/types'
import { renderHtml, toPlainText } from './html'
import { topEightFromHtml } from './top-eight'
/** The interest rows a MySpace profile shipped with, in their original order. */
export const INTEREST_ROWS = ['General', 'Music', 'Movies', 'Television', 'Books', 'Heroes'] as const
@@ -70,6 +71,8 @@ export interface ProfileView {
about: string
/** "Who I'd like to meet" blurb, sanitized HTML. Empty when the user wrote none. */
wantsToMeet: string
/** Fully-qualified handles declared in the portable bio section. */
topEightHandles: string[]
interests: InterestEntry[]
details: ProfileField[]
}
@@ -124,7 +127,9 @@ export function fallbackMood(seed: string): string {
}
export function buildProfileView(account: Account): ProfileView {
const noteHtml = renderHtml(account.note, { emojis: account.emojis })
const renderedNote = renderHtml(account.note, { emojis: account.emojis })
const topEight = topEightFromHtml(renderedNote)
const noteHtml = topEight.html
const { about, meet } = splitBio(noteHtml)
const interests: InterestEntry[] = []
@@ -155,7 +160,7 @@ export function buildProfileView(account: Account): ProfileView {
interests.sort((a, b) => INTEREST_ROWS.indexOf(a.row) - INTEREST_ROWS.indexOf(b.row))
const headlineField = findField(account, ['headline', 'status'])
const headline = headlineField ?? firstSentence(toPlainText(account.note)) ?? '"..."'
const headline = headlineField ?? firstSentence(toPlainText(noteHtml)) ?? '"..."'
const ageField = findField(account, ['age'])
const parsedAge = ageField ? Number.parseInt(ageField, 10) : Number.NaN
@@ -169,6 +174,7 @@ export function buildProfileView(account: Account): ProfileView {
age: Number.isFinite(parsedAge) ? parsedAge : null,
about,
wantsToMeet: meet,
topEightHandles: topEight.handles,
interests,
details,
}