58 lines
1.3 KiB
Ruby
58 lines
1.3 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require "ryo"
|
|
require "ryo/json"
|
|
require "nanoc-gzip"
|
|
require "nanoc-webpack"
|
|
require "nanoc-tidy"
|
|
require_relative "nanoc/lib/require_rules"
|
|
|
|
##
|
|
# Common vars
|
|
locales = %w[ar en]
|
|
json_dir = File.join(Dir.getwd, "src", "json")
|
|
name_by_id = Ryo.from_json_file("#{json_dir}/nameById.json")
|
|
i18n = Ryo.from_json_file("#{json_dir}/i18n.json")
|
|
buildenv = ENV["buildenv"] || "development"
|
|
Nanoc::Webpack.default_options.merge!(
|
|
"--config" => "webpack.#{buildenv}.js"
|
|
)
|
|
Nanoc::Tidy.default_options.merge!(
|
|
"-upper" => true
|
|
)
|
|
|
|
##
|
|
# See packages/typescript/postman
|
|
compile "/css/postman.scss" do
|
|
filter :sass, syntax: :scss, style: :compact
|
|
filter :rainpress
|
|
write("/css/postman.css")
|
|
end
|
|
|
|
##
|
|
# /sitemap.xml
|
|
compile "/sitemap.xml.erb" do
|
|
filter(:erb, locals: {locales:, name_by_id:})
|
|
filter(:strip)
|
|
write("/sitemap.xml")
|
|
end
|
|
|
|
##
|
|
# /robots.txt
|
|
compile "/robots.txt" do
|
|
write("/robots.txt")
|
|
end
|
|
|
|
##
|
|
# Require rules
|
|
require_rules "nanoc/rules/assets"
|
|
require_rules "nanoc/rules/redirect"
|
|
require_rules "nanoc/rules/random", {locales:}
|
|
require_rules "nanoc/rules/stream", {locales:, i18n:, name_by_id:}
|
|
require_rules "nanoc/rules/index", {locales:, i18n:}
|
|
|
|
##
|
|
# Defaults
|
|
compile("/**/*") { write(nil) }
|
|
layout("**/*", :erb)
|