README
¶
Goro - Static Website Generator
Goro is a simple yet flexible static website generator built in Go. It allows you to build websites by composing web components and pages from HTML templates. The generated site is organized into a DIST_BASEPATH directory with support for assets and customizable components.
Features
- Web Component Support: Goro automatically registers and processes custom web components prefixed with
WEBCOMPONENT_PREFIX. This allows for reusable, modular HTML structures across your site. - Asset Management: Automatically copies and updates static assets from the
ASSETS_BASEPATHfolder to theDIST_BASEPATH/assetsdirectory, ensuring your assets are always up to date. - Recursive and Cyclic Detection: Ensures that your components are not recursively or cyclically dependent, avoiding rendering issues.
- Template-based Pages: Build your website pages from HTML templates stored in the
PAGES_BASEPATHdirectory.
Project Structure
COMPONENTS_BASEPATH/: Contains reusable HTML components that can be injected into pages.PAGES_BASEPATH/: HTML templates for each page on the site.ASSETS_BASEPATH/: Static files (e.g., CSS, JS, images) that will be copied to theDIST_BASEPATH/assets/directory.DIST_BASEPATH/: The output folder containing the fully generated site ready to be deployed.
How It Works
- Component Registration: The
loadComponent()function scans theCOMPONENTS_BASEPATH/directory for HTML files. Components with theWEBCOMPONENT_PREFIXprefix are registered and can be reused across different pages. - Page Compilation: Each HTML template in the
PAGES_BASEPATH/folder is parsed, compiled, and output into theDIST_BASEPATH/directory. - Asset Copying: Assets in the
ASSETS_BASEPATH/folder are copied to theDIST_BASEPATH/assetsdirectory. If an asset is already present and up to date, it will be skipped. - Component Population: Components are populated by analyzing their dependencies and checking for cyclic or recursive references before rendering.
Installation
- Clone this repository:
git clone https://github.com/yourusername/goro.git - Install dependencies:
go get - Build the project:
go build - Run Goro to generate your website:
./goro
Configuration
Web Component Prefix
The default prefix for custom web components is WEBCOMPONENT_PREFIX. You can modify this in the source code by adjusting the WEBCOMPONENT_PREFIX constant in config.go.
Allow is Attribute Components
Goro supports custom web components that extend native HTML elements using the is attribute. This feature is disabled by default due to limited browser support and potential performance considerations. To enable this feature, set the ALLOW_IS_TAG_COMPONENTS constant to true in the source code.
For example, enabling this would allow you to register and use components like:
<button is="wc-custom-button">Click Me</button>
Note: Only components with the WEBCOMPONENT_PREFIX (e.g., wc-) will be processed when this feature is enabled.
To enable this feature:
- Open the source file and locate the
ALLOW_IS_TAG_COMPONENTSconstant. - Set it to
true:
const ALLOW_IS_TAG_COMPONENTS = true
Keep in mind that support for the is attribute may vary across browsers, so it's recommended to test your site in different environments when using this feature.
TODO
-
Command-line Flags & Configuration File Support
Implement support for configuringgorothrough command-line flags or an external configuration file. This will allow users to specify important settings (like paths and flags) without needing to modify the source code. -
HTML Fragment Support
Add support for accepting partial HTML files (fragments) that can be inserted directly into pages without parsing or modification. This feature will make it easier to include raw HTML in specific parts of a page. -
Watch Mode for Automatic Rebuilds
Enable a watch mode that detects changes in theCOMPONENTS_BASEPATH,PAGES_BASEPATH, andASSETS_BASEPATH. When files are modified,gorowill automatically trigger a rebuild, streamlining the development process. -
goro initCommand
Introduce agoro initcommand to initialize a new project folder with default configurations. This command will generate a basic directory structure and a configuration file, helping users quickly set up their projects. -
Individual Page Compilation
Implement functionality to compile individual pages on demand instead of regenerating the entire site. This will speed up the build process when making small changes to a single page. -
Unused Components Report
Add a feature that reports any components defined in theCOMPONENTS_BASEPATH/directory that are not used anywhere in the project. This will help identify and clean up unused components. -
Configurable Log Level
Allow users to set the desired log level (e.g., info, warning, error) to reduce verbose output in the terminal during build processes. This will improve the user experience by limiting log noise during routine operations. -
Add Examples and Documentation
Create detailed examples and documentation to guide users on how to set up and usegoroeffectively. This should cover common use cases, configuration options, and how to structure projects. -
Add Tests
Develop unit and integration tests to cover common mistakes and edge cases ingoro's functionality. This will ensure stability and reliability as the project evolves.
⚠️ Project Status: Initial Phase
Note: goro is currently in its initial development phase, and its primary purpose is to fulfill my personal needs. While contributions and feedback are welcome, please be aware that there is no guarantee that pull requests or suggestions will be merged or even considered.
This project is evolving based on my own use cases and preferences, and its roadmap may not align with broader community needs or expectations.
Documentation
¶
There is no documentation for this package.