Fix llms.txt: recent articles from blog.json, correct JSON Blog description

This commit is contained in:
russell@unturf.com 2026-01-26 08:35:11 -05:00
parent d6890e9a03
commit e9e643243c

View file

@ -28,21 +28,35 @@ def get_tags_and_categories(output_dir):
def get_recent_articles(output_dir, limit=20):
"""Get list of recent articles from output directory."""
"""Get list of recent articles from blog.json (sorted by date)."""
output_path = Path(output_dir)
blog_json = output_path / 'blog.json'
if blog_json.exists():
try:
data = json.loads(blog_json.read_text())
posts = data.get('posts', [])
# Already sorted by date in blog.json, just get slugs
return [post['slug'] for post in posts[:limit]]
except (json.JSONDecodeError, KeyError):
pass
# Fallback: sort by file modification time
output_path = Path(output_dir)
articles = []
# Find all index.html files that look like articles (have dates in parent dir name)
for index_file in output_path.glob('*/index.html'):
dirname = index_file.parent.name
# Skip non-article directories
if dirname in ('tags', 'category', 'author', 'uploads', 'feeds', 'about', 'archives'):
continue
if dirname.startswith('20'): # Date-prefixed directories (cover letters, etc.)
if dirname.startswith('20'):
continue
articles.append(dirname)
mtime = index_file.stat().st_mtime
articles.append((mtime, dirname))
return sorted(articles)[:limit]
# Sort by modification time, newest first
articles.sort(reverse=True)
return [name for _, name in articles[:limit]]
def generate_llms_txt(output_dir, site_url='https://russell.ballestrini.net'):
@ -76,7 +90,7 @@ def generate_llms_txt(output_dir, site_url='https://russell.ballestrini.net'):
### JSON Blog (jsonblog.dev)
- URL: {site_url}/blog.json
- Format: JSON Blog
- Description: **Entire blog in one file** - all posts with plain text content
- Description: **Entire blog in one file** - all posts with content_url links to index-slim.md (Markdown)
## Content Formats