Giter Club home page Giter Club logo

middleman-disqus's Introduction

Middleman Disqus

Build Status Gem Version Dependency Status Code Climate

Middleman-Disqus is a Middleman extension that generates the Disqus embed code, and keeps your config in config.rb, where it belongs.

Installation

  1. Specify the dependency in your project's Gemfile:
# Gemfile
gem "middleman-disqus"
  1. Activate the Disqus extension in your project's config.rb. (n.b. read important information about shortnames)
# config.rb
activate :disqus do |d|
  d.shortname = 'your-shortname' # Replace with your Disqus shortname.
end
  1. In your layout or template call disqus and/or discus_count and include the results in the page:

Haml:

/ link with `#disqus_thread` is optional if not using `disqus_count` -->
%a{:href => "http://example.com/foo.html#disqus_thread"} Comments

= disqus
= disqus_count

ERB:

<!-- link with `#disqus_thread` is optional if not using `disqus_count` -->
<a href="http://example.com/foo.html#disqus_thread">Comments</a>

<%= disqus %>
<%= disqus_count %>

Helper methods

The following helper methods are available within your templates:

  • disqus will include the Disqus embed.js code and display comments.
  • disqus_count will include the Disqus count.js code for displaying a comment count on links when you set #disqus_thread to the href attribute.

Configuration: config.rb

activate :disqus do |d|
  # Disqus shotname, without '.disqus.com' on the end (default = nil)
  d.shortname = 'your_shortname'
end

Configuration: YAML Frontmatter

You can set per page configuration variables in the YAML Fontmatter, these are used as parameters for Disqus' behaviors and settings.

For full details about what they do, see Disqus JavaScript configuration variables

---
disqus_identifier: /2012/the-best-day-of-my-life.html
disqus_title: The best day of my life
disqus_url: http://example.com/2012/the-best-day-of-my-life.html
disqus_category_id: 4
disqus_disable_mobile: true
---

Page with YAML Frontmatter.

IMPORTANT: Do not use real shortnames during development

If you use the live/production shortname during development and testing, expect to litter your Disqus account with discussions that you can't delete!

You have two options:

  • Create a special testing/development shortname for use during development.
  • Only include Disqus in builds, not when running middleman server.

You can set different options for build and development by using Middleman's environment specific settings, for example:

# config.rb
configure :development do
  activate :disqus do |d|
    # using a special shortname
    d.shortname = "development-shortname"
    # or setting to `nil` will stop Disqus loading
    d.shortname = nil
  end
end

configure :build do
  activate :disqus do |d|
    # using a different shortname for production builds
    d.shortname = "production-shortname"
  end
end

License

Usage is provided under the MIT License. See the LICENSE file for the full details.

middleman-disqus's People

Contributors

clupprich avatar komor72 avatar lantins avatar simonrice avatar wikimatze avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.