### Display Parklife Version Source: https://parklife.dev/cli Outputs the currently installed version of the Parklife CLI. ```bash parklife version ``` -------------------------------- ### Syntax-Highlighted Code Block Example Source: https://parklife.dev/colophon An example demonstrating a syntax-highlighted code block, typically used for showcasing code within documentation. ```ruby if I.should(:stay) I.ll(:only).be in("your way") end ``` -------------------------------- ### Define Routes with Crawling Source: https://parklife.dev/config Use the `root` and `get` methods to define routes. Set `crawl: true` to discover and save all linked pages from a starting route. ```ruby Parklife.application.routes do # Starting at the root crawl and save every page encountered. root crawl: true # Also crawl these pages that aren't linked to from within the main site. get '/hidden/pages', crawl: true end ``` -------------------------------- ### Get HTML Content with Custom Base Path Source: https://parklife.dev/cli Retrieves the HTML content for a given path, useful for checking generated URLs with a custom base path. Pipe output to `bat` for syntax highlighting. ```bash parklife get / --base /foo | grep /link/to/check ``` ```bash parklife get /my/page | bat -lhtml ``` -------------------------------- ### Define Routes for Parklife Crawling Source: https://parklife.dev/rails Specify the routes Parklife should crawl, starting from the root and including specific paths like feeds, sitemaps, and hidden pages. ```ruby Parklife.application.routes do # Start from the homepage and crawl all links. root crawl: true # Some extra paths that aren't discovered by crawling links. get feed_path(format: :atom) get sitemap_path(format: :xml) # A couple more hidden pages. get easter_egg_path, crawl: true end ``` -------------------------------- ### Initialize Parklife Project Source: https://parklife.dev/cli Creates a starter `Parkfile` configuration and a static build script. Can be run safely in existing projects; it will prompt before overwriting files. ```bash parklife init ``` -------------------------------- ### Initialize Parklife Source: https://parklife.dev/ Run the parklife init command to generate a Parkfile configuration and build script. ```bash bundle exec parklife init ``` -------------------------------- ### Initialize Parklife for Rails Source: https://parklife.dev/rails Run the parklife init command to generate a Parkfile and a static-build script tailored for Rails. ```bash parklife init --rails ``` -------------------------------- ### Build Static Site with Parklife Source: https://parklife.dev/rails Execute `parklife build` to generate all routes and save them to the `build` directory for serving as a static site. ```bash $ find build -type f build/404.html build/about/index.html build/blog/2019/03/07/developers-developers-developers/index.html build/blog/2019/04/21/modern-life-is-rubbish/index.html build/blog/2019/05/15/introducing-parklife/index.html build/blog/index.html build/easter_egg/index.html build/easter_egg/surprise/index.html build/feed.atom build/index.html build/location/index.html build/sitemap.xml ``` -------------------------------- ### Build Static Site Source: https://parklife.dev/cli Crawl your application to create a static build. Use the `--base` flag to override the configured base path. ```bash parklife build ``` ```bash parklife build --base https://parklife.dev ``` -------------------------------- ### Initialize Parklife with GitHub Pages Integration Source: https://parklife.dev/cli Generates a `Parkfile`, `bin/static-build` script, and an additional GitHub Actions workflow for deploying to GitHub Pages. ```bash parklife init --github-pages ``` -------------------------------- ### Initialize Parklife with Sinatra Integration Source: https://parklife.dev/cli Adds Sinatra integration details to the `Parkfile` when initializing a new project. ```bash parklife init --sinatra ``` -------------------------------- ### Display Help Information Source: https://parklife.dev/cli Displays general help information for the Parklife CLI. Use `parklife help [COMMAND]` for specific command help. ```bash parklife help ``` -------------------------------- ### Initialize Parklife with Rails Integration Source: https://parklife.dev/cli Adds Rails integration to the `Parkfile` and `bin/static-build` script during project initialization. ```bash parklife init --rails ``` -------------------------------- ### Output Parklife Configuration Source: https://parklife.dev/cli Outputs the full Parklife configuration settings. ```bash parklife config ``` -------------------------------- ### Configure Application Instance Source: https://parklife.dev/config Assign a custom Rack application instance to Parklife's `app` configuration setting. ```ruby Parklife.application.config.app = my_rack_app ``` -------------------------------- ### Configure Build Directory Source: https://parklife.dev/config Set the build directory for Parklife output using the block form configuration. ```ruby Parklife.application.configure do |config| config.build_dir = 'build' end ``` -------------------------------- ### Configure Build Directory Source: https://parklife.dev/config Specify a custom directory for Parklife to save its build files. The default is 'build'. ```ruby Parklife.application.config.build_dir = 'my/build/dir' ``` -------------------------------- ### Configure 404 Handling to Warn Source: https://parklife.dev/config Sets Parklife to output a warning message to stderr and continue processing when a 404 response is encountered. This is useful for identifying broken links without stopping the build. ```ruby Parklife.application.config.on_404 = :warn ``` -------------------------------- ### Configure Build Directory Directly Source: https://parklife.dev/config Alternatively, set the build directory directly on the Parklife application configuration. ```ruby Parklife.application.config.build_dir = 'build' ``` -------------------------------- ### List Parklife Routes Source: https://parklife.dev/rails Use the `parklife routes` command to list all the routes that are included in your Parklife application configuration. ```bash $ bundle exec parklife routes / crawl=true /feed.atom /sitemap.xml /easter_egg crawl=true /404.html ``` -------------------------------- ### Configure ActiveStorage Service for Parklife Source: https://parklife.dev/rails Switch to Parklife's ActiveStorage service in `config/storage.yml` to enable asset collection during Parklife builds. ```yaml local: service: Parklife root: <%= Rails.root.join("storage") %> ``` -------------------------------- ### Use ActiveStorage with Parklife Integration Source: https://parklife.dev/rails Use ActiveStorage helpers as usual. Parklife automatically collects encountered attachments and copies them to the build directory. ```ruby # Pass a blob/attachment/preview/variant directly to helpers as usual: image_tag(blog_post.hero_image.variant(:medium)) # => video_tag(product.intro_video) # => # Ask a variant for its path: blog_post.hero_image.variant(:medium).processed.url # => "/parklife/blobs/6adews39uehd44spynetigykwssh/cute-cat.jpg" # Use the route helper: Rails.application.routes.url_helpers.parklife_blob_path( blog_post.hero_image.variant(:medium) ) # => "/parklife/blobs/6adews39uehd44spynetigykwssh/cute-cat.jpg" ``` -------------------------------- ### Enable Parklife ActiveStorage Integration Source: https://parklife.dev/rails Opt-in to Parklife's ActiveStorage integration by requiring the integration file in `config/application.rb` before the app boots. ```ruby require 'parklife-rails/activestorage' ``` -------------------------------- ### Configure Parklife Routes Source: https://parklife.dev/ Register routes within the Parkfile for Parklife to crawl and build. ```ruby Parklife.application.routes do root crawl: true end ``` -------------------------------- ### List Defined Routes Source: https://parklife.dev/cli Lists all defined routes within Parklife and indicates whether crawling is enabled for each route. ```bash $ parklife routes / crawl=true /feed.atom /sitemap.xml /easter_egg crawl=true /404.html ``` -------------------------------- ### Generate Full ActiveStorage URL with Parklife Source: https://parklife.dev/rails To generate a full URL (including hostname) for an ActiveStorage blob with Parklife, use `parklife_blob_url` and pass `only_path: false`. ```ruby Rails.application.routes.url_helpers.parklife_blob_url( blog_post.hero_image.variant(:medium), only_path: false, ) # => "http://example.com/parklife/blobs/6adews39uehd44spynetigykwssh/cute-cat.jpg" ``` -------------------------------- ### Configure Parkfile for Rails App Source: https://parklife.dev/rails Load your Rails application environment within the Parkfile to enable Parklife/Rails integration and access route helpers and models. ```ruby # Load your application, this activates the Parklife/Rails integration and gives # you access to route helpers and models in this file. require_relative 'config/environment' ``` -------------------------------- ### Configure Base URL Source: https://parklife.dev/config Set the base URL for Parklife requests, which is important for generating correct URLs, especially in production environments. ```ruby Parklife.application.config.base = 'https://parklife.dev' ``` -------------------------------- ### Define Static Routes Source: https://parklife.dev/config Register static routes for specific paths like API feeds or sitemaps that Parklife should generate. ```ruby Parklife.application.routes do get '/feed.atom' get '/sitemap.xml' end ``` -------------------------------- ### Define Content Model with Decant Source: https://parklife.dev/colophon Use Decant to define a model-like class for accessing content files. Specify the directory and file extension, and declare frontmatter fields for convenience. ```ruby # Define a model-like class to wrap the content. Page = Decant.define(dir: 'content', ext: 'md') do # Declare a frontmatter convenience reader. frontmatter :title end # Now find the page and work with it. page = Page.find('colophon') page.content # => "Colophon\n\nThis site is a"... page.frontmatter # => {:title=>"Colophon"} page.title # => "Colophon" ``` -------------------------------- ### Set Base URL for Subpath Hosting Source: https://parklife.dev/config Configure the base URL when your application will be hosted at a subpath, such as on GitHub Pages. This ensures links are generated correctly for the production environment. ```ruby Parklife.application.config.base = 'https://benpickles.github.io/parklife' ``` ```ruby Parklife.application.config.base = '/parklife' ``` -------------------------------- ### Add Parklife Gem Source: https://parklife.dev/ Add the Parklife gem to your application's Gemfile to begin using the library. ```ruby gem 'parklife' ``` -------------------------------- ### Define Routes with Rails Helpers Source: https://parklife.dev/config When Rails integration is enabled, use Rails route helpers within the Parklife routes block to define dynamic routes. ```ruby Parklife.application.routes do get hidden_pages_path, crawl: true get feed_path(format: :atom) get sitemap_path(format: :xml) end ``` -------------------------------- ### Disable Nested Index Files Source: https://parklife.dev/config Turn off the default behavior of storing files in an 'index.html' nested within a directory. This changes the storage for '/my/nested/route' from '/my/nested/route/index.html' to '/my/nested/route.html'. ```ruby Parklife.application.config.nested_index = false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.