This folder contains helper scripts for the site.
measure_linkedin_heights.js
Automatically measures LinkedIn embed post heights and calculates aspect ratios for responsive display.
Usage:
Install Node dependencies (this will download Chromium used by Puppeteer):
npm installRun the measurement script:
npm run measure:linkedin
What It Does:
- Opens each LinkedIn post URL in a headless browser (viewport: 900x1200)
- Measures the actual rendered height and width
- Calculates aspect ratio as percentage:
ratio = (height / width) × 100 - Updates
_data/linkedin_posts.ymlwith bothheightandratiovalues
Output Format:
- url: https://www.linkedin.com/embed/feed/update/urn:li:share:123...
height: 1200 # measured height in pixels
ratio: 133 # aspect ratio as percentage
How Ratios Work:
The ratio determines how the iframe scales responsively:
- Ratio = 100%: Square (height = width)
- Ratio > 100%: Taller than wide (portrait) - typical for LinkedIn posts
- Ratio < 100%: Wider than tall (landscape)
Examples:
- 1200px tall / 900px wide = 133% ratio
- 1500px tall / 900px wide = 167% ratio
The responsive CSS uses this ratio to maintain correct proportions on all screen sizes.
Notes:
- The script uses a headless browser (Puppeteer) with a 900px viewport width
- It does best-effort cookie consent clicks but may fail on some LinkedIn pages that enforce sign-in or advanced consent flows
- The script creates a backup of
_data/linkedin_posts.ymlat_data/linkedin_posts.yml.bakbefore writing changes - If measurement fails, existing values are preserved
