@profullstack/builtindie 0.1.4 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/fetch.ts CHANGED
@@ -17,6 +17,7 @@
17
17
  import { lookup } from 'node:dns/promises'
18
18
  import { isIP } from 'node:net'
19
19
  import { accounts, identityValue, kindOf as kindOfProfile, parseOpenProfile, web } from '@profullstack/openprofile'
20
+ import { tagsFor } from './tags.js'
20
21
 
21
22
  export type Video = { kind: 'youtube' | 'vimeo' | 'loom' | 'file'; url: string; embed: string | null }
22
23
 
@@ -554,13 +555,20 @@ export async function autofetch(input: string, o: FetchOptions = {}): Promise<Si
554
555
  for (const a of profile?.accounts ?? []) addSocial(a)
555
556
  for (const l of facts.links) addSocial(l)
556
557
 
557
- const tags = [
558
- ...new Set(
559
- [...String(m['keywords'] ?? '').split(','), ...asArray(app?.applicationCategory).map(String), ...asArray(manifest?.categories).map(String)]
560
- .map((t) => t.toLowerCase().replace(/application$/, '').replace(/[^a-z0-9 +#.-]/g, '').trim())
561
- .filter((t) => t.length >= 2 && t.length <= 24),
562
- ),
563
- ].slice(0, 6)
558
+ // Tags: what the site declares (opensite.json, keywords meta, article:tag, JSON-LD keywords,
559
+ // category and genre, manifest categories); else topics read from its own words.
560
+ const words = (v: unknown) => asArray(v).flatMap((k) => String(k ?? '').split(','))
561
+ const tags = tagsFor(
562
+ [
563
+ ...words(declared?.tags),
564
+ ...words(declared?.keywords),
565
+ ...words(m['keywords']),
566
+ ...words(m['article:tag']),
567
+ ...[app, org, site].flatMap((d) => [...words(d?.keywords), ...words(d?.applicationCategory), ...words(d?.genre)]),
568
+ ...words(manifest?.categories),
569
+ ],
570
+ { name, tagline, description },
571
+ )
564
572
 
565
573
  return {
566
574
  url: base.href,