uniweb 1.34.12 → 1.35.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.
@@ -86,7 +86,8 @@ import { keepEditedTranslations, rowsWantTranslation, formatKeptTranslations } f
86
86
  // Deliberately NOT pull.js's `readPullDocuments`: that one is tolerant of JSON
87
87
  // envelopes for a lane whose shape may change, and importing it here would be a
88
88
  // cycle (pull.js already imports this module). Both lanes here are always ZIPs.
89
- function entityDocFromUwx(buf) {
89
+ // `uniweb promote` reads the site's pages from it, as pushed.
90
+ export function entityDocFromUwx(buf) {
90
91
  if (!buf || buf.length < 2 || buf[0] !== 0x50 || buf[1] !== 0x4b) return null
91
92
  for (const [name, data] of readZip(buf)) {
92
93
  if (name === 'manifest.json' || !name.endsWith('.json')) continue
@@ -1424,8 +1424,11 @@ export async function checkVideoTools({ sitePath, siteName, issues, tools }) {
1424
1424
  * cannot parse is reported as that, never as a page with no description. A page made from a record
1425
1425
  * (`[slug]`) takes its image and title from the record, which no file here describes, so it is left
1426
1426
  * out. An image at an address of its own is left alone: doctor reads files, it fetches nothing.
1427
+ *
1428
+ * `route` checks that one page, by the same rules: the page a post or an ad links to
1429
+ * (`uniweb promote check <route>`), whose card a network draws from its head.
1427
1430
  */
1428
- export async function checkLinkPreviews({ sitePath, siteName, issues }) {
1431
+ export async function checkLinkPreviews({ sitePath, siteName, issues, route = null }) {
1429
1432
  let content
1430
1433
  let failure = null
1431
1434
  // The collect reports its progress on the console; this report is doctor's.
@@ -1453,7 +1456,17 @@ export async function checkLinkPreviews({ sitePath, siteName, issues }) {
1453
1456
  }
1454
1457
 
1455
1458
  // A folder with no content of its own only redirects (to its first page), so a link never lands on it.
1456
- const pages = (content.pages || []).filter((p) => !p.isDynamic && p.hasContent !== false)
1459
+ let pages = (content.pages || []).filter((p) => !p.isDynamic && p.hasContent !== false)
1460
+ if (route !== null) {
1461
+ const key = (r) => String(r).replace(/\/+$/, '') || '/'
1462
+ pages = pages.filter((p) => key(p.route) === key(route))
1463
+ if (pages.length === 0) {
1464
+ const id = 'page-unknown'
1465
+ issues.push({ id, type: 'warn', site: siteName, message: `The site's files have no page ${route}` })
1466
+ warn(`[${id}] The site's files have no page ${route}, or it only leads to the page under it`)
1467
+ return
1468
+ }
1469
+ }
1457
1470
  if (pages.length === 0) return
1458
1471
  const site = content.config || {}
1459
1472
  const siteImage = site.seo?.image || null
@@ -1463,11 +1476,14 @@ export async function checkLinkPreviews({ sitePath, siteName, issues }) {
1463
1476
  if (without.length > 0) {
1464
1477
  const id = 'share-image-none'
1465
1478
  const n = without.length
1466
- const message = n === pages.length ? 'Links to this site show no image' : `Links to ${n} page${n === 1 ? '' : 's'} show no image`
1479
+ const message = route
1480
+ ? `Links to ${route} show no image`
1481
+ : n === pages.length ? 'Links to this site show no image' : `Links to ${n} page${n === 1 ? '' : 's'} show no image`
1467
1482
  issues.push({ id, type: 'info', site: siteName, message })
1468
1483
  info(`[${id}] ${message}`)
1469
1484
  if (without.length < pages.length) listSome(without.map((p) => p.route))
1470
- log(` Set ${colors.green}seo.image${colors.reset} in site.yml — every page without one of its own shows it. A ${CARD.width}×${CARD.height} JPEG or PNG fills a card; ${colors.green}uniweb snapshot --share${colors.reset} makes one from the site.`)
1485
+ if (route) log(` Give it ${colors.green}seo.image${colors.reset} in its page.yml, a card of its own — or set one in site.yml, which every page without one shows. A ${CARD.width}×${CARD.height} JPEG or PNG fills a card.`)
1486
+ else log(` Set ${colors.green}seo.image${colors.reset} in site.yml — every page without one of its own shows it. A ${CARD.width}×${CARD.height} JPEG or PNG fills a card; ${colors.green}uniweb snapshot --share${colors.reset} makes one from the site.`)
1471
1487
  }
1472
1488
 
1473
1489
  // Each image once, with the pages that show it.
@@ -1480,7 +1496,7 @@ export async function checkLinkPreviews({ sitePath, siteName, issues }) {
1480
1496
  }
1481
1497
  let readImageSize = null
1482
1498
  for (const [image, routes] of shownBy) {
1483
- const shownOn = routes.length === pages.length ? 'every page' : routes.length === 1 ? routes[0] : `${routes.length} pages`
1499
+ const shownOn = route ?? (routes.length === pages.length ? 'every page' : routes.length === 1 ? routes[0] : `${routes.length} pages`)
1484
1500
  const file = siteFile(sitePath, image)
1485
1501
  if (!file) {
1486
1502
  const id = 'share-image-missing'