Skip to content

Commit

Permalink
added posts folder
Browse files Browse the repository at this point in the history
  • Loading branch information
bendominguez0111 committed Jul 29, 2023
1 parent d8ad35f commit 7af02c3
Show file tree
Hide file tree
Showing 67 changed files with 13,464 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
venv
.venv
.ipynb_checkpoints
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include:
- dist
- posts
34 changes: 34 additions & 0 deletions build_posts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import subprocess
import shutil

# Directory containing .ipynb files
input_dir = 'submissions'

# Directory to save .md files
output_dir = 'posts'

# Directory to save images
img_dir = os.path.join(output_dir, 'img')

# Create the image directory if it doesn't exist
os.makedirs(img_dir, exist_ok=True)

# Get list of all .ipynb files in input_dir
ipynb_files = [f for f in os.listdir(input_dir) if f.endswith('.ipynb')]

# Iterate over .ipynb files and convert each one
for ipynb_file in ipynb_files:
# Construct full file paths
input_file = os.path.join(input_dir, ipynb_file)
# Remove .ipynb extension and add .md extension
output_file = os.path.join(output_dir, ipynb_file.rsplit('.', 1)[0] + '.md')

# Run nbconvert command
subprocess.run(['jupyter', 'nbconvert', '--to', 'markdown', input_file, '--output-dir', output_dir])

# Move the image folder to img
image_folder = os.path.join(output_dir, ipynb_file.rsplit('.', 1)[0] + '_files')
if os.path.exists(image_folder):
new_image_folder = os.path.join(img_dir, ipynb_file.rsplit('.', 1)[0] + '_files')
shutil.move(image_folder, new_image_folder)
11 changes: 0 additions & 11 deletions dist/index.html

This file was deleted.

Loading

0 comments on commit 7af02c3

Please sign in to comment.