Changeset 3b4095f in Klonkt


Ignore:
Timestamp:
07/01/2026 10:28:08 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
5e52448
Parents:
7f265ce
Message:

feat(seo): og:image light/dark override setting

The auto-generated share card followed the site's default theme (1.2.0); Admin →
SEO now has an explicit override: Auto (follow site theme) / Light / Dark.

  • src/config/database.js — sites.og_theme column (NULL = auto).
  • src/services/OgImageService.js — og_theme wins over theme_override when set.
  • src/routes/og.js — select og_theme for the card route.
  • src/routes/admin-seo.js — save og_theme (validated to light/dark, else auto).
  • src/views/pages/admin-seo.ejs — select under the share-image field.
  • src/services/i18n.js — aseo.og_theme* (nl/en/de).
  • CHANGELOG(.nl/.de).md — under Added.

Closes prutfolio-src-krm.

Co-Authored-By: Claude <noreply@…>

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG.de.md

    r7f265ce r3b4095f  
    77
    88### Hinzugefügt
     9- **Wähle eine helle oder dunkle Teilen-Karte.** Das automatisch erzeugte Teilbild folgt deinem
     10  Site-Thema; unter Verwaltung → SEO kannst du es jetzt fest auf hell oder dunkel stellen.
    911- **Eine Erwähnung ist jetzt eine Benachrichtigung.** Wenn dich jemand im Fediverse in einem
    1012  Beitrag erwähnt — auch in einem, der keine Antwort an dich ist — erscheint das in deinen
  • CHANGELOG.md

    r7f265ce r3b4095f  
    77
    88### Added
     9- **Choose a light or dark share card.** The auto-generated share image follows your site theme;
     10  under Admin → SEO you can now force it light or dark.
    911- **A mention is now a notification.** When someone on the fediverse mentions you in a post —
    1012  even one that isn't a reply to you — it shows up in your fediverse notifications with a link
  • CHANGELOG.nl.md

    r7f265ce r3b4095f  
    77
    88### Toegevoegd
     9- **Kies een lichte of donkere deel-kaart.** De automatisch gemaakte deel-afbeelding volgt je
     10  site-thema; onder Beheer → SEO kun je 'm nu geforceerd licht of donker zetten.
    911- **Een vermelding is nu een melding.** Als iemand op de fediverse je noemt in een post — ook
    1012  eentje die geen reactie op jou is — verschijnt dat in je fediverse-meldingen met een link naar
  • src/config/database.js

    r7f265ce r3b4095f  
    8282  ensureColumn('sites', 'show_search',     'INTEGER DEFAULT 1');
    8383  ensureColumn('sites', 'show_archive_link', 'INTEGER DEFAULT 1');
     84  ensureColumn('sites', 'og_theme', 'TEXT');               // OG share-card variant: NULL=auto (follow site theme) | 'light' | 'dark'
    8485
    8586  // Per-post noindex + type
  • src/routes/admin-seo.js

    r7f265ce r3b4095f  
    5959      default_description = ?,
    6060      og_image_default = ?,
     61      og_theme = ?,
    6162      og_locale = ?,
    6263      author = ?,
     
    7980    trimOrNull(f.default_description, 500),
    8081    trimOrNull(f.og_image_default, 500),
     82    (f.og_theme === 'light' || f.og_theme === 'dark') ? f.og_theme : null, // null = auto (follow site theme)
    8183    trimOrNull(f.og_locale, 32),
    8284    trimOrNull(f.author, 120),
  • src/routes/og.js

    r7f265ce r3b4095f  
    1414  try {
    1515    site = db.prepare(
    16       'SELECT slug, title, tagline, description, palette, accent, theme_override FROM sites WHERE slug = ?'
     16      'SELECT slug, title, tagline, description, palette, accent, theme_override, og_theme FROM sites WHERE slug = ?'
    1717    ).get(req.params.slug);
    1818  } catch { /* db error → 404 below */ }
  • src/services/OgImageService.js

    r7f265ce r3b4095f  
    9090
    9191  const palette = ThemeService.PALETTES[site.palette] ? site.palette : 'klonkt';
    92   // Follow the site's "default theme for new visitors" (theme_override): a light card when the site
    93   // is set to Light, otherwise dark (an OG image is static, so Auto/Dark → dark).
    94   const theme = site.theme_override === 'light' ? 'light' : 'dark';
     92  // Card variant: an explicit SEO override (og_theme) wins; else follow the site's "default
     93  // theme for new visitors" (theme_override) — light when the site is set to Light, otherwise
     94  // dark (an OG image is static, so Auto/Dark → dark).
     95  const theme = (site.og_theme === 'light' || site.og_theme === 'dark')
     96    ? site.og_theme
     97    : (site.theme_override === 'light' ? 'light' : 'dark');
    9598  const accent = site.accent || ((ThemeService.PALETTES[palette] || ThemeService.PALETTES.klonkt)[theme] || ThemeService.PALETTES.klonkt.dark).accent;
    9699  const key = crypto.createHash('sha1')
  • src/services/i18n.js

    r7f265ce r3b4095f  
    285285    'aseo.og_image': 'Standaard deel-afbeelding (URL)',
    286286    'aseo.og_image_hint': 'og:image / Twitter-card; ~1200×630px',
     287    'aseo.og_theme': 'Deel-kaart licht of donker',
     288    'aseo.og_theme_hint': 'de automatisch gemaakte deel-afbeelding',
     289    'aseo.og_theme_auto': 'Automatisch (volgt site-thema)',
     290    'aseo.og_theme_light': 'Licht',
     291    'aseo.og_theme_dark': 'Donker',
    287292    'aseo.og_locale': 'Taal-locale',
    288293    'aseo.og_locale_hint_pre': 'og:locale, bv.',
     
    12081213    'aseo.og_image': 'Default share image (URL)',
    12091214    'aseo.og_image_hint': 'og:image / Twitter card; ~1200×630px',
     1215    'aseo.og_theme': 'Share card light or dark',
     1216    'aseo.og_theme_hint': 'the auto-generated share image',
     1217    'aseo.og_theme_auto': 'Auto (follows site theme)',
     1218    'aseo.og_theme_light': 'Light',
     1219    'aseo.og_theme_dark': 'Dark',
    12101220    'aseo.og_locale': 'Language locale',
    12111221    'aseo.og_locale_hint_pre': 'og:locale, e.g.',
     
    21302140    'aseo.og_image': 'Standard-Teilbild (URL)',
    21312141    'aseo.og_image_hint': 'og:image / Twitter-Card; ~1200×630px',
     2142    'aseo.og_theme': 'Teilen-Karte hell oder dunkel',
     2143    'aseo.og_theme_hint': 'das automatisch erzeugte Teilbild',
     2144    'aseo.og_theme_auto': 'Automatisch (folgt dem Site-Thema)',
     2145    'aseo.og_theme_light': 'Hell',
     2146    'aseo.og_theme_dark': 'Dunkel',
    21322147    'aseo.og_locale': 'Sprach-Locale',
    21332148    'aseo.og_locale_hint_pre': 'og:locale, z. B.',
  • src/views/pages/admin-seo.ejs

    r7f265ce r3b4095f  
    4242        <span><%= t('aseo.og_image') %> <small class="form-hint-inline">— <%= t('aseo.og_image_hint') %></small></span>
    4343        <input type="text" name="og_image_default" value="<%= site.og_image_default || '' %>" placeholder="https://yourdomain.com/share.jpg" maxlength="500">
     44      </label>
     45      <label>
     46        <span><%= t('aseo.og_theme') %> <small class="form-hint-inline">— <%= t('aseo.og_theme_hint') %></small></span>
     47        <select name="og_theme">
     48          <option value="" <%= !site.og_theme ? 'selected' : '' %>><%= t('aseo.og_theme_auto') %></option>
     49          <option value="light" <%= site.og_theme === 'light' ? 'selected' : '' %>><%= t('aseo.og_theme_light') %></option>
     50          <option value="dark" <%= site.og_theme === 'dark' ? 'selected' : '' %>><%= t('aseo.og_theme_dark') %></option>
     51        </select>
    4452      </label>
    4553      <label>
Note: See TracChangeset for help on using the changeset viewer.