# ⚡ Modern BashBlog

A lightweight, single-script static blog generator written in Bash, now supercharged with a **modern Bento Grid UI**, **YAML-driven dynamic dropdown menus**, **article hero banners**, and **Docker containerization**.

---

## ✨ Features

- **📂 Single-Script Power:** All core engine operations remain completely contained within a single optimized shell script (`bb.sh`).
- **🍱 Bento Box Grid Layout:** The homepage presents articles in a sleek, responsive CSS Grid bento layout with micro-animations, glassmorphic cards, and hover effects.
- **🗺️ YAML-Driven Dropdowns:** A dynamic navigation menu generated on rebuild from `menu.yaml`, supporting nested submenus and dropdown categories.
- **🖼️ Article Hero Images:** Every individual article page automatically displays a premium header banner.
- **🚀 Docker Ready:** Includes `Dockerfile` and `docker-compose.yml` for serving the static blog with hot-reload support using Nginx Alpine.
- **📈 Caching, Parallelism & Sitemap:** A built-in caching system, parallel tag processing pipeline, and automatic standard-compliant `sitemap.xml` generation for search engine optimization.

---

## 🛠️ Getting Started

### 1. Run Locally with Docker Compose

To immediately start a local web server serving your blog:

```bash
docker compose up -d
```

Your blog will be accessible at [http://localhost:8080](http://localhost:8080). Editing articles or rebuilding will reflect immediately due to read-only volume mounting.

### 2. Creating a Post

To create a new markdown post, run the following command (requires your `$EDITOR` environment variable to be set, e.g., `export EDITOR=nano` or `export EDITOR=vim`):

```bash
./bb.sh post
```

This will open your text editor with a template where you can write your post. When you save and close the editor, the blog will regenerate.

### 3. Rebuilding the Blog

If you make modifications to the stylesheets, configuration, or `menu.yaml`, manually trigger a site-wide regeneration:

```bash
./bb.sh rebuild
```

### 4. Automatically Publishing a Post (Non-Interactive)

To automatically publish an article from an existing `.md` or `.html` file without open text editors or interactive prompts:

```bash
./bb.sh publish filename.md
```

#### Expected File Formats

- **Markdown (`.md`):** The first line of the file must be the title (e.g., `# My First Article`). Optionally, the second line can specify tags (e.g., `Tags: test, automagic`).
- **HTML (`.html`):** The first line of the file must contain the article title. Line 2 can contain a tags list (e.g., `<p>Tags: test, automagic</p>`).

### 5. Deleting a Post

To delete a post, run:

```bash
./bb.sh delete filename.html
```

Or run the command without arguments to start the **interactive deletion menu**:

```bash
./bb.sh delete
```

This lists all published posts, prompts for selection, requests a confirmation (`y/N`), deletes the selected post file, invalidates the metadata cache index, and regenerates all site index pages automatically.

---

## ⚙️ Configuration

### Navigation Menu (`menu.yaml`)

Define your header links, dropdown menus, and links. Our custom parser translates this structure dynamically:

```yaml
menu_entry_1:
  - text: Blog
  submenu_1_entry_1:
    - text: "Home"
      url: "index.html"
  submenu_1_entry_2:
    - text: "All Posts"
      url: "all_posts.html"
  submenu_1_entry_3:
    - text: "Tags"
      url: "all_tags.html"
menu_entry_2
  submenu_2_entry_1:
    - text: Progetti
  submenu_2_entry_2:
    - text: Portfolio
      url: "http://portfolio.rikbon.xyz"
menu_entry_3:
  - text: "Google"
    url: "https://www.google.com"
```

### Performance Profiles (`bb.sh`)

Modify variables at the top of `bb.sh` to configure cache levels:

- `performance_profile`: Set to `fast` (basic speed), `normal` (balanced caching/rebuilds), or `detailed` (aggressive optimization and detailed metrics).
- `enable_caching`: Toggle the metadata and tags caching layer (`true` / `false`).
- `enable_parallel_processing`: Run tag compilation concurrently across multiple CPU threads.
- `enable_sitemap`: Toggle generation of standard-compliant `sitemap.xml` file on rebuild (`true` / `false`).

---

## 🎨 Theme & Customization

The blog utilizes a modern, dark obsidian style system:

- **Typography:** Uses Google Fonts' `Outfit` font for headings and UI components.
- **Styling Files:** Custom rules are automatically initialized in [blog.css](blog.css) (grid layouts, dropdowns, and triggers) and [main.css](main.css) (dark-obsidian layout base, blocks, quotes, and typography reset).

To customize styles, edit the templates directly in the `create_css` function inside `bb.sh` to ensure they persist through resets.

---

## 📄 License

This project is licensed under the GNU General Public License v3.0. See the `LICENSE` info inside the source header of `bb.sh` for details.