** Yantar - Java Static Site Generator ** A lightweight, extensible static site generator built with Java and following SOLID principles.
** Features **
- HTML Elements & Components: POJO-based HTML elements with custom composite components support
- Multi-format Support: Markdown and other markup languages (in next releases)
- Code Highlighting: Syntax highlighting with Jygments
- Sitemap Generation: Automatic sitemap.xml generation
- Live Development Server: Jetty-based server with auto-rebuild
- i18n Support: Multi-language website support
- Layout System: Freemarker-based templating
- Single JAR: Everything in one executable JAR
Technology Stack
- Core: Spring Framework
- Markup Processing: Markdown4J, Textile4j
- Templating: Freemarker
- YAML Parsing: SnakeYaml
- HTML Parsing: Jsoup
- Code Highlighting: Jygments
- Logging: Logback
- CLI Parsing: Args4j
- Web Server: Jetty
** Installation **
git clone git://github.com/hldevpro/yantar.git cd yantar
mvn package
export PATH=$(pwd)/target/yantar.jar:$PATH
** Quick Start ** ** Initialize a new site **
yantar -init
This creates a default site structure with:
layouts/ - Template files posts/ - Blog posts static/ - Static assets config.yaml - Site configuration
** Run development server **
yantar -make -serve
The server will:
- Generate the entire site
- Watch for file changes
- Auto-rebuild modified pages
- Serve the site at http://localhost:8080
** Build for production ** yantar -build
This generates the static site in the build directory.
** Project Structure **
. ├── layouts/ # Freemarker templates ├── posts/ # Blog posts (yyyy-MM-dd-title.mkd) ├── static/ # Static assets (css, js, images) ├── build/ # Generated site └── config.yaml # Site configuration
** Configuration **
site: title: "My Static Site" baseUrl: "http://mysite.com" description: "A personal static site" author: "Ivan Ivanov"
locales: en: name: "English" ru: name: "Russian"
** Architecture **
┌─────────────────────────────────────────┐ │ CLI Layer (Entry Point) │ │ Args4j + Commands │ └────────────────┬────────────────────────┘ │ ┌────────────────▼────────────────────────┐ │ Application Service Layer │ │ (Orchestration & Business Logic) │ │ SiteBuilder, PageGenerator, etc. │ └────────────────┬────────────────────────┘ │ ┌────────────────▼────────────────────────┐ │ Core Domain Layer │ │ Models: Page, Post, Site, Config │ └────────────────┬────────────────────────┘ │ ┌────────────────▼────────────────────────┐ │ Infrastructure Layer │ │ Parsers, Renderers, File I/O, Server │ │ Markdown4J, Textile4j, Freemarker, │ │ Jsoup, Jygments, SnakeYaml, Jetty │ └─────────────────────────────────────────┘
** Core Components **
- HTML Elements: POJO representations of HTML tags
- Generators: HTML, sitemap, and page generators
- Processors: Markdown processor with code highlighting
- Template Engine: Freemarker-based layout system
- CLI: Args4j-based command line interface
** Design Principles **
- SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- POJOs: Plain Old Java Objects for simplicity and testability
- Dependency Injection: Spring-based DI for loose coupling
- Extensibility: Plugin architecture for custom components and generators
** Usage Examples **
** Create a new post **
yantar new post "My First Post"
** Generate sitemap **
yantar generate sitemap
** Custom HTML component **
public class CardComponent extends HtmlElement { private String title; private String content;
public CardComponent(String title, String content) {
super("div");
this.title = title;
this.content = content;
addClass("card");
}
@Override
public String render() {
add(new HtmlElement("h2").setText(title));
add(new HtmlElement("p").setText(content));
return super.render();
}
}
** Contributing **
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
** License **
MIT License - see LICENSE file for details.