Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
_site
.sass-cache
Gemfile.lock
# Jekyll
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata

# Dependency directories
node_modules/
vendor/
.bundle/

# Environment and build files
.env
.DS_Store
*.log

# Editor directories and files
.idea/
.vscode/
*.swp
*.swo

# Build output
dist/
build/

# Backup files
*.bak
52 changes: 48 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
# Econ3.org Blog
We are exploring Collaborative Economics as a community-driven solution to latestage capitalism.
# Jekyll Author Metadata Implementation

Add to /posts to contribute :)
## Author Metadata Feature

All PRs welcome
This implementation adds a flexible author metadata system to Jekyll blog posts.

### Features
- Optional author information in post front matter
- Default site-wide author configuration
- Supports rich author metadata (name, bio, avatar, social links)

### Usage

#### In Post Front Matter
```yaml
---
layout: post
title: "Your Post Title"
author:
name: "Your Name"
bio: "Optional author bio"
avatar: "/path/to/avatar.jpg"
---
```

#### Default Author
If no author is specified, the site will use the default author from `_config.yml`.

### Configuration

Edit `_config.yml` to set default and additional author information:

```yaml
defaults:
- scope:
path: ""
type: "posts"
values:
author:
name: "Site Default Author"
```

### Best Practices
- Always provide an author name or use site default
- Use consistent avatar image sizes
- Keep bios concise

### Compatibility
- Works with existing Jekyll posts
- Minimal configuration required
43 changes: 18 additions & 25 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
baseurl: "/" # The subpath of your site. Use "" if you're hosting a blog at the root level.
url: "http://ellekasai.github.io" # the base hostname & protocol for your site
title: "Co-Lab"
title: Your Blog Name
description: Your blog description

# This is used by feed.xml. Uncomment if you want to use it.
# description: "..."

gems:
- jemoji
exclude:
- "README.md"
- "CHANGELOG.md"
- "CNAME"
- "Gemfile"
- "Gemfile.lock"
permalink: :title
# Default Author Configuration
defaults:
-
scope:
path: ""
type: "pages"
values:
layout: "default"
-
scope:
path: ""
type: "posts"
values:
layout: "post"
author:
name: "Site Default Author"
bio: "Default author bio"
avatar: "/assets/images/default-avatar.jpg"

# Excerpt settings
excerpt_separator: <!--more-->
show_excerpts: true
# Optional: Additional author-related configurations
authors:
# You can define multiple authors here
john_doe:
name: "John Doe"
bio: "Experienced software developer"
avatar: "/assets/images/authors/john-doe.jpg"
jane_smith:
name: "Jane Smith"
bio: "Technical writer and engineer"
avatar: "/assets/images/authors/jane-smith.jpg"
16 changes: 16 additions & 0 deletions _templates/post-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: post
title: "Your Post Title"
date: YYYY-MM-DD HH:MM:SS +/-TTTT
categories: [category1, category2]
tags: [tag1, tag2]
author:
name: "Your Name" # Full name of the author
bio: "Short author bio (optional)" # Optional biographical information
avatar: "/assets/images/authors/your-avatar.jpg" # Optional avatar image path
social:
twitter: "twitter_handle" # Optional social media links
linkedin: "linkedin_profile"
---

Start writing your blog post content here. Use Markdown formatting as needed.
75 changes: 75 additions & 0 deletions scripts/validate_author_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python3
import sys
import yaml
import os

def validate_author_metadata(file_path):
"""
Validate author metadata in Jekyll post front matter

Args:
file_path (str): Path to the markdown file

Returns:
bool: True if valid, False otherwise
"""
try:
with open(file_path, 'r') as f:
content = f.read()

# Extract front matter
if not content.startswith('---'):
return True # No front matter, skip validation

front_matter_end = content.find('---', 1)
if front_matter_end == -1:
print(f"Invalid front matter in {file_path}")
return False

front_matter_str = content[3:front_matter_end].strip()
front_matter = yaml.safe_load(front_matter_str)

# Check author metadata
if 'author' in front_matter:
author = front_matter['author']

# Validate name
if isinstance(author, dict) and 'name' in author:
name = author['name']
if not name or len(name) > 100:
print(f"Invalid author name in {file_path}: must be 1-100 characters")
return False

# Optional additional validations can be added here

return True

except Exception as e:
print(f"Error processing {file_path}: {e}")
return False

def main():
# Validate all markdown files in _posts directory
posts_dir = '_posts'
if not os.path.exists(posts_dir):
print(f"No {posts_dir} directory found.")
sys.exit(0)

invalid_files = []
for filename in os.listdir(posts_dir):
if filename.endswith('.md') or filename.endswith('.markdown'):
file_path = os.path.join(posts_dir, filename)
if not validate_author_metadata(file_path):
invalid_files.append(file_path)

if invalid_files:
print("Invalid author metadata in the following files:")
for file in invalid_files:
print(f" - {file}")
sys.exit(1)

print("All post author metadata is valid.")
sys.exit(0)

if __name__ == '__main__':
main()