Turn Rails into a real static site generator
Perron is a Rails-based static site generator—start a new site easily
Used 2 times
E
Eelco from Rails Designer
Usage
Perron is Rails-based Static Site Generator. Create static sites with the framework you love. ❤️
This template was taken from the official docs site.
Start your next site by running this command:
This template was taken from the official docs site.
Start your next site by running this command:
rails new MyNewSite --minimal -T -O -m https://railsbytes.com/script/VQLsND
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/VQLsND"
Template Source
Review the code before running this template on your machine.
gsub_file "Gemfile", /gem "sqlite3".*$/, ""
gsub_file "Gemfile", /gem "activerecord".*$/, ""
remove_file "config/database.yml"
remove_file "config/credentials.yml.enc"
remove_file "config/master.key"
remove_file "public/400.html"
remove_file "public/406-unsupported-browser.html"
remove_file "public/422.html"
remove_file "public/500.html"
run "rm -r app/views/pwa"
remove_file "app/controllers/application_controller.rb"
create_file "app/controllers/application_controller.rb", <<~RB
class ApplicationController < ActionController::Base
end
RB
remove_file "app/views/layouts/application.html.erb"
create_file "app/views/layouts/application.html.erb", <<~ERB
<!DOCTYPE html>
<html lang="en">
<head>
<%= meta_tags %>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= yield :head %>
<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<%= stylesheet_link_tag :app %>
<!-- Learn more on https://attractivejs.railsdesigner.com/ -->
<script defer src="https://cdn.jsdelivr.net/npm/attractivejs@latest"></script>
</head>
<body>
<%= yield %>
</body>
</html>
ERB
append_to_file ".gitignore", "/output/\n"
gem "perron"
after_bundle do
rails_command("generate perron:install")
markdown_gem = ask("Which markdown parser would you like to use? (commonmarker/kramdown/redcarpet or leave blank to skip):")
VALID_MARKDOWN_GEMS = %w[commonmarker kramdown redcarpet]
gem_name = markdown_gem.strip.downcase
if VALID_MARKDOWN_GEMS.include?(gem_name)
uncomment_lines "Gemfile", /gem "#{gem_name}"/
Bundler.with_unbundled_env { run "bundle install" }
elsif markdown_gem.present?
say "Invalid markdown parser option. Skipping…", :yellow
end
end
remove_file "README.md"
create_file "README.md", <<~MARKDOWN
# #{app_name.titleize}
TBD
## Development
```
bin/dev
```
## Deploy/publish
```
bin/rails perron:build
```
MARKDOWN