JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34
  • Score
    100M100P100Q55407F
  • License MIT

A Docusaurus plugin for embedding Discourse comments

Package Exports

  • docusaurus-plugin-discourse-comments
  • docusaurus-plugin-discourse-comments/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (docusaurus-plugin-discourse-comments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Docusaurus Plugin: Discourse Comments

This plugin integrates Discourse comments into your Docusaurus 3 site, appending them after the <article> element without requiring modifications to your theme's Layout component.

Installation

npm install docusaurus-plugin-discourse-comments

Usage

Add the plugin to your docusaurus.config.js:

module.exports = {
  // ...other config
  plugins: [
    [
      'docusaurus-plugin-discourse-comments',
      {
        discourseUrl: 'https://your-discourse-instance.com/',
        debugMode: false, // Optional, default: false
        embedRoutes: ['/docs/*', '/blog/*'], // Optional, default: ['/docs/*', '/blog/*']
      },
    ],
  ],
};

The plugin will automatically insert Discourse comments after the <article> element on the specified routes.

Configuration Options

  • discourseUrl (required): The URL of your Discourse instance.
  • debugMode (optional): Enable debug logging. Default: false
  • embedRoutes (optional): An array of routes where the Discourse embed component will be inserted. Default: ['/docs/', '/blog/']

How it works

The plugin automatically injects the necessary scripts and handles the insertion and removal of Discourse comments as you navigate through your site. It appends the comments after the <article> element, which is typically where the main content of a Docusaurus page ends.

Testing from the Console

To test the Discourse comments component from the browser console:

  1. Open your browser's developer tools (usually F12 or right-click and select "Inspect").
  2. Go to the Console tab.
  3. To manually render the comments, run:
    window.renderDiscourseComments()
  4. If you want to inspect the component, you can access it via:
    window.DiscourseCommentsComponent

These methods are helpful for debugging and ensuring the component is working as expected.

Troubleshooting

If you're not seeing comments on your pages:

  1. Check that the discourseUrl is correct and points to a valid Discourse instance.
  2. Verify that the current route matches one of the embedRoutes patterns.
  3. Ensure that an <article> element exists on the page.
  4. Set debugMode: true in the plugin options to see more detailed logs in the browser console.
  5. Use the console methods described in the "Testing from the Console" section to manually trigger the component rendering.

License

MIT