Skip to content

Yantar - Java Static Site Generator. A lightweight, extensible static site generator built with Java and following SOLID principles.

Notifications You must be signed in to change notification settings

hldevpro/Yantar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

** 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 **

Clone the repository

git clone git://github.com/hldevpro/yantar.git cd yantar

Build the project

mvn package

Add to your PATH (optional)

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 **

config.yaml

site: title: "My Static Site" baseUrl: "http://mysite.com" description: "A personal static site" author: "Ivan Ivanov"

i18n support

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 **

  1. HTML Elements: POJO representations of HTML tags
  2. Generators: HTML, sitemap, and page generators
  3. Processors: Markdown processor with code highlighting
  4. Template Engine: Freemarker-based layout system
  5. 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 **

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

** License **

MIT License - see LICENSE file for details.

About

Yantar - Java Static Site Generator. A lightweight, extensible static site generator built with Java and following SOLID principles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published