npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodebb-plugin-veegie-blog-comments

v0.1.0

Published

NodeBB Blog Comments (Ghost / WP Commenting Engine) - Simple Topic Link. Forked modification of nodebb-plugin-blog-comments, replaces the comment thread with a forum topic link.

Downloads

47

Readme

NodeBB Blog Comments - Simple Topic Link

A heavily-simplified fork of nodebb-plugin-blog-comments by Andrew Rodrigues, replacing the comment thread display with a link to the created NodeBB topic. Only supports Ghost as of now, though it should be simple enough to adapt to Wordpress or a general PHP blog if you need to.

Ghost Installation

Paste this any where in yourtheme/post.hbs, somewhere between {{#post}} and {{/post}}.

<div id="nodebb"></div>
<!-- Use the nbb-post-header div to include any content you want to include that isn't part of the Ghost API post endpoint "html" field. It can also be left empty. This example adds the feature image, if one exists. -->
<div id="nbb-post-header" class="display-none"> 
    {{#if feature_image}}
	<div>
		<img src="{{../post.feature_image}}" alt="{{../post.title}}" />
	</div>
	{{/if}}
</div>
<div id="nbb-post-html" class="display-none"></div>

Then place the following script inside a {{#contentfor "scripts"}} block in your post.hbs template. All you have to edit is line 3 (nbb.url) - put the URL to your NodeBB forum's home page here.

<script type="text/javascript">
var nbb = {};
nbb.url = '//your.nodebb.com'; // EDIT THIS
nbb.cid = 1;	// OPTIONAL. Forces a Category ID in NodeBB.
				//  Omit it to fallback to specified IDs in the admin panel.

(function() {
nbb.articleID = '{{../post.id}}'; nbb.title = '{{../post.title}}';
nbb.tags = [{{#../post.tags}}"{{name}}",{{/../post.tags}}];
nbb.script = document.createElement('script'); nbb.script.type = 'text/javascript'; nbb.script.async = true;
nbb.script.src = nbb.url + '/plugins/nodebb-plugin-veegie-blog-comments/lib/ghost.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(nbb.script);
})();
$.get(ghost.url.api('posts/'+nbb.articleID, {absolute_urls: true})).done(function (data){
    document.getElementById('nbb-post-html').innerHTML = data.posts[0].html.replace('http://' + document.location.host, 'https://' + document.location.host);
}).fail(function  (err){
	console.log(err);
});
</script>

The corresponding {{{block "scripts"}}} definition will have to be placed at a point where jQuery has already been loaded. default.hbs is probably a good place for this.

As the latest version of Ghost no longer provides a Markdown template helper, nor a Markdown field from its post API endpoint, this fork uses the html field instead.

We retrieve the HTML content via the Ghost API using AJAX rather than through the Handlebars helper. We do this because, while you can retrieve the raw HTML of a post, there is currently no way to specify the use of absolute URLs for any embedded content using the Handlebars helper. As such, images and other uploaded content will not display properly. Using the API with the absolute_urls option alleviates this. Then we do a .replace to ensure that all embedded content from the same site is done using https, as the default is http for some reason.

The post's HTML is then parsed using Turndown to generate the Markdown used in the resulting forum post. Of course, this process isn't perfect (embedded tweets in the new Ghost editor become block-quotes, for example), and may require some tweaks for your specific blog/forum.

Publishing

Head over to the article that you'd like to publish. The code will detect if you're both an administrator of your blog and NodeBB (so ensure that you're logged into both) and will display a publish button if so.

You may also create a publishers group in NodeBB to allow a group of regular users to have publish rights.

Multiple blogs

You may use a comma-separated entry of blogs in the ACP to support publishing from a network of separate blogs to your forum. You can also choose to put each blog in its own dedicated category, or place them all into one category.