# fushaolei/hexo-theme-white architecture

> Architecture diagram of the GitHub repository fushaolei/hexo-theme-white, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fushaolei/hexo-theme-white
- Repository: https://github.com/fushaolei/hexo-theme-white

## Overview

##### Main Components
- Hexo Core: The static site generator that reads the site content and, using the theme, renders the final HTML pages.
- Theme Configuration: The _config.yml file at the root sets up the theme and its options.
- Layout Templates: The “layout” directory contains various EJS templates (e.g., layout.ejs, index.ejs, post.ejs, header.ejs, footer.ejs) which define the structure of different pages.
- Partial Templates & Plugins: Within “layout/_partial” and “layout/_plugins,” you have modular templates (e.g., header, footer, toc) and plugins (such as tocbot integration) that are reused across multiple layouts.
- Assets Management: The “source” directory holds CSS (with subdirectories for common, page-specific, and utility stylus files) and JavaScript files (in source/js) that dictate the theme’s styles and client-side behaviors.
- Custom Scripts: The “scripts” directory contains additional JavaScript, such as lazyload and configurator scripts, which enhance interactivity and configuration setup.
- Documentation & Metadata: Files like README.md, LICENSE, and CHANGELOG.md provide context, licensing, and versioning information.

##### Relationships and Interactions
- The Hexo core engine reads configuration from _config.yml, which, among other things, specifies the active theme.
- Partial templates (found in “layout/_partial”) are incorporated into these page layouts, ensuring consistent headers, footers, and navigation across the site.
- The “source” directory provides CSS and JS assets that are integrated within the generated page markup. For example, CSS inside “source/css” styles the HTML, while JavaScript in “source/js” (and additional libraries like “tocbot” in “source/lib”) adds dynamic functionalities.
- Custom scripts (in the “scripts” folder) might be used during the build or deployed for client-side enhancements, affecting how assets are loaded or configured.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The theme cleanly separates layout (EJS templates), styling (CSS/Stylus files), and behavior (JavaScript), which simplifies maintenance and extension.
- Modular Design: Pages are composed of partials (header, footer, etc.), enabling a modular approach to code reuse and easier updates across multiple page views.
- Template Inheritance and Reuse: The use of common base layouts (e.g., layout.ejs) that other templates extend helps maintain consistency and simplifies changes.

##### Essential Elements
- Clear labels for each identified component (e.g., “Hexo Core,” “Theme Configuration,” “Layout – Post Template,” “CSS Assets,” etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    Hexo["Hexo Core"]:::core
    ThemeConfig["_config.yml"]:::config
    Layout["Layout Templates"]:::template
    Custom["Custom Scripts"]:::scripts
    Docs["Documentation & Metadata"]:::docs

    %% Sub-components of Layout Templates: Page Templates
    LayoutEJS["layout.ejs"]:::pageTemplates
    IndexEJS["index.ejs"]:::pageTemplates
    PostEJS["post.ejs"]:::pageTemplates
    ArchiveEJS["archive.ejs"]:::pageTemplates
    CategoryEJS["category.ejs"]:::pageTemplates
    PageEJS["page.ejs"]:::pageTemplates
    SearchEJS["search.ejs"]:::pageTemplates
    TagEJS["tag.ejs"]:::pageTemplates

    %% Partial Templates under Layout
    Partial["Partial Templates"]:::partial
    Header["header.ejs"]:::partial
    Footer["footer.ejs"]:::partial
    Head["head.ejs"]:::partial
    ArchivePartial["archive.ejs"]:::partial
    Toc["toc.ejs"]:::partial
    Homepage["homepage.ejs"]:::partial
    ModeHome["mode-home.ejs"]:::partial
    ModeImg["mode-img.ejs"]:::partial
    ModeSimple["mode-simple.ejs"]:::partial
    AfterFooter["after-footer.ejs"]:::partial

    %% Assets Management
    Assets["Assets Management (source)"]:::assets
    Css["CSS Assets (white.styl & Others)"]:::assets
    Js["JS Assets"]:::assets

    %% Plugin Integrations
    LayoutPlugins["Layout Plugins (tocbot.ejs)"]:::plugins
    LibPlugins["tocbot Library"]:::plugins

    %% Custom Scripts details
    LazyLoad["lazyload.js"]:::scripts
    ReplaceConfig["replace-config.js"]:::scripts

    %% Documentation Details
    Readme["README.md"]:::docs
    License["LICENSE"]:::docs
    Changelog["CHANGELOG.md"]:::docs

    %% Connections from Hexo Core
    Hexo -->|"reads"| ThemeConfig
    Hexo -->|"renders"| Layout
    Hexo -->|"uses"| Custom
    Hexo -->|"refers"| Docs

    %% Layout Templates connections
    Layout -->|"contains"| LayoutEJS
    Layout -->|"contains"| IndexEJS
    Layout -->|"contains"| PostEJS
    Layout -->|"contains"| ArchiveEJS
    Layout -->|"contains"| CategoryEJS
    Layout -->|"contains"| PageEJS
    Layout -->|"contains"| SearchEJS
    Layout -->|"contains"| TagEJS
    Layout -->|"includes"| Partial
    Layout -->|"links to"| Assets
    Layout -->|"integrates"| LayoutPlugins
    Layout -->|"integrates"| LibPlugins

    %% Partial Templates breakdown
    Partial -->|"includes"| Header
    Partial -->|"includes"| Footer
    Partial -->|"includes"| Head
    Partial -->|"includes"| ArchivePartial
    Partial -->|"includes"| Toc
    Partial -->|"includes"| Homepage
    Partial -->|"includes"| ModeHome
    Partial -->|"includes"| ModeImg
    Partial -->|"includes"| ModeSimple
    Partial -->|"includes"| AfterFooter

    %% Assets breakdown
    Assets -->|"provides"| Css
    Assets -->|"provides"| Js

    %% Custom Scripts breakdown
    Custom -->|"contains"| LazyLoad
    Custom -->|"contains"| ReplaceConfig

    %% Documentation breakdown
    Docs --> Readme
    Docs --> License
    Docs --> Changelog

    %% Click Events for Component Mapping
    click ThemeConfig "https://github.com/fushaolei/hexo-theme-white/blob/master/_config.yml"
    click Layout "https://github.com/fushaolei/hexo-theme-white/tree/master/layout"
    click LayoutEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/layout.ejs"
    click IndexEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/index.ejs"
    click PostEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/post.ejs"
    click ArchiveEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/archive.ejs"
    click CategoryEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/category.ejs"
    click PageEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/page.ejs"
    click SearchEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/search.ejs"
    click TagEJS "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/tag.ejs"
    click Partial "https://github.com/fushaolei/hexo-theme-white/tree/master/layout/_partial"
    click Header "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/header.ejs"
    click Footer "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/footer.ejs"
    click Head "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/head.ejs"
    click ArchivePartial "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/archive.ejs"
    click Toc "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/toc.ejs"
    click Homepage "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/homepage.ejs"
    click ModeHome "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/mode-home.ejs"
    click ModeImg "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/mode-img.ejs"
    click ModeSimple "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/mode-simple.ejs"
    click AfterFooter "https://github.com/fushaolei/hexo-theme-white/blob/master/layout/_partial/after-footer.ejs"
    click LayoutPlugins "https://github.com/fushaolei/hexo-theme-white/tree/master/layout/_plugins"
    click LibPlugins "https://github.com/fushaolei/hexo-theme-white/tree/master/source/lib/tocbot"
    click Css "https://github.com/fushaolei/hexo-theme-white/tree/master/source/css"
    click Js "https://github.com/fushaolei/hexo-theme-white/tree/master/source/js"
    click Custom "https://github.com/fushaolei/hexo-theme-white/tree/master/scripts"
    click LazyLoad "https://github.com/fushaolei/hexo-theme-white/blob/master/scripts/lazyload.js"
    click ReplaceConfig "https://github.com/fushaolei/hexo-theme-white/blob/master/scripts/replace-config.js"
    click Readme "https://github.com/fushaolei/hexo-theme-white/blob/master/README.md"
    click License "https://github.com/fushaolei/hexo-theme-white/tree/master/LICENSE"
    click Changelog "https://github.com/fushaolei/hexo-theme-white/blob/master/CHANGELOG.md"

    %% Style Definitions
    classDef core fill:#f1c40f,stroke:#e67e22,stroke-width:2px;
    classDef config fill:#1abc9c,stroke:#16a085,stroke-width:2px;
    classDef template fill:#3498db,stroke:#2980b9,stroke-width:2px;
    classDef pageTemplates fill:#34495e,stroke:#2c3e50,stroke-width:2px;
    classDef partial fill:#9b59b6,stroke:#8e44ad,stroke-width:2px;
    classDef assets fill:#2ecc71,stroke:#27ae60,stroke-width:2px;
    classDef plugins fill:#d35400,stroke:#e67e22,stroke-width:2px;
    classDef scripts fill:#e74c3c,stroke:#c0392b,stroke-width:2px;
    classDef docs fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px;
```
