# Φωτογραφικό δοκίμιο με ολοσέλιδες εικόνες ως την άκρη

> Ολοσέλιδες εικόνες ως στιλ επικεφαλίδων από λίστα, καθεμία ως την κοπή της σελίδας της· η εικόνα της καταιγίδας περνά τη ράχη ενός δισέλιδου σε δύο μισά.

- Έκδοση HTML: https://postext.dev/el/cookbook/photo-essay-full-bleed
- Συνταγή Αρ. 068 · Εικόνες και γραφικά · Επίπεδο 2 (Μεσαίο) · Έξοδοι: Canvas
- Είδη: Φωτογραφικά λευκώματα
- Απαιτεί postext ≥ 1.42.1 · δοκιμασμένη με 1.65.0 στις 2026-10-31
- Σελίδες: [1](https://postext.dev/cookbook/photo-essay-full-bleed/en/p01.webp?v=ef5cac10), [2](https://postext.dev/cookbook/photo-essay-full-bleed/en/p02.webp?v=ef5cac10), [3](https://postext.dev/cookbook/photo-essay-full-bleed/en/p03.webp?v=ef5cac10), [4](https://postext.dev/cookbook/photo-essay-full-bleed/en/p04.webp?v=ef5cac10), [5](https://postext.dev/cookbook/photo-essay-full-bleed/en/p05.webp?v=ef5cac10), [6](https://postext.dev/cookbook/photo-essay-full-bleed/en/p06.webp?v=ef5cac10), [7](https://postext.dev/cookbook/photo-essay-full-bleed/en/p07.webp?v=ef5cac10), [8](https://postext.dev/cookbook/photo-essay-full-bleed/en/p08.webp?v=ef5cac10), [9](https://postext.dev/cookbook/photo-essay-full-bleed/en/p09.webp?v=ef5cac10)
- Άνοιγμα στο Sandbox: https://postext.dev/el/sandbox#recipe=photo-essay-full-bleed&lang=en (.postext: https://postext.dev/cookbook/photo-essay-full-bleed/en/photo-essay-full-bleed.postext)
- Τελευταία ενημέρωση: 2026-10-10
- Άλλες γλώσσες: [en](https://postext.dev/en/cookbook/photo-essay-full-bleed.md), [es](https://postext.dev/es/cookbook/photo-essay-full-bleed.md), [ca](https://postext.dev/ca/cookbook/photo-essay-full-bleed.md), [de](https://postext.dev/de/cookbook/photo-essay-full-bleed.md), [fr](https://postext.dev/fr/cookbook/photo-essay-full-bleed.md), [it](https://postext.dev/it/cookbook/photo-essay-full-bleed.md), [pt](https://postext.dev/pt/cookbook/photo-essay-full-bleed.md), [zh](https://postext.dev/zh/cookbook/photo-essay-full-bleed.md), [ja](https://postext.dev/ja/cookbook/photo-essay-full-bleed.md), [ar](https://postext.dev/ar/cookbook/photo-essay-full-bleed.md)

## Με λίγα λόγια

Ένα οριζόντιο φωτογραφικό βιβλίο που δείχνει μια μέρα στα βουνά σε έξι εικόνες. Δείχνει πώς γεμίζουν ολόκληρες σελίδες με φωτογραφίες ως την άκρη, και πώς μια εικόνα απλώνεται σε δύο αντικριστές σελίδες.

## Τι θα στοιχειοθετήσετε

Το *Sierra*, ένα οριζόντιο φωτογραφικό βιβλίο σε σελίδα 280 × 210 mm: μια μέρα σε μια γρανιτένια οροσειρά σε έξι ολοσέλιδες εικόνες, από το πρώτο φως ως το πρωί μετά το πρώτο χιόνι. Κάθε εικόνα γεμίζει τη σελίδα της ως την άκρη κοπής και φέρει μόνο έναν μικρό αριθμό και την ώρα στην κάτω αριστερή γωνία της· η πρώτη φέρει επίσης τον τίτλο, SIERRA σε Syne 72 pt, σε αρνητικό πάνω στον ουρανό της αυγής. Η καταιγίδα περνά πάνω από τη ράχη των σελίδων 4 και 5 ως μία εικόνα. Τρία σύντομα κείμενα, στοιχειοθετημένα σε στήλη 100 mm κοντά στη ράχη, αντικρίζουν τις εικόνες που τα ακολουθούν. Το κείμενο της καταιγίδας τελειώνει σε μια μικρότερη εικόνα του σούρουπου που κινείται ελεύθερα κάτω του, με τον αριθμό της στη λεζάντα. Η τελευταία εικόνα δείχνει το κάρο της δεύτερης από τον ίδιο ογκόλιθο, κάτω από το χιόνι. Οι εικόνες είναι φωτογραφίες που δημιουργήθηκαν με μοντέλα διάχυσης· η εικόνα του χιονιού φτιάχτηκε ως επεξεργασία της εικόνας του μεσημεριού, ώστε οι δύο λήψεις να ταιριάζουν.

**Αυτή η συνταγή απαντά:**

- Πώς δίνω σε κάθε εικόνα φωτογραφικού δοκιμίου δική της σελίδα ως την άκρη και απλώνω μία σε δισέλιδο;
- Πώς εισάγω σκόπιμα κενές σελίδες, ή αρχίζω μια ενότητα σε νέο δισέλιδο;
- Πώς κρύβω τις τρέχουσες κεφαλίδες στις εναρκτήριες και στις κενές σελίδες, ή χρωματίζω μια κενή αριστερή σελίδα με το χρώμα του μέρους;
- Πώς στοιχειοθετώ μη αριθμημένα εικαστικά: κοσμήματα, βινιέτες, λογότυπα;

## Η σύντομη απάντηση

```js
// script.js, γραμμές 35–57
// '{attr.art}' is filled in per heading, so a plain plate names its picture on its line:
// # Noon {style="lamina" art="mediodia" …}. Only the cover and the last plate draw extras.
const PLATES = [ // the style id, its picture, the ink of its caption, anything extra it draws
  { id: 'alba', art: 'alba', extra: (colour) => cover(colour) }, // an arrow: cover() is below
  { id: 'lamina', art: '{attr.art}' }, // any plate on a page of its own
  { id: 'pliego', art: '{attr.art}', half: 'verso' }, // one picture across a spread:
  { id: 'pliego-recto', art: '{attr.art}', half: 'recto' }, // the left half, then the right
  { id: 'nieve', art: 'nieve', ink: 'ink', extra: (colour) => colophon(colour) },
];
const plate = ({ id, art, half, ink = 'white', extra = () => [] }) => ({
  id, span: 'page', // an opener: a span heading always starts a page of its own
  // The left half opens on an even page, a verso, so the right half faces it across the
  // gutter (gotcha: parity-page1-recto).
  ...(half === 'verso' && { breakBefore: { enabled: true, parity: 'even' } }),
  // The picture is as deep as the page, more than the column holds: the plate claims the
  // whole page, and what follows starts on the next one.
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'image', id: 'picture', resourceId: art, // the recto half is the same picture,
      placement: at('page', 'top-left', half === 'recto' ? -PAGE.width : 0, 0, // moved left
        { width: mm(half ? 2 * PAGE.width : PAGE.width), height: mm(PAGE.height) }) },
    ...(half === 'recto' ? [] : caption(col(ink))), ...extra(col(ink)),
  ] } },
});
```

## Υλικά

**Διδάσκει**

- [Εικόνες στις σχεδιάσεις σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-εικόνας): Λογότυπα, φωτογραφίες και κοσμήματα τοποθετημένα σε κεφαλίδες, υποσέλιδα, εναρκτήριες σελίδες και σελίδες μέρους, με μέγεθος που διατηρεί τις αναλογίες τους.
- [Στιλ επικεφαλίδων](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων): Ονομασμένες παραλλαγές ενός επιπέδου επικεφαλίδας, που επιλέγονται με {style="…"}: διαφορετική εναρκτήρια σελίδα, τυπογραφία, τρέχουσες κεφαλίδες ή διάταξη σελίδας ανά κεφάλαιο.
- [Σχεδιασμένες εναρκτήριες σελίδες](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση): Μια επικεφαλίδα σχεδιασμένη ως ελεύθερη σύνθεση από κείμενο, γραμμές, πλαίσια και εικόνες, που δεσμεύει το ύψος που χρειάζεται πάνω από το κυρίως κείμενο.

**Χρησιμοποιεί επίσης**

- [Αγκύρωση στοιχείων σχεδίασης](https://postext.dev/el/docs/configuration-headers-footers.md#τοποθέτηση-στοιχείων)
- [Γεωμετρία ενότητας](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)
- [Ιδιότητες επικεφαλίδων](https://postext.dev/el/docs/document-format.md#χαρακτηριστικά-επικεφαλίδων)
- [Κεφάλαια που ανοίγουν σε δεξιά σελίδα](https://postext.dev/el/docs/configuration-headings.md#αλλαγή-σελίδας-πριν-από-επικεφαλίδα)
- [Κεφαλίδες ανά ρόλο σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου)
- [Παραπομπές που τοποθετούν εικόνες](https://postext.dev/el/docs/document-format-resources.md#παραπομπή-μέσα-στο-κείμενο-η-κύρια-μορφή)
- [Προσαρμοσμένοι τύποι πόρων](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων)
- [Στιλ λεζάντας](https://postext.dev/el/docs/configuration-resources.md#στιλ-λεζάντας)
- [Εξώφυλλα, σελίδες τίτλου και κολοφώνες](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)
- [Χρώμα χαρτιού](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα)
- [Συμμετρικά περιθώρια](https://postext.dev/el/docs/configuration-page-layout.md#κατοπτρικά-περιθώρια)
- [Κείμενο, γραμμές και πλαίσια στις σχεδιάσεις σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα)
- [Συλλαβισμός και γλώσσα του εγγράφου](https://postext.dev/el/docs/justification.md#υποστηριζόμενες-γλώσσες)
- [Σημασιολογική χρωματική παλέτα](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων)
- [Εικόνες και πίνακες ως πόροι](https://postext.dev/el/docs/document-format-resources.md#πόροι)
- [Σελίδες σε καμβά](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)

**Η διαμόρφωση με μια ματιά**

- [`bodyText`](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο), [`canvasViewer`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#προβολή-καμβά), [`captionStyle`](https://postext.dev/el/docs/configuration-resources.md#στιλ-λεζάντας), [`colorPalette`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων), [`footer`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`header`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`headingStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων), [`headings`](https://postext.dev/el/docs/configuration-headings.md#επικεφαλίδες), [`layout`](https://postext.dev/el/docs/configuration-page-layout.md#διάταξη), [`locale`](https://postext.dev/el/docs/configuration-language.md#συλλαβισμός), [`page`](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα), [`resourceTypes`](https://postext.dev/el/docs/configuration-resources.md#τύποι-πόρων)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`registerResourceImage`](https://postext.dev/el/docs/architecture.md#η-επιφάνεια-του-api), [`renderPageToCanvas`](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)

**Γραμματοσειρές**

- Andada Pro (OFL-1.1), Syne (OFL-1.1), Syne Mono (OFL-1.1)

## Προετοιμασία

### 1 · Ένα στιλ επικεφαλίδας για κάθε εικόνα, χτισμένο από μια λίστα

Ο κώδικας είναι η [σύντομη απάντηση](https://postext.dev/el/cookbook/photo-essay-full-bleed.md#η-σύντομη-απάντηση) παραπάνω. Το `plate()` χτίζει ένα στιλ επικεφαλίδας από κάθε γραμμή του `PLATES`, και το Markdown ορίζει τη σειρά του δοκιμίου, μία γραμμή για κάθε εικόνα: `# Night {style="lamina" art="noche" n="V" hora="22:10"}`. Το `resourceId` του στοιχείου εικόνας είναι `'{attr.art}'`, ένα σύμβολο κράτησης θέσης όπως εκείνα ενός κειμένου, οπότε κάθε απλή εικόνα μοιράζεται το στιλ `lamina` και ονομάζει την εικόνα της στη γραμμή της επικεφαλίδας της· μόνο το εξώφυλλο και η τελευταία εικόνα, που σχεδιάζουν επιπλέον στοιχεία, κρατούν δικό τους στιλ ([Στοιχεία εικόνας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-εικόνας)). Το `span: 'page'` ξεκινά κάθε εικόνα σε δική της σελίδα. Η εικόνα έχει βάθος 210 mm, το ύψος της σελίδας, και μια σχεδίαση κρατά χώρο ως το κάτω μέρος των εικόνων της. Αυτό είναι περισσότερο από τη στήλη των 158 mm των σελίδων κειμένου, οπότε η εικόνα διεκδικεί ολόκληρη τη σελίδα και ό,τι ακολουθεί αρχίζει στην επόμενη, χωρίς `minHeight` και χωρίς δικά της περιθώρια.

Τα δύο στιλ του δισέλιδου, `pliego` και `pliego-recto`, σχεδιάζουν την ίδια εικόνα των 560 mm, εδώ `art="tormenta"`: το μισό της ζυγής σελίδας στην αριστερή άκρη της σελίδας, το μισό της μονής 280 mm πιο αριστερά, έτσι κάθε σελίδα δείχνει το δικό της μισό και ο καμβάς περικόπτει τα υπόλοιπα στην άκρη κοπής. Το `parity: 'even'` κρατά τα δύο μισά αντικριστά. Χωρίς αυτό, αν αφαιρούσατε την εικόνα του μεσημεριού από το Markdown, το αριστερό μισό θα πήγαινε στη σελίδα 3, μια μονή σελίδα, και το δεξί στην πίσω όψη, στη σελίδα 4· με αυτό, η σελίδα 3 μένει κενή και η καταιγίδα γεμίζει ακόμη τις σελίδες 4 και 5.

### 2 · Ο αριθμός και η ώρα έρχονται από τη γραμμή της επικεφαλίδας

```js
// script.js, γραμμές 61–72
const NUMERAL = { x: 16, y: PAGE.height - 21, size: 13 }; // mm from the top left; size in pt
// A design text's baseline sits 0.8 of its line box below its top: set a smaller label beside
// a larger one this much lower and the two share a baseline.
const dropTo = (big, small, lineHeight = 1.2) => (0.8 * lineHeight * (big - small) * 25.4) / 72;
const caption = (colour) => [
  { kind: 'text', id: 'numeral', content: '{attr.n}', fontFamily: 'Syne', fontWeight: 700,
    fontSize: pt(NUMERAL.size), color: colour, align: 'left',
    placement: at('page', 'top-left', NUMERAL.x, NUMERAL.y) },
  { kind: 'text', id: 'hour', content: '· {attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
    letterSpacing: pt(0.8), color: colour, align: 'left', // the dot: a lone I reads as a bar
    placement: at('#numeral', 'right-of', 1.6, dropTo(NUMERAL.size, 8)) },
];
```

Ο αριθμός και η ώρα είναι ιδιότητες της επικεφαλίδας, οπότε το περιεχόμενο μένει στο Markdown και μία σχεδίαση εξυπηρετεί κάθε εικόνα. Η ώρα κρέμεται `right-of` του αριθμού, που ευθυγραμμίζει τις κορυφές τους. Η γραμμή βάσης ενός κειμένου σχεδίασης βρίσκεται στο 0,8 του πλαισίου γραμμής του κάτω από την κορυφή του στοιχείου, και το πλαίσιο γραμμής είναι από προεπιλογή 1,2 φορές το μέγεθος των στοιχείων, οπότε το `dropTo(13, 8)` κατεβάζει την ώρα κατά 0,8 × 1,2 × (13 − 8) pt και βάζει την ώρα των 8 pt στη γραμμή βάσης του αριθμού των 13 pt, 193,4 mm από την κορυφή της σελίδας. Η ώρα ανοίγει με μια μέση τελεία, όπως η λεζάντα της εικόνας IV, επειδή το I της Syne είναι μια απλή ράβδος και, μόνο του δίπλα στην ώρα, διαβάζεται σαν γραμμή. Το μισό της καταιγίδας στη μονή σελίδα δεν σχεδιάζει λεζάντα, και η εικόνα του χιονιού στοιχειοθετεί τη λεζάντα της σε μελάνι, επειδή το πρώτο της πλάνο είναι λευκό.

### 3 · Τίτλος και κολοφώνας πάνω στις ίδιες τις εικόνες

```js
// script.js, γραμμές 76–90
const cover = (colour) => [
  { kind: 'text', id: 'title', content: '{title}', fontFamily: 'Syne', fontWeight: 800,
    fontSize: pt(72), lineHeight: 1, letterSpacing: pt(6), textTransform: 'uppercase',
    color: colour, align: 'left', placement: at('page', 'top-left', 22, 26) },
  { kind: 'text', id: 'subtitle', content: '{subtitle}', fontFamily: 'Syne Mono',
    fontSize: pt(10), letterSpacing: pt(2), textTransform: 'uppercase', color: colour,
    align: 'left', placement: at('#title', 'below', 1.5, 3) },
];
// The colophon: one element per line, 10.5 pt apart, so the break falls after the licence, and
// the second line on the baseline of the plate's numeral.
const COLOPHON = { y: NUMERAL.y + dropTo(NUMERAL.size, 7.5), leading: (10.5 * 25.4) / 72 };
const colophon = (colour) => ['colofon', 'tipos'].map((key, line) => ({ kind: 'text', id: key,
  content: `{attr.${key}}`, fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.2),
  color: colour, align: 'right',
  placement: at('page', 'top-right', -16, COLOPHON.y - (1 - line) * COLOPHON.leading) }));
```

Η πρώτη εικόνα είναι το εξώφυλλο. Τα `{title}` και `{subtitle}` διαβάζουν το frontmatter, και το `extra` στο `PLATES` προσθέτει και τα δύο στοιχεία στη σχεδίαση αυτής της εικόνας, στο χρώμα της λεζάντας της. Ο κολοφώνας μπαίνει με τον ίδιο τρόπο στην τελευταία εικόνα, σε μελάνι πάνω στο χιόνι: δύο στοιχεία των 7,5 pt, ένα ανά γραμμή, από τις ιδιότητες `colofon` και `tipos`, στοιχισμένα δεξιά, το δεύτερο στη γραμμή βάσης του αριθμού. Ένα μόνο στοιχείο που αναδιπλώνεται θα άλλαζε γραμμή όπου τελείωνε το πλάτος του· με ένα στοιχείο ανά γραμμή, η αλλαγή πέφτει μετά την άδεια χρήσης.

### 4 · Τα κείμενα ακολουθούν τις εικόνες τους χωρίς αλλαγή σελίδας

```js
// script.js, γραμμές 94–114
const textOpener = { enabled: true, slot: { elements: [
  { kind: 'text', id: 'hours', content: '{attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
    letterSpacing: pt(0.8), color: col('accent'), align: 'left',
    placement: at('container', 'top-left', 0, 0) },
  { kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Syne', fontWeight: 700,
    fontSize: pt(28), lineHeight: 1.05, // a multiple of the size
    color: col('ink'), align: 'left', overflow: 'wrap',
    placement: at('#hours', 'below', 0, 2.5, { width: 'fill' }) },
] } };
// The folio and the book's title under the text block, flush with its left edge, on the
// baseline of the plates' numerals. Not on the plates: a span heading opens their pages, so
// they are opener pages, and 'body' leaves them out.
const foot = (id, content, extra) => ({ kind: 'text', id, content, pages: 'body',
  fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.8), color: col('muted'),
  align: 'left', ...extra });
const FOOT = NUMERAL.y + dropTo(NUMERAL.size, 7.5) - (PAGE.height - MARGIN.bottom); // from the foot
const footer = { elements: [
  foot('folio', '{pageNumber}', { color: col('ink'),
    placement: at('container', 'top-left', 0, FOOT) }),
  foot('book', '{title}', { textTransform: 'uppercase', placement: at('#folio', 'right-of', 5) }),
] };
```

Η εικόνα πριν από ένα κείμενο γεμίζει τη σελίδα της, οπότε το κείμενο αρχίζει την επόμενη σελίδα χωρίς δική του αλλαγή. Μια σελίδα της οποίας το πρώτο μπλοκ είναι επικεφαλίδα με αλλαγή σελίδας είναι εναρκτήρια σελίδα, και το `pages: 'body'` του αριθμού σελίδας την παραλείπει. Χωρίς αλλαγή, οι σελίδες κειμένου κρατούν τον αριθμό σελίδας τους· οι εικόνες, που τις ανοίγουν επικεφαλίδες πλάτους σελίδας, δεν παίρνουν. Το `breakBefore: { enabled: false }` απενεργοποιεί την αλλαγή προς μονή σελίδα που έχει από προεπιλογή μια επικεφαλίδα επιπέδου 1· με αυτή την αλλαγή, η σελίδα κάθε κειμένου θα ήταν εναρκτήρια, χωρίς αριθμό σελίδας. Το `FOOT` βάζει τον αριθμό σελίδας στη γραμμή βάσης των αριθμών των εικόνων, 193,4 mm από την κορυφή της σελίδας, έτσι ο αριθμός σελίδας ενός κειμένου και ο αριθμός της εικόνας απέναντί του κάθονται στην ίδια γραμμή.

### 5 · Δηλώστε κάθε εικόνα, παραπέμψτε μόνο σε αυτήν που κινείται

```js
// script.js, γραμμές 195–221
// Plate IV is the one plate that floats, so a counter of its type would number it 1. The type
// prints no number (no caption prefix, an empty template) and the caption carries the numeral.
// The text names the plate with :ref's text, since a bare :ref prints 'lámina' and nothing else.
const lamina = { id: 'lamina', name: t({ en: 'Plate', es: 'Lámina' }),
  shortLabel: t({ en: 'plate', es: 'lámina' }), numberingTemplate: '',
  resetOn: 'never', counterFormat: 'decimal', captionPrefix: '' };
// JPEGs in assets/, cut to the page's shape: 1600 × 1200 px for 280 × 210 mm (145 dpi).
const picture = (id, [w, h], alt, extra = {}) => ({ id, typeId: 'lamina', kind: 'bitmap',
  bitmap: { fileId: `${id}-${w}.jpg`, format: 'jpeg', width: w, height: h },
  createdAt: 0, updatedAt: 0, altText: t(alt), ...extra });
const resources = [ // the five the heading styles draw, never cited, and plate IV
  picture('alba', [1600, 1200], { en: 'Eight ridges fading into a peach dawn haze.',
    es: 'Ocho crestas que se pierden en la bruma del alba.' }),
  picture('mediodia', [1600, 1200], { en: 'A granite cirque and its lake under a pale noon sky.',
    es: 'Un circo de granito y su laguna bajo el cielo pálido del mediodía.' }),
  picture('tormenta', [2400, 900], { en: 'A storm over the range: rain on the left, lightning '
    + 'and a break of sun on the right.', es: 'Una tormenta sobre la sierra: lluvia a la '
    + 'izquierda; un rayo y un claro de sol a la derecha.' }),
  picture('noche', [1600, 1200], { en: 'Stars over dark ridges and two lit windows at a refuge.',
    es: 'Estrellas sobre crestas oscuras y dos ventanas encendidas en un refugio.' }),
  picture('nieve', [1600, 1200], { en: 'The cirque the morning after, white with new snow.',
    es: 'El circo a la mañana siguiente, blanco de nieve nueva.' }),
  // 2000 px, 339 mm at the layout's 150 dpi, which the float fits to the 100 mm measure.
  picture('atardecer', [2000, 800], { en: 'A crest lit orange under strips of cloud, violet sky.',
    es: 'Una cresta encendida de naranja bajo franjas de nube, en un cielo violeta.' },
  { caption: t({ en: 'IV · Dusk · 19:41', es: 'IV · Atardecer · 19:41' }) }),
];
```

Το στοιχείο εικόνας μιας σχεδίασης σχεδιάζει έναν δηλωμένο πόρο, οπότε και οι έξι εικόνες βρίσκονται στο `resources`: JPEG στον φάκελο `assets/` της συνταγής, καθένα κομμένο στο σχήμα της σελίδας ή του δισέλιδου που γεμίζει και δηλωμένο στο μέγεθός του σε pixel, που είναι ό,τι διαβάζει η σελιδοποίηση. Το `loadImage()` καταχωρίζει κάθε αρχείο πριν από το χτίσιμο. Η εικόνα IV είναι η μόνη με παραπομπή `:ref`, και επομένως η μόνη που κινείται. Παίρνει την πρώτη ελεύθερη θέση μετά την παραπομπή, στη σελίδα του κειμένου της, μία γραμμή κάτω από την τελευταία παράγραφο. Ένας αριθμημένος τύπος θα της έδινε λεζάντα *Plate 1*, αφού είναι ο μόνος πόρος του τύπου της που κινείται. Το `lamina` έχει αντί γι’ αυτό κενό `numberingTemplate` και κενό `captionPrefix`, οπότε δεν τυπώνεται *Plate.*, και η ίδια η λεζάντα αρχίζει με IV. Στην πρόταση, το `text` του `:ref` ονομάζει την εικόνα, επειδή ένα σκέτο `:ref` τυπώνει μόνο τη λέξη *plate*.

## Η πλήρης συνταγή

Ένα αρχείο, συντεθειμένο από τον φάκελο της συνταγής με το δείγμα κειμένου και το κοινό κιτ του Συνταγολογίου ενσωματωμένα· φτιάχνει τη δική του σελίδα. Για να το εκτελέσετε, βάλτε το σε ένα `<script type="module">` σε μια κενή σελίδα, ή επικολλήστε το στο πάνελ JS ενός νέου CodePen (ως module). Εισάγει το postext από το esm.sh, οπότε δεν χρειάζεται εγκατάσταση ούτε build.

- Φάκελος πηγής: https://github.com/drnachio/postext/tree/main/cookbook/photo-essay-full-bleed

### script.js

```js
// ═══ Postext Cookbook · Nº 068 · Photo essay with full-bleed plates ═══════════════
// https://postext.dev/en/cookbook/photo-essay-full-bleed
// Code: MIT · Text: original (CC BY 4.0) · Plates: diffusion models
// Fonts: Andada Pro, Syne, Syne Mono (SIL OFL 1.1) · Needs postext ≥ 1.42.1
// Sierra, a landscape photobook: one day in a mountain range in six plates, each on a page of
// its own and one across the gutter of a spread, with three short texts between them.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'photo-essay-full-bleed';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the paper between the plates, the ink and one rust for the labels
const palette = {
  ink: '#1c1f27', // text: the blue-black of the night plate
  paper: '#f3f0ea', // every page's ground: a pale stone, seen only between the plates
  accent: '#94462e', // the times over each text: the dusk plate's rust, dark enough for 8 pt
  muted: '#5f646d', // the running foot and the caption of the small plate
  white: '#fbfaf7', // type set on the plates
};
// col() links a colour to its palette entry; the hex is the value the entry holds.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries(palette)
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const PAGE = { width: 280, height: 210 }; // a landscape photobook, in mm
const MARGIN = { top: 28, bottom: 24, inner: 40, outer: 140 }; // text pages: a 100 mm measure
const LEAD = 15; // body leading in pt
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });

// #region answer: the plates' heading styles, generated from a list
// '{attr.art}' is filled in per heading, so a plain plate names its picture on its line:
// # Noon {style="lamina" art="mediodia" …}. Only the cover and the last plate draw extras.
const PLATES = [ // the style id, its picture, the ink of its caption, anything extra it draws
  { id: 'alba', art: 'alba', extra: (colour) => cover(colour) }, // an arrow: cover() is below
  { id: 'lamina', art: '{attr.art}' }, // any plate on a page of its own
  { id: 'pliego', art: '{attr.art}', half: 'verso' }, // one picture across a spread:
  { id: 'pliego-recto', art: '{attr.art}', half: 'recto' }, // the left half, then the right
  { id: 'nieve', art: 'nieve', ink: 'ink', extra: (colour) => colophon(colour) },
];
const plate = ({ id, art, half, ink = 'white', extra = () => [] }) => ({
  id, span: 'page', // an opener: a span heading always starts a page of its own
  // The left half opens on an even page, a verso, so the right half faces it across the
  // gutter (gotcha: parity-page1-recto).
  ...(half === 'verso' && { breakBefore: { enabled: true, parity: 'even' } }),
  // The picture is as deep as the page, more than the column holds: the plate claims the
  // whole page, and what follows starts on the next one.
  advancedDesign: { enabled: true, slot: { elements: [
    { kind: 'image', id: 'picture', resourceId: art, // the recto half is the same picture,
      placement: at('page', 'top-left', half === 'recto' ? -PAGE.width : 0, 0, // moved left
        { width: mm(half ? 2 * PAGE.width : PAGE.width), height: mm(PAGE.height) }) },
    ...(half === 'recto' ? [] : caption(col(ink))), ...extra(col(ink)),
  ] } },
});
// #endregion

// #region caption: the plate's numeral and hour, lower left, from the heading's attributes
const NUMERAL = { x: 16, y: PAGE.height - 21, size: 13 }; // mm from the top left; size in pt
// A design text's baseline sits 0.8 of its line box below its top: set a smaller label beside
// a larger one this much lower and the two share a baseline.
const dropTo = (big, small, lineHeight = 1.2) => (0.8 * lineHeight * (big - small) * 25.4) / 72;
const caption = (colour) => [
  { kind: 'text', id: 'numeral', content: '{attr.n}', fontFamily: 'Syne', fontWeight: 700,
    fontSize: pt(NUMERAL.size), color: colour, align: 'left',
    placement: at('page', 'top-left', NUMERAL.x, NUMERAL.y) },
  { kind: 'text', id: 'hour', content: '· {attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
    letterSpacing: pt(0.8), color: colour, align: 'left', // the dot: a lone I reads as a bar
    placement: at('#numeral', 'right-of', 1.6, dropTo(NUMERAL.size, 8)) },
];
// #endregion

// #region cover: the book's title reversed out of the dawn sky of the first plate
const cover = (colour) => [
  { kind: 'text', id: 'title', content: '{title}', fontFamily: 'Syne', fontWeight: 800,
    fontSize: pt(72), lineHeight: 1, letterSpacing: pt(6), textTransform: 'uppercase',
    color: colour, align: 'left', placement: at('page', 'top-left', 22, 26) },
  { kind: 'text', id: 'subtitle', content: '{subtitle}', fontFamily: 'Syne Mono',
    fontSize: pt(10), letterSpacing: pt(2), textTransform: 'uppercase', color: colour,
    align: 'left', placement: at('#title', 'below', 1.5, 3) },
];
// The colophon: one element per line, 10.5 pt apart, so the break falls after the licence, and
// the second line on the baseline of the plate's numeral.
const COLOPHON = { y: NUMERAL.y + dropTo(NUMERAL.size, 7.5), leading: (10.5 * 25.4) / 72 };
const colophon = (colour) => ['colofon', 'tipos'].map((key, line) => ({ kind: 'text', id: key,
  content: `{attr.${key}}`, fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.2),
  color: colour, align: 'right',
  placement: at('page', 'top-right', -16, COLOPHON.y - (1 - line) * COLOPHON.leading) }));
// #endregion

// #region texts: a text between plates opens on the next page with its hours above it
const textOpener = { enabled: true, slot: { elements: [
  { kind: 'text', id: 'hours', content: '{attr.hora}', fontFamily: 'Syne Mono', fontSize: pt(8),
    letterSpacing: pt(0.8), color: col('accent'), align: 'left',
    placement: at('container', 'top-left', 0, 0) },
  { kind: 'text', id: 'title', content: '{titleText}', fontFamily: 'Syne', fontWeight: 700,
    fontSize: pt(28), lineHeight: 1.05, // a multiple of the size
    color: col('ink'), align: 'left', overflow: 'wrap',
    placement: at('#hours', 'below', 0, 2.5, { width: 'fill' }) },
] } };
// The folio and the book's title under the text block, flush with its left edge, on the
// baseline of the plates' numerals. Not on the plates: a span heading opens their pages, so
// they are opener pages, and 'body' leaves them out.
const foot = (id, content, extra) => ({ kind: 'text', id, content, pages: 'body',
  fontFamily: 'Syne Mono', fontSize: pt(7.5), letterSpacing: pt(0.8), color: col('muted'),
  align: 'left', ...extra });
const FOOT = NUMERAL.y + dropTo(NUMERAL.size, 7.5) - (PAGE.height - MARGIN.bottom); // from the foot
const footer = { elements: [
  foot('folio', '{pageNumber}', { color: col('ink'),
    placement: at('container', 'top-left', 0, FOOT) }),
  foot('book', '{title}', { textTransform: 'uppercase', placement: at('#folio', 'right-of', 5) }),
] };
// #endregion

const config = () => ({
  canvasViewer: { pageGap: 0 }, // the Canvas joins the two pages of a spread
  // The English sample is British English: every English tag hyphenates with the US patterns.
  locale: t({ en: 'en-us', es: 'es' }),
  colorPalette,
  resourceTypes: [lamina],
  page: { width: mm(PAGE.width), height: mm(PAGE.height), dpi: 150,
    backgroundColor: col('paper'), // the ground of every page; the plates cover it
    margins: { top: mm(MARGIN.top), bottom: mm(MARGIN.bottom), left: mm(MARGIN.inner),
      right: mm(MARGIN.outer), mirror: true } }, // left is the inner margin
  layout: { layoutType: 'single' },
  bodyText: { fontFamily: 'Andada Pro', fontSize: pt(10.5), lineHeight: pt(LEAD),
    color: col('ink'), boldColor: col('ink'), italicColor: col('ink'), // both default to blue
    referenceColor: col('ink'), referenceBold: false, // 'lámina IV' reads as a word of the text
    firstLineIndent: mm(4), indentAfterHeading: false, // justified and hyphenated by default
    minWordSpacing: 0.7, maxWordSpacing: 1.6 }, // a narrower range than the defaults, 0.6 to 2
  // A heading's own line is measured even where its design paints the title: set it in a face
  // the page loads, or the kit fetches Open Sans for it.
  headings: { fontFamily: 'Syne', levels: [
    // A text follows its plate with no break of its own, so the default H1 break is switched
    // off: the plate fills its page, the text still starts a page, and that page stays a body
    // page, with its running foot.
    { level: 1, breakBefore: { enabled: false }, advancedDesign: textOpener },
  ] },
  headingStyles: PLATES.map(plate),
  captionStyle: { fontFamily: 'Syne Mono', fontSize: pt(7.5), color: col('muted') },
  header: { elements: [] },
  footer,
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = String.raw`---
title: "Sierra"
subtitle: "An essay in six lights"
---

# Dawn {style="alba" n="I" hora="08:12"}

# The climb {hora="06:40–14:06 · 1770–2180 m"}

We left the car park at 6:40 with head torches, on the paved track that climbs between the broom. At that hour the granite still holds the night’s cold, and our boots sound louder than they should. From the first bend we can see the lights of the village below, eleven of them, counted twice; from the second we can’t.

At 8:12 the sun touches the highest point of the crest. It is a pink edge that lasts as long as it takes to get the camera out; then the light works its way down the gullies, slowly, and takes almost an hour to reach the path. The meadow grass is white with frost and crunches under our boots. An ibex watches us from a boulder and does not move, so we are the ones who go round.

We stop at the pass to eat. There is a spring that is not on the map, an iron spout driven into the rock, and the water is cold enough to make our teeth ache. Andrés notes the time and the altitude of every photograph in a notebook; at one o’clock the thermometer hanging from his rucksack reads eleven degrees in the sun.

Solar noon falls after two here, on summer time. By then the shadows have gone under the stones, and the lake, seen from the pass, looks like a sheet of tin someone has left behind between the walls.

# Noon {style="lamina" art="mediodia" n="II" hora="14:06"}

# Storm {style="pliego" art="tormenta" n="III" hora="16:40"}

# Storm {style="pliego-recto" art="tormenta"}

# Eleven seconds {hora="15:00–19:50 · 2180–1950 m"}

At three o’clock the air grows heavy. A cloud that at first we take for another mountain is building in the west. We pack in a hurry. The first thunder comes eleven seconds after the flash: nearly four kilometres away, Andrés reckons, because he always counts. The next one comes after four.

We take shelter under the overhang of a boulder as big as a house. First small hail, then rain; the wall opposite fades behind the curtain and comes back darker, washed. Nobody speaks for a good hour.

Around half past seven the storm drifts away down the valley and leaves the sky broken into strips. For a moment the sun comes out below the cloud, low in the west, and turns the whole crest a colour that lasts less than three minutes (:ref{id="atardecer" text="plate IV"}). We go down to the refuge soaked through, beside the stream, which is running full.

# Night {style="lamina" art="noche" n="V" hora="22:10"}

# First snow {hora="22:10–09:00 · 1950 m"}

At ten the sky is clear, and the refuge window cannot hold all its stars. At midnight somebody opens the door and says it is snowing. We go out in our socks. The snow falls straight down, with no wind, in large flakes that are slow to melt on our sleeves, and the torch lights only a cone of white points coming towards us.

In the morning the thermometer at the window reads two below. There is a hand’s depth of snow at the door and a rim of thin ice along the lake. The ridges that were grey yesterday are white with black streaks, the ribs where the snow will not stick, and the sky is the same colour as the ground.

Andrés takes the last photograph at 8:31, from the same boulder as at noon yesterday. It takes him some time to find it, because the stones he used as markers are now identical white mounds. In the end he places it by matching the crest to yesterday’s picture on the camera screen.

It is the first snow of the autumn, two weeks early, the warden says. We set off at nine. The paved track is under the snow, so we go down from one cairn to the next.

# Snow {style="nieve" n="VI" hora="08:31" colofon="Sierra. An essay in six lights · Plates generated with diffusion models · Text: CC BY 4.0" tipos="Set in Andada Pro, Syne and Syne Mono (SIL OFL)"}
`; // content.<lang>.md, inlined by the Cookbook

// #region plates: every picture is a resource; only plate IV is cited, so only it floats
// Plate IV is the one plate that floats, so a counter of its type would number it 1. The type
// prints no number (no caption prefix, an empty template) and the caption carries the numeral.
// The text names the plate with :ref's text, since a bare :ref prints 'lámina' and nothing else.
const lamina = { id: 'lamina', name: t({ en: 'Plate', es: 'Lámina' }),
  shortLabel: t({ en: 'plate', es: 'lámina' }), numberingTemplate: '',
  resetOn: 'never', counterFormat: 'decimal', captionPrefix: '' };
// JPEGs in assets/, cut to the page's shape: 1600 × 1200 px for 280 × 210 mm (145 dpi).
const picture = (id, [w, h], alt, extra = {}) => ({ id, typeId: 'lamina', kind: 'bitmap',
  bitmap: { fileId: `${id}-${w}.jpg`, format: 'jpeg', width: w, height: h },
  createdAt: 0, updatedAt: 0, altText: t(alt), ...extra });
const resources = [ // the five the heading styles draw, never cited, and plate IV
  picture('alba', [1600, 1200], { en: 'Eight ridges fading into a peach dawn haze.',
    es: 'Ocho crestas que se pierden en la bruma del alba.' }),
  picture('mediodia', [1600, 1200], { en: 'A granite cirque and its lake under a pale noon sky.',
    es: 'Un circo de granito y su laguna bajo el cielo pálido del mediodía.' }),
  picture('tormenta', [2400, 900], { en: 'A storm over the range: rain on the left, lightning '
    + 'and a break of sun on the right.', es: 'Una tormenta sobre la sierra: lluvia a la '
    + 'izquierda; un rayo y un claro de sol a la derecha.' }),
  picture('noche', [1600, 1200], { en: 'Stars over dark ridges and two lit windows at a refuge.',
    es: 'Estrellas sobre crestas oscuras y dos ventanas encendidas en un refugio.' }),
  picture('nieve', [1600, 1200], { en: 'The cirque the morning after, white with new snow.',
    es: 'El circo a la mañana siguiente, blanco de nieve nueva.' }),
  // 2000 px, 339 mm at the layout's 150 dpi, which the float fits to the 100 mm measure.
  picture('atardecer', [2000, 800], { en: 'A crest lit orange under strips of cloud, violet sky.',
    es: 'Una cresta encendida de naranja bajo franjas de nube, en un cielo violeta.' },
  { caption: t({ en: 'IV · Dusk · 19:41', es: 'IV · Atardecer · 19:41' }) }),
];
// #endregion

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { // text, display and label faces, loaded before the build
  'Andada Pro': ['400'], Syne: ['700', '800'], 'Syne Mono': ['400'] };

// ─── 4 · Build & show ───────────────────────────────────────────────────────
const files = resources.map((r) => r.bitmap.fileId); // a resource names a file: load each
await Promise.all(files.map((f) => loadImage(f, asset(f))));
const doc = await buildDocumentWithFonts({ markdown, resources }, config(), kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Sierra: a photo essay in landscape',
  es: 'Sierra: un ensayo fotográfico apaisado' }) });

// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ─────

// ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook
function mm(value) { return { value, unit: 'mm' }; }
function pt(value) { return { value, unit: 'pt' }; }
function em(value) { return { value, unit: 'em' }; }
/** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */
function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; }
/** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */
function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; }

// ─── Kit · fonts v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,'
      + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
    'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,'
      + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}files/${id}-${subset}-${weight}-${style}.woff2`;
        const face = new FontFace(family, `url(${url}) format('woff2')`,
          { weight: String(weight), style, unicodeRange: ranges[subset] });
        jobs.push(face.load().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
function hasFace(family, weight, style) {
  for (const face of document.fonts) {
    if (face.status !== 'loaded' || face.style !== style) continue;
    if (face.family.replace(/^["']|["']$/g, '') !== family) continue;
    const [low, high = low] = face.weight.split(' ').map(Number);
    if (weight >= low && weight <= high) return true;
  }
  return false;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  const root = viewer(title);
  const pages = [docs].flat().flatMap((doc) =>
    doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index })));
  const spreads = [];
  let verso = null;
  for (const p of pages) {
    if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; }
    else { spreads.push([verso, p]); verso = null; }
  }
  if (verso) spreads.push([verso, null]);
  const density = Math.min(window.devicePixelRatio || 1, 2);
  showPages.painter?.disconnect();
  const painter = new IntersectionObserver((entries) => {
    for (const { isIntersecting, target } of entries) {
      if (!isIntersecting) continue;
      painter.unobserve(target);
      const { doc, page } = target.postext;
      renderPageToCanvas(page, doc, target, { ...render, scale: (width * density) / page.width });
    }
  }, { rootMargin: '800px' });
  showPages.painter = painter;
  root.replaceChildren(...spreads.map((pair) => {
    const spread = document.createElement('div');
    spread.className = 'pt-spread';
    for (const p of pair) {
      const figure = document.createElement('figure');
      if (p) {
        const label = p.page.pageLabel || String(p.n + 1);
        const canvas = document.createElement('canvas');
        canvas.postext = p;
        canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`;
        canvas.setAttribute('role', 'img');
        canvas.setAttribute('aria-label', `Page ${label}`);
        const folio = document.createElement('figcaption');
        folio.textContent = label;
        figure.append(canvas, folio);
        painter.observe(canvas);
      } else figure.className = 'pt-blank';
      spread.append(figure);
    }
    return spread;
  }));
  kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`);
  document.documentElement.dataset.postext = 'ready';
  return pages.length;
}

/** The desk, the bar and the error reporting, created once. */
function viewer(title) {
  if (!document.getElementById('pt-kit')) {
    document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit">
      :root { color-scheme: dark; }
      body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; }
      #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center;
        gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px);
        border-bottom: 1px solid #23262d; }
      #pt-bar strong { color: #f4f1ea; font-weight: 600; }
      #pt-actions { display: flex; gap: 12px; margin-left: auto; }
      #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
      #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; }
      .pt-spread { display: flex; }
      .pt-spread figure { margin: 0; width: min(460px, 44vw); }
      .pt-spread canvas { display: block; width: 100%; background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif;
        letter-spacing: .18em; text-transform: uppercase; color: #6c7079; }
      .pt-blank { visibility: hidden; }
      @media (max-width: 760px) {
        .pt-spread { flex-direction: column; gap: 32px; }
        .pt-spread figure { width: min(460px, 92vw); }
        .pt-blank { display: none; }
      }
    </style>`);
    document.body.insertAdjacentHTML('afterbegin',
      '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>');
    document.getElementById('pt-title').textContent = document.title || 'Postext';
    addEventListener('error', (event) => kitFail(event.error ?? event.message));
    addEventListener('unhandledrejection', (event) => kitFail(event.reason));
  }
  if (title) document.getElementById('pt-title').textContent = title;
  return document.getElementById('pages')
    ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' }));
}

function kitStatus(text) {
  viewer();
  document.getElementById('pt-status').textContent = text;
}

function kitFail(error) {
  document.documentElement.dataset.postext = 'error';
  kitStatus(`Error: ${error?.message ?? error}`);
}

// ─── Kit · images v3 ── recipes with pictures · postext.dev/cookbook
/** Registers a photo or PNG for the canvas and keeps its bytes for the PDF.
 *  fetch → ImageBitmap never taints the canvas (a plain cross-origin <img> would). */
async function loadImage(fileId, url) {
  const res = await fetch(url);
  if (!res.ok) throw new Error(`Image not found (${res.status}): ${url}`);
  const bytes = new Uint8Array(await res.arrayBuffer());
  registerResourceImage(fileId, await createImageBitmap(new Blob([bytes])));
  (loadImage.bytes ??= new Map()).set(fileId, bytes);
}

/** Registers SVG markup as a vector image, its fonts inside (inlineSvgFonts, ≥ 1.25).
 *  `options` go to registerResourceImage: { singleInk: true } tints it on the canvas. */
async function loadSvg(fileId, svg, options) {
  if (typeof inlineSvgFonts === 'function') svg = await inlineSvgFonts(svg, svgFaces);
  const img = new Image();
  img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
  await img.decode();
  registerResourceImage(fileId, img, options);
  (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg));
}

/** A face's Fontsource files: nearest weight; latin + what the SVG sets. */
async function svgFaces(family, weight, style, { codePoints = [] } = {}) {
  const [id, m] = [fontsourceId(family), await fontsourceMeta(family)];
  const w = m?.weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)) ?? weight;
  const s = m?.styles.includes(style) === false ? 'normal' : style;
  return Promise.all(['latin', ...kitSubsetsFor(String.fromCodePoint(...codePoints), m)].map(async (x) => new Uint8Array(
    await (await fetch(`${await fontsourceAt(id)}files/${id}-${x}-${w}-${s}.woff2`)).arrayBuffer())));
}

/** renderToPdf({ resourceBytes: imageBytes }) */
function imageBytes(fileId) { return loadImage.bytes?.get(fileId); }

/** renderToHtml({ resourceImageUrl: imageUrl }) */
function imageUrl(fileId) {
  const bytes = imageBytes(fileId);
  if (!bytes) return undefined;
  imageUrl.urls ??= new Map();
  if (!imageUrl.urls.has(fileId)) {
    const type = /\.svg$/i.test(fileId) ? 'image/svg+xml' : /\.png$/i.test(fileId) ? 'image/png' : 'image/jpeg';
    imageUrl.urls.set(fileId, URL.createObjectURL(new Blob([bytes], { type })));
  }
  return imageUrl.urls.get(fileId);
}

// ─── /Kit ───────────────────────────────────────────────────────────────────────
```

## Παραλλαγές

### Εικόνες που κινούνται απέναντι από τα λήμματά τους

Για ολοσέλιδες εικόνες που κινούνται στη μονή σελίδα απέναντι από ένα λήμμα καταλόγου, με το πλάτος της εικόνας να ορίζεται από τις αναλογίες της, δείτε τη συνταγή [Λήμματα καταλόγου απέναντι από τις ολοσέλιδες εικόνες τους](https://postext.dev/el/cookbook/catalogue-facing-plates.md).

### Ανοίξτε ένα άρθρο με φωτογραφία ως την άκρη

Για μια φωτογραφία που απλώνεται ως την άκρη στην κορυφή ενός άρθρου, με τον τίτλο και τον πρόλογο πάνω της, δείτε [το άρθρο περιοδικού](https://postext.dev/el/cookbook/magazine-feature-opener.md).

## Συνήθη λάθη

- **Η σελίδα 1 είναι δεξιά: σχεδιάστε τις σελίδες με φυσικούς αριθμούς.** Η σελίδα 1 είναι δεξιά (μονή) σελίδα και η σελίδα 2 η πρώτη αριστερή (ζυγή), οπότε σχεδιάστε τα δισέλιδα με φυσικούς αριθμούς σελίδων: μια εναρκτήρια σελίδα σε ζυγή σελίδα βλέπει τη μονή σελίδα που ακολουθεί.
- **Χωρίς <marker> ή φίλτρα στα SVG (εφεδρική ψηφιογραφία).** Μια εικόνα SVG μένει διανυσματική στο PDF μόνο χωρίς <marker>, φίλτρα και μάσκες· διαφορετικά μετατρέπεται σε ψηφιογραφία, και φίλτρα σε βαθιά εμφώλευση μπορεί να την αφήσουν κενή στο Chrome. Σχεδιάστε τις αιχμές των βελών ως διαδρομές.

- Μην παραπέμπετε ποτέ σε μια εικόνα που σχεδιάζει μια σχεδίαση. Με παραπομπή, κινείται επιπλέον ως εικόνα: ένα `:ref` στην εικόνα του μεσημεριού στο πρώτο κείμενο βάζει ένα δεύτερο αντίγραφό της στη σελίδα 3, και η καταιγίδα μετακινείται δύο σελίδες πιο πέρα, μετά από μια κενή σελίδα.
- Η εικόνα του σούρουπου κάθεται μία γραμμή κάτω από το κείμενό της, όχι στο κάτω μέρος της σελίδας. Στην τελευταία σελίδα ενός κειμένου, ένα κινητό στοιχείο που βρίσκεται κάτω από το κείμενο ανεβαίνει ως αυτό (`layout.hugClosingFloats`, ενεργό από προεπιλογή), και το `position: 'bottom'` δεν αλλάζει τίποτα εκεί.
- Κάθε κείμενο είναι προσαρμοσμένο σε μία σελίδα και στις δύο εκδόσεις. Όταν το πρώτο συνεχίσει στη σελίδα 3, η εικόνα του μεσημεριού πηγαίνει στη σελίδα 4 και η καταιγίδα στις σελίδες 6 και 7, μετά από μια κενή σελίδα 5.
- Το δεξί μισό της καταιγίδας είναι μια δεύτερη επικεφαλίδα `# Storm`. Η σελίδα δεν τυπώνει τίτλο γι’ αυτήν, αλλά ένας `:::toc` χτισμένος από τις επικεφαλίδες απαριθμεί την καταιγίδα δύο φορές, στις σελίδες 4 και 5.
- Οι εικόνες σταματούν στην άκρη κοπής, που είναι η άκρη του καμβά. Με ενεργό το `page.cutLines`, ο καμβάς μεγαλώνει γύρω από την άκρη κοπής, και το περιθώριο αιμορραγίας γύρω από κάθε εικόνα δείχνει το χρώμα του χαρτιού. Για εκτύπωση, αγκυρώστε τις εικόνες στο `'bleed'` και κάντε καθεμία μεγαλύτερη κατά το περιθώριο αιμορραγίας σε κάθε πλευρά.

## Ευχαριστίες

- Συνταγή: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Κείμενο: The three texts, the captions and the colophon, in Spanish and English, and the six plates, drawn in code: Postext Cookbook, CC-BY-4.0
- Εικόνες: Plate I, dawn: ridges fading into a peach haze under a dark blue sky: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plate II, noon: a granite cirque and its lake: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plate III, storm: rain, lightning and a break of sun across a spread: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plate IV, dusk: the crest lit orange under a violet sky: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plate V, night: stars over the ridges and a lit refuge: Generated With Diffusion Models, πρωτότυπο
- Εικόνες: Plate VI, snow: the cirque of plate II the morning after: Generated With Diffusion Models, πρωτότυπο
- Γραμματοσειρές: Andada Pro (OFL-1.1), Syne (OFL-1.1), Syne Mono (OFL-1.1)
- Κώδικας: MIT · Δείγμα περιεχομένου: CC-BY-4.0

## Σχετικές συνταγές

- [Αρ. 017 · Πέντε εναρκτήριες σελίδες κεφαλαίων σε ένα βιβλίο](https://postext.dev/el/cookbook/five-chapter-openers.md): Μία εναρκτήρια στο επίπεδο 1 και τέσσερα στιλ επικεφαλίδας από το Markdown· όλα αλλάζουν το χρώμα έμφασης, κάποια και περιθώρια, στήλες ή σελιδαρίθμηση. · Επίπεδο 3 (Προχωρημένο) · Οποιοδήποτε είδος
- [Αρ. 034 · Λήμματα καταλόγου απέναντι από τις ολοσέλιδες εικόνες τους](https://postext.dev/el/cookbook/catalogue-facing-plates.md): Κάθε λήμμα ανοίγει αριστερά και αναφέρει την εικόνα του στην πρώτη πρόταση του σχολίου· η εικόνα πάει στην απέναντι δεξιά σελίδα, σε κλίμακα που τη γεμίζει. · Επίπεδο 3 (Προχωρημένο) · Κατάλογοι
- [Αρ. 004 · Θέμα περιοδικού: από τη φωτογραφία ως το σήμα τέλους](https://postext.dev/el/cookbook/magazine-feature-opener.md): Ένα άνοιγμα advancedDesign στήνει από την επικεφαλίδα φωτογραφία σε αιμορραγία, υπέρτιτλο, τίτλο, πρόλογο, υπογραφή· μετά δύο κινητά πλαίσια, σήμα τέλους. · Επίπεδο 3 (Προχωρημένο) · Περιοδικά και fanzines
