Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

docpad-plugin-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docpad-plugin-mongodb

Import your mongodb collections to DocPad collections

Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
10
900%
Maintainers
1
Weekly downloads
 
Created
Source

EXPERIMENTAL MongoDB Importer Plugin for DocPad

Import MongoDB collections into DocPad collections.

Inspired by https://github.com/simonh1000/docpad-plugin-mongo and based on https://github.com/docpad/docpad-plugin-tumblr/

Install

docpad install mongodb

Configuration

Simple example

Add the following to your docpad configuration file via:

plugins:
  mongodb:
    connectionString: "mongodb://localhost/blog" # format is "mongodb://username:password@hostname:port/dbname?options"
    collections: [
      collectionName: "posts"
      relativeDirPath: "blog"
      extension: ".md.html"
        meta:
          layout: "blogpost"
    ]

Customising the Output

The default directory for where the imported documents will go inside is the collectionName. You can customise this using the relativeDirPath plugin configuration option, the above example shows the posts collection going into the .

The default extension for imported documents is .json. You can customise this with the extension plugin configuration option.

The default content for the imported documents is the serialised tumblr data as JSON data. You can can customise this with the injectDocumentHelper plugin configuration option which is a function that takes in a single Document Model.

If you would like to render a partial for the tumblr data type, add a layout, and change the extension, you can this with the following plugin configuration:

extension: '.html.eco'
injectDocumentHelper: (document) ->
	document.setMeta(
		layout: 'default'
		tags: (document.get('tags') or []).concat(['post'])
		data: """
			<%- @partial('post/'+@document.tumblr.type, @extend({}, @document, @document.tumblr)) %>
			"""
	)

Creating a File Listing

As imported documents are just like normal documents, you can also list them just as you would other documents. Here is an example of a index.html.eco file that would output the titles and links to all the imported tumblr documents:

<h2>Blog:</h2>
<ul><% for file in @getFilesAtPath('blog/').toJSON(): %>
	<li>
		<a href="<%= file.url %>"><%= file.title %></a>
	</li>
<% end %></ul>

History

Discover the change history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Licensed under the incredibly permissive MIT license

Copyright © Bevry Pty Ltd us@bevry.me (http://bevry.me)

Keywords

docpad

FAQs

Package last updated on 16 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts