This project is a static site generator built as part of a Boot.dev course. It recursively converts Markdown files into a structured HTML website with a Lord of the Rings-themed design. The generator, written in Python, uses standard libraries (re
, os
, sys
, shutil
) to parse Markdown and generate HTML pages. The site is hosted on GitHub Pages at https://kelvindokhoi.github.io/LOTRStaticGen/.
- Recursive Markdown Conversion: Transforms Markdown files into HTML pages using recursive parsing.
- Lord of the Rings Theme: Styled with a custom Lord of the Rings-inspired design via
index.css
. - GitHub Pages Deployment: Deploys the site from the
docs/
directory using a build script. - Modular Python Code: Includes modules for Markdown parsing, HTML generation, and text node processing.
- Customizable: Modify Markdown files, CSS, or Python scripts to create new themes or content.
- Test Suite: Includes unit tests for validating Markdown parsing and HTML generation.
- No External Dependencies: Uses only standard Python libraries (
re
,os
,sys
,shutil
).
Visit the live site at https://kelvindokhoi.github.io/LOTRStaticGen/ to explore the Lord of the Rings-themed website.
- Python 3.x (includes
re
,os
,sys
,shutil
). - A modern web browser (e.g., Chrome, Firefox, Edge).
- A code editor (e.g., VS Code, Sublime Text).
- Clone the repository:
git clone https://github.com/kelvindokhoi/LOTRStaticGen.git
- Navigate to the project directory:
Note: No additional dependencies are required, as the project uses standard Python libraries.
cd LOTRStaticGen
To generate the site and preview it locally:
- Run the generator and start a local server:
This executes
./main.sh
python3 src/main.py
to generate HTML files in thepublic/
directory and starts a local server athttp://localhost:8888
usingpython3 -m http.server 8888
. - Open
http://localhost:8888
in a web browser to view the site.
To generate the site and deploy it to GitHub Pages:
- Run the build script:
This executes
./build.sh
python3 src/main.py '/LOTRStaticGen/'
to generate HTML files and copy them to thedocs/
directory, using/LOTRStaticGen/
as the repository name for correct URL paths. - Commit and push the changes to the
main
branch:git add docs/ git commit -m "Update GitHub Pages content" git push origin main
- The updated site will be available at https://kelvindokhoi.github.io/LOTRStaticGen/.
- Add Markdown Files: Place Markdown files in the
content/
directory (e.g.,content/index.md
,content/blog/glorfindel/index.md
) to define site content. - Run the Generator: Use
./main.sh
to generate HTML files in thepublic/
directory for local testing, or./build.sh
to generate files for GitHub Pages indocs/
. - Customize the Theme: Edit
static/index.css
to modify the Lord of the Rings theme or create a new design. - Extend Functionality: Modify Python scripts in
src/
(e.g.,generate_page.py
,markdown_to_html_node.py
) to add new features or Markdown support. - Run Tests: Execute unit tests to verify functionality:
./test.sh
LOTRStaticGen/
├── content/ # Markdown files for site content
│ ├── blog/ # Blog section Markdown files
│ │ ├── glorfindel/index.md
│ │ ├── majesty/index.md
│ │ └── tom/index.md
│ ├── contact/index.md
│ └── index.md
├── docs/ # GitHub Pages deployment directory
│ ├── blog/ # Generated HTML for blog
│ │ ├── glorfindel/index.html
│ │ ├── majesty/index.html
│ │ └── tom/index.html
│ ├── contact/index.html
│ ├── images/ # Image assets
│ │ ├── glorfindel.png
│ │ ├── rivendell.png
│ │ ├── tolkien.png
│ │ └── tom.png
│ ├── index.css # CSS stylesheet
│ └── index.html # Homepage
├── public/ # Generated HTML output (ignored by .gitignore)
│ ├── blog/ # Generated HTML for blog
│ │ ├── glorfindel/index.html
│ │ ├── majesty/index.html
│ │ └── tom/index.html
│ ├── contact/index.html
│ ├── images/ # Copied image assets
│ │ ├── glorfindel.png
│ │ ├── rivendell.png
│ │ ├── tolkien.png
│ │ └── tom.png
│ ├── index.css
│ └── index.html
├── src/ # Python source code for the generator
│ ├── block_to_blocktype.py
│ ├── blocktype.py
│ ├── extract_markdown_images.py
│ ├── extract_markdown_links.py
│ ├── extract_title.py
│ ├── generate_page.py
│ ├── generate_pages_recursive.py
│ ├── htmlnode.py
│ ├── main.py # Main generator script
│ ├── markdown_to