# frozen_string_literal: true usage 'create-site [options] path' aliases :create_site, :cs summary 'create a site' description 'Create a new site at the given path. The site will use the `filesystem` data source.' flag nil, :force, 'force creation of new site' param :path module Nanoc::CLI::Commands class CreateSite < ::Nanoc::CLI::CommandRunner class << self protected # Converts the given array to YAML format def array_to_yaml(array) '[ ' + array.map { |s| "'" + s + "'" }.join(', ') + ' ]' end end DEFAULT_CONFIG = <<~EOS unless defined? DEFAULT_CONFIG # A list of file extensions that Nanoc will consider to be textual rather than # binary. If an item with an extension not in this list is found, the file # will be considered as binary. text_extensions: #{array_to_yaml(Nanoc::Int::Configuration::DEFAULT_CONFIG[:text_extensions])} prune: auto_prune: true data_sources: - type: filesystem encoding: utf-8 EOS DEFAULT_RULES = <<~EOS unless defined? DEFAULT_RULES #!/usr/bin/env ruby compile '/index.html' do layout '/default.*' write '/index.html' end compile '/**/*.html' do layout '/default.*' write item.identifier.without_ext + '/index.html' end # This is an example rule that matches Markdown (.md) files, and filters them # using the :kramdown filter. It is commented out by default, because kramdown # is not bundled with Nanoc or Ruby. # #compile '/**/*.md' do # filter :kramdown # layout '/default.*' # write item.identifier.without_ext + '/index.html' #end compile '/**/*' do write item.identifier.to_s end layout '/**/*', :erb EOS DEFAULT_ITEM = <<~EOS unless defined? DEFAULT_ITEM --- title: Home ---
You’ve just created a new Nanoc site. The page you are looking at right now is the home page for your site. To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:
Change this page’s content by editing the “index.html” file in the “content” directory. This is the actual page content, and therefore doesn’t include the header, sidebar or style information (those are part of the layout).
Change the layout, which is the “default.html” file in the “layouts” directory, and create something unique (and hopefully less bland).
If you need any help with customizing your Nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!
EOS DEFAULT_STYLESHEET = <<~EOS unless defined? DEFAULT_STYLESHEET * { margin: 0; padding: 0; font-family: Georgia, Palatino, serif; } body { background: #fff; } a { text-decoration: none; } a:link, a:visited { color: #f30; } a:hover { color: #f90; } #main { position: absolute; top: 40px; left: 280px; width: 500px; } #main h1 { font-size: 40px; font-weight: normal; line-height: 40px; letter-spacing: -1px; } #main p { margin: 20px 0; font-size: 15px; line-height: 20px; } #main ul, #main ol { margin: 20px; } #main li { font-size: 15px; line-height: 20px; } #main ul li { list-style-type: square; } #sidebar { position: absolute; top: 40px; left: 20px; width: 200px; padding: 20px 20px 0 0; border-right: 1px solid #ccc; text-align: right; } #sidebar h2 { text-transform: uppercase; font-size: 13px; color: #333; letter-spacing: 1px; line-height: 20px; } #sidebar ul { list-style-type: none; margin: 20px 0; } #sidebar li { font-size: 14px; line-height: 20px; } EOS DEFAULT_LAYOUT = <<~EOS unless defined? DEFAULT_LAYOUT