# Trifle::Docs [![Gem Version](https://badge.fury.io/rb/trifle-docs.svg)](https://badge.fury.io/rb/trifle-docs) ![Ruby](https://github.com/trifle-io/trifle-docs/workflows/Ruby/badge.svg?branch=main) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/trifle-io/trifle-docs) Simple documentation backend for your markdown files. Integrate your documentation or blog into your existing Rails application. `Trifle::Docs` maps your docs folder full of markdown files to your URLs and allows you to integrate it with same layout as the rest of your app. ![Demo App](demo.gif) ## Installation Install the gem and add to the application's Gemfile by executing: ```sh $ bundle add trifle-docs ``` If bundler is not being used to manage dependencies, install the gem by executing: ```sh $ gem install trifle-docs ``` ## Usage You can use this as a build-in Sinatra app or mount it in your Rails app. Sinatra configuration requires simple integration in your ruby file. ```ruby # app.rb require 'trifle/docs' Trifle::Docs.configure do |config| config.path = 'docs' config.templates = File.join(__dir__, '..', 'templates', 'simple') config.register_harvester(Trifle::Docs::Harvester::Markdown) config.register_harvester(Trifle::Docs::Harvester::File) end Trifle::Docs.App.run! ``` Rails configuration requires initializer and routes configuration. ```ruby # config/initializers/trifle.rb Trifle::Docs.configure do |config| config.path = File.join(Rails.root, 'docs') config.templates = File.join(Rails.root, 'app', 'views', 'trifle', 'docs') config.register_harvester(Trifle::Docs::Harvester::Markdown) config.register_harvester(Trifle::Docs::Harvester::File) end # config/routes.rb MyRailsApp::Application.routes.draw do # ... mount Trifle::Docs::App.new => '/docs' # ... end ``` Or use individual configuration per mount. ```ruby # config/routes.rb MyRailsApp::Application.routes.draw do # ... mount Trifle::Docs::App.new => '/docs' mount Trifle::Docs::App.new => '/blog' # ... end ``` ### Templates Please create two files in folder you provided the configuration. ```ruby # templates/layout.erb