✨ markdown option for creating new comics
This commit is contained in:
@@ -99,9 +99,13 @@ Comics are stored in the `COMICS` list in `comics_data.py`. Each comic entry:
|
||||
|
||||
**Option 1: Use the script (recommended)**
|
||||
```bash
|
||||
# Add comic entry only
|
||||
python scripts/add_comic.py
|
||||
|
||||
# Add comic entry AND create markdown file for author notes
|
||||
python scripts/add_comic.py -m
|
||||
```
|
||||
This will automatically add a new entry with defaults. Then edit `comics_data.py` to customize.
|
||||
This will automatically add a new entry with defaults. The `-m` flag creates a markdown file in `content/author_notes/{date}.md` with a template. Then edit `comics_data.py` to customize.
|
||||
|
||||
**Option 2: Manual**
|
||||
1. Save your comic image in `static/images/comics/` (e.g., `comic-001.png`)
|
||||
|
||||
@@ -4,6 +4,7 @@ Script to add a new comic entry to comics_data.py with reasonable defaults
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
|
||||
# Add parent directory to path so we can import comics_data
|
||||
@@ -11,8 +12,46 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from comics_data import COMICS
|
||||
|
||||
|
||||
def create_markdown_file(date_str, parent_dir):
|
||||
"""Create a markdown file for author notes"""
|
||||
author_notes_dir = os.path.join(parent_dir, 'content', 'author_notes')
|
||||
|
||||
# Create directory if it doesn't exist
|
||||
os.makedirs(author_notes_dir, exist_ok=True)
|
||||
|
||||
markdown_file = os.path.join(author_notes_dir, f'{date_str}.md')
|
||||
|
||||
# Check if file already exists
|
||||
if os.path.exists(markdown_file):
|
||||
print(f"Warning: Markdown file already exists: {markdown_file}")
|
||||
return markdown_file
|
||||
|
||||
# Create file with template content
|
||||
template = f"""# Author Note
|
||||
|
||||
Write your author note here using markdown formatting.
|
||||
|
||||
**Example formatting:**
|
||||
- *Italic text*
|
||||
- **Bold text**
|
||||
- [Links](https://example.com)
|
||||
- `Code snippets`
|
||||
"""
|
||||
|
||||
with open(markdown_file, 'w') as f:
|
||||
f.write(template)
|
||||
|
||||
print(f"Created markdown file: {markdown_file}")
|
||||
return markdown_file
|
||||
|
||||
|
||||
def main():
|
||||
"""Add a new comic entry with defaults"""
|
||||
parser = argparse.ArgumentParser(description='Add a new comic entry to comics_data.py')
|
||||
parser.add_argument('-m', '--markdown', action='store_true',
|
||||
help='Generate a markdown file for author notes')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get next number
|
||||
number = max(comic['number'] for comic in COMICS) + 1 if COMICS else 1
|
||||
|
||||
@@ -51,6 +90,10 @@ def main():
|
||||
|
||||
print(f"Added comic #{number}")
|
||||
|
||||
# Create markdown file if requested
|
||||
if args.markdown:
|
||||
create_markdown_file(comic['date'], parent_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user