https://github.com/adam12/inert
An experimental static site builder with unambitious goals.
https://github.com/adam12/inert
roda ruby static-site static-site-generator
Last synced: about 1 year ago
JSON representation
An experimental static site builder with unambitious goals.
- Host: GitHub
- URL: https://github.com/adam12/inert
- Owner: adam12
- License: mit
- Created: 2017-11-07T20:06:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-27T16:17:11.000Z (over 1 year ago)
- Last Synced: 2025-04-07T05:43:26.123Z (about 1 year ago)
- Topics: roda, ruby, static-site, static-site-generator
- Language: Ruby
- Size: 71.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Inert
An experimental static site builder with unambitious goals.
## Project Goals
- Be fast
- Allow reading of YAML frontmatter
- Allow queueing of manual URLs for preservation
## Usage
Install the gem:
gem install inert
Create a few folders:
mkdir static views
And a layout file:
echo "<%= yield %>" > views/layout.erb
And then start the Inert server:
inert
When you're ready to deploy, build the site:
inert build
## Configuring
By default, Inert expects a few things, and should work without configuration.
Because it's built on top of Roda, it's very easily extendable, and Inert
provides hooks to do this via the `Inertfile` it will read from your project
root at runtime.
```ruby
# Inertfile
Inert.config do |inert|
inert.helpers do
def generator
"Inert v#{Inert::VERSION}"
end
end
inert.app do
plugin :h
end
inert.routes do |r|
r.on "employees.html" do
@employees = [] # Read in actual data here
view("employees.html.erb")
end
end
end
```
## Asset Fingerprinting
Use asset fingerprinting to enable max-cache times on all your static assets.
```ruby
# Inertfile
Inert.config do |inert|
inert.app do
plugin :timestamp_public
end
inert.routes do |r|
r.timestamp_public
end
end
```
And inside your views, use the `timestamp_path` helper with the name of the file
in `static/` wherever you'd just use the filename itself:
```ruby
">
```
## Asset Minification
Use asset minification to compile and compress all your CSS and JS assets into
a single file.
```ruby
# Inertfile
Inert.config do |inert|
inert.app do
plugin :assets, css: %w"text.css layout.css"
compile_assets if Inert.building?
end
inert.routes do |r|
r.assets
end
end
```
And inside your layout, use the `assets` helper with the name of the asset group:
```ruby
<%= assets(:css) %>
```
Make sure you put your assets in `assets/group`. For the example above, you'd have
`assets/css/text.css` and `assets/css/layout.css`.
## Live Reloads
Use the `roda-live_reload` gem to enable live reloads:
```ruby
# Gemfile
gem "roda-live_reload"
gem "puma" # Webrick wont' currently work with roda-live_reload
# Inertfile
Inert.config do |inert|
inert.app do
plugin :live_reload if Inert.development?
end
inert.routes do |r|
r.live_reload if Inert.development?
end
end
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/adam12/inert.
I love pull requests! If you fork this project and modify it, please ping me to see
if your changes can be incorporated back into this project.
That said, if your feature idea is nontrivial, you should probably open an issue to
[discuss it](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/)
before attempting a pull request.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).