Commit Graph

2462 Commits

Author SHA1 Message Date
Gigi
5181176260 feat: add configurable link color setting for article links
- Add linkColor field to UserSettings interface
- Add LINK_COLORS palette with 6 link-appropriate colors
- Update ColorPicker to accept custom color arrays
- Add Link Color setting UI after Reading Font setting
- Apply link color as CSS variable in useSettings hook
- Update reader CSS to use --link-color variable instead of --color-primary
- Add link color preview in settings preview section
- Default to indigo-400 (#818cf8) for better visibility on dimmed displays
2025-11-07 22:27:16 +01:00
Gigi
3b4f3e8161 feat: improve link visibility in dark mode with lighter indigo-400 color
- Change primary color from indigo-500 to indigo-400 (#818cf8) in dark mode
- Improves readability on dimmed mobile displays
- Update both theme-dark and theme-system dark mode variants
2025-11-07 22:20:33 +01:00
Gigi
2323427dbd style: further increase top margin on headlines in reader view 2025-11-07 22:15:16 +01:00
Gigi
43e6455668 style: further increase top margin on headlines in reader view 2025-11-07 22:14:53 +01:00
Gigi
7b3f36b0bb style: increase top margin on headlines in reader view 2025-11-07 22:14:11 +01:00
Gigi
feafe4a07b style: increase paragraph spacing in reader view to 1.5rem 2025-11-07 22:13:18 +01:00
Gigi
ed1a4e489e style: increase paragraph spacing in reader view to 1rem 2025-11-07 22:12:43 +01:00
Gigi
4ab34456d1 Merge pull request #43 from dergigi/more-md-tests
Add basic markdown syntax test suite
2025-11-07 21:13:55 +01:00
Gigi
54ed0c547f docs: update source links to point to specific files
Update source links in each basic markdown test file to link to the specific file path rather than the directory.
2025-11-07 21:08:50 +01:00
Gigi
98291f0904 docs: add source links to basic markdown test files
Add GitHub source directory links at the end of each basic syntax test file for easy reference.
2025-11-07 21:08:23 +01:00
Gigi
f0b3ad239c feat: add basic markdown syntax test files
Add comprehensive test suite for basic markdown syntax features:
- basic-headings.md: All heading levels and setext syntax
- basic-paragraphs-line-breaks.md: Paragraph separation and line breaks
- basic-emphasis.md: Bold and italic formatting
- basic-blockquotes.md: Blockquotes with nested content
- basic-lists.md: Ordered and unordered lists with nesting
- basic-code.md: Inline code and code blocks
- basic-horizontal-rules.md: Horizontal rule variants
- basic-links-and-images.md: Links and images with various syntax
- basic-escaping.md: Character escaping
- basic-index.md: Index of all test files

All files follow the Markdown Guide's Basic Syntax specification.
2025-11-07 21:05:40 +01:00
Gigi
7d7e60c226 Merge pull request #42 from dergigi/fix-opengraph-try3
Fix OpenGraph metadata fetching and add Redis-backed caching
2025-11-07 19:59:19 +01:00
Gigi
55ea43e103 chore: remove debug logging from article metadata fetching
- Remove console.log statements from fetchArticleMetadataViaRelays
- Remove console.log statements from article-og handler
- Keep error logging (console.error) for debugging issues
2025-11-07 19:53:03 +01:00
Gigi
631d65be21 perf: implement early-return article fetch with micro-wait author
- Add fetchFirstEvent helper that resolves on first event (not waiting for complete)
- Add fetchAuthorProfile helper for DRY author fetching
- Refactor fetchArticleMetadataViaRelays to:
  - Return immediately when first article event arrives (no 7s wait)
  - Fetch author profile with 400ms micro-wait (connections already warm)
  - Optional hedge: try again with 600ms if first attempt fails
  - Fallback to pubkey prefix if profile not found
- Add logging to track article fetch and author resolution source

This dramatically improves first-request latency by returning as soon as
any relay responds, while still attempting to get author name with
minimal additional delay (400-600ms total).
2025-11-07 19:48:48 +01:00
Gigi
76b9797c41 feat: add article tags and image alt text to OG metadata
- Add tags field to ArticleMetadata type (extracted from 't' tags)
- Add imageAlt field to ArticleMetadata type (uses title as fallback)
- Extract 't' tags from article events in fetchArticleMetadataViaRelays
- Generate multiple article:tag meta tags in HTML output
- Add og:image:alt meta tag for better accessibility

This improves SEO and social media previews by including
article categorization tags and image descriptions.
2025-11-07 19:39:02 +01:00
Gigi
4fc4971345 refactor: simplify OG fetch - remove timeout wrapper and background refresh
Remove Promise.race timeout wrapper and let relay fetch use its natural
timeouts (7s for article, 5s for profile). Remove background refresh
complexity entirely.

Flow is now simple:
1. Check Redis cache
2. If miss, fetch from relays (up to 7s)
3. Cache result
4. Subsequent requests hit cache

First request may take 7-8 seconds, but after that it's cached and fast.
Much simpler and more reliable.
2025-11-07 19:30:36 +01:00
Gigi
f2bc0c1da1 feat: enhance background refresh logging
Add more detailed logging to diagnose background refresh issues:
- Log the exact URL being called
- Log whether secret is present
- Better error handling for non-JSON responses
- More detailed error messages

This will help identify if the refresh endpoint is being called
and why we're not seeing logs from it.
2025-11-07 19:28:04 +01:00
Gigi
f486de1597 fix: increase relay fetch timeout from 3s to 5s
Relays can be slow, especially on first connection. Increase timeout
to 5 seconds to give relays more time to respond before falling back
to default metadata.
2025-11-07 19:23:47 +01:00
Gigi
b0e43ccee7 feat: add comprehensive logging for background refresh
Add detailed logging to verify background refresh is working:
- Log when background refresh is triggered
- Log the response status and result from refresh endpoint
- Log errors if refresh fetch fails
- Add logging in refresh endpoint to track:
  - When refresh starts
  - When metadata is found
  - When metadata is cached
  - Any errors during refresh

This will help diagnose if background refresh is actually
populating the Redis cache after timeouts.
2025-11-07 19:19:47 +01:00
Gigi
66db9cd23f refactor: remove gateway fetch, use relays with short timeout
- Remove gateway HTTP fetch entirely
- Fetch directly from relays on cache miss with 3s timeout
- If relay fetch succeeds: cache and return article metadata
- If relay fetch fails/times out: return default OG and trigger background refresh
- Update logging to reflect relay-first strategy
- Keep background refresh endpoint for eventual consistency

This simplifies the code and removes dependency on unreliable gateway,
while ensuring fast responses and eventual correctness via background refresh.
2025-11-07 19:15:17 +01:00
Gigi
c2552d2e34 feat: add detailed logging for gateway metadata fetch
Add comprehensive logging to diagnose why gateway fetch is failing:
- Log the exact URL being fetched
- Log HTTP status on failure
- Log response length on success
- Log which OG tags were found/missing
- Add detailed error information

This will help identify if the issue is:
- Fetch timeout/failure
- Missing OG tags in response
- Regex pattern mismatch
2025-11-07 19:08:08 +01:00
Gigi
56547b3526 fix: improve Redis initialization and add debugging for metadata fetch
- Support both KV_* and UPSTASH_* env var names for Redis
- Add error handling for Redis get operations
- Add console logging to track cache hits/misses and gateway fetches
- Fix syntax error in background refresh trigger

This will help diagnose why article metadata isn't being returned correctly.
2025-11-07 19:05:25 +01:00
Gigi
70ac7dce95 fix: add .js extensions to ESM imports for Vercel compatibility
ESM requires explicit file extensions in import paths. Add .js
extensions to all relative imports in API files and services,
even though source files are .ts (they compile to .js).

This fixes ERR_MODULE_NOT_FOUND errors on Vercel.
2025-11-07 19:01:01 +01:00
Gigi
f982781dd8 fix: move OG service files to api/services for Vercel compatibility
- Move ogStore, ogHtml, and articleMeta from src/services/ to api/services/
- Update imports in article-og.ts and article-og-refresh.ts
- Update import paths in articleMeta.ts (lib/profile and src/config/relays)
- Remove old files from src/services/
- Clean up ESLint config to only reference api/**/*.ts

This fixes the ERR_MODULE_NOT_FOUND error on Vercel by ensuring
serverless functions can access the service modules.
2025-11-07 18:52:30 +01:00
Gigi
a73c7db9d3 fix: resolve linting and type errors
- Add ESLint override for Node.js environment in api/ and services files
- Fix WebSocket redeclaration warning in articleMeta.ts
- Fix import path for profile utility (../../lib/profile)
- Install @types/ws for TypeScript support
- Remove unused @ts-expect-error directive
2025-11-07 18:46:24 +01:00
Gigi
c81b7b89d1 feat: implement storage-backed OG previews with Upstash Redis
- Add ogStore service for Redis get/set operations
- Extract shared logic: ogHtml (generateHtml, escapeHtml) and articleMeta (relay/gateway fetching)
- Refactor article-og endpoint to read from Redis, try gateway on miss, trigger background refresh
- Add article-og-refresh endpoint for background relay fetching and caching
- Update vercel.json with refresh function config
- Remove WebSocket dependencies from main OG endpoint for faster crawler responses
2025-11-07 18:41:08 +01:00
Gigi
971b672591 chore: add .vercel to gitignore 2025-11-07 17:32:09 +01:00
Gigi
8b30ffd5e7 Merge pull request #41 from dergigi/fix-opengraph-try2
Fix OpenGraph metadata generation for article naddrs
2025-11-07 17:31:26 +01:00
Gigi
3975ef15dd chore(runtime): pin Node 22.x via package.json engines 2025-11-07 17:28:01 +01:00
Gigi
61e8517137 fix(vercel): remove functions.runtime and pin Node 18 via package.json engines 2025-11-07 17:26:35 +01:00
Gigi
b0d30946eb fix(vercel): add version=2 to vercel.json so functions.runtime is recognized 2025-11-07 17:21:59 +01:00
Gigi
c0cfd41e76 perf(og): increase relay request timeouts (7s article, 5s profile) to improve reliability 2025-11-07 17:15:48 +01:00
Gigi
be7b6c2cfb chore(vercel): pin Node runtime and increase maxDuration for article OG function 2025-11-07 17:15:30 +01:00
Gigi
afd27032e0 chore(api): add ws polyfill and dependency for RelayPool in serverless 2025-11-07 17:15:17 +01:00
Gigi
696fe42bee feat(og): always render OG meta for /a/:naddr and include redirect script for browsers 2025-11-07 17:14:55 +01:00
Gigi
1a0370aef9 Merge pull request #40 from dergigi/fix-500
Fix serverless import resolution for profile helpers
2025-11-07 16:48:11 +01:00
Gigi
ed3e8e9799 refactor(shared): move profile helpers to lib and import from API and src\n\n- Fix serverless import resolution by avoiding src/** in API\n- Keep code DRY with single shared module 2025-11-07 16:43:02 +01:00
Gigi
f590ff56ec fix(api): inline profile display name helper to avoid src import in serverless 2025-11-07 16:39:58 +01:00
Gigi
cc68980cdb Merge pull request #39 from dergigi/fix-opengraph-stuff
Fix OpenGraph meta tags for article URLs
2025-11-07 16:36:11 +01:00
Gigi
d83708ceb3 fix: remove user-agent restriction from article OG rewrite
All /a/:naddr requests now route to article-og handler, which handles crawler detection internally. This ensures social media crawlers always receive proper OpenGraph meta tags.
2025-11-07 16:10:31 +01:00
Gigi
507aa27d29 chore: remove trailing newline from tables.md test file 2025-11-07 16:04:50 +01:00
Gigi
1d4c5a7393 docs: add footnotes explaining Bitcoin frequency notation 2025-11-07 15:43:25 +01:00
Gigi
64fd2cc0d3 test: add real-world table from Bitcoin is Time article 2025-11-07 15:36:55 +01:00
Gigi
b6182b3c11 Merge pull request #38 from dergigi/render-tables
Add markdown table rendering support
2025-11-07 15:22:42 +01:00
Gigi
e7e02dd129 fix: remove quotation marks from title in publish-markdown script 2025-11-07 15:16:45 +01:00
Gigi
d76bfb66bb docs: add test account npub and profile link to .env.example
Add documentation about the test account used for publishing markdown test documents, including the npub and profile link to Marky Markdown Testerson's writings.
2025-11-07 15:14:31 +01:00
Gigi
024e62118b docs: add test account npub and profile link to publish-markdown.sh
Add documentation about the test account used for publishing markdown test documents, including the npub and profile link to Marky Markdown Testerson's writings.
2025-11-07 15:13:46 +01:00
Gigi
ed93675d8d chore: remove misplaced .env.example from scripts directory
The publish-markdown.sh script expects .env in the project root, not in scripts/, so this example file was in the wrong location.
2025-11-07 15:12:58 +01:00
Gigi
2089208448 docs: add explanatory paragraphs to each test table
- Add descriptive text before each table explaining what it tests
- Improve documentation for table test cases
- Help developers understand the purpose of each test scenario
2025-11-07 15:08:15 +01:00
Gigi
4fd8a0b18f test: extend table with numbers to 21 rows
- Add rows 4-21 with decreasing scores
- Test table styling with longer content
2025-11-07 15:06:46 +01:00