Giter Club home page Giter Club logo

docpad-plugin-tags's Introduction

Tags Plugin for DocPad

Travis CI Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
GitHub Sponsors donate button Patreon donate button Flattr donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button Wishlist browse button

Create tag pages within DocPad

Configuration

Customising the Output

The default directory for where the imported documents will go inside is the tags directory. You can customise this using the relativeDirPath plugin configuration option.

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 tag 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 imported document, add a layout, and change the extension, you can this with the following plugin configuration:

extension: '.html.eco'
injectDocumentHelper: (document) ->
	document.setMeta(
		layout: 'default'
		data: """
			<%- @partial('content/tag', @) %>
			"""
	)

You can find a great example of this customisation within the syte skeleton which combines the tags plugin with the partials plugin as well as the tumblr plugin and paged plugin.

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 tag documents:

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

Install

Install this DocPad plugin by entering docpad install tags into your terminal.

History

Discover the release 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.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

GitHub Sponsors donate button Patreon donate button Flattr donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

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

License

Unless stated otherwise all works are:

and licensed under:

docpad-plugin-tags's People

Contributors

balupton avatar dependabot[bot] avatar robloach avatar vsopvsop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docpad-plugin-tags's Issues

Override tag files meta

I am looking to override the default title generation and thought I could do it with the document injection helper along the lines of the code below.

I was hoping I could pull tagName from document as it seems to exist and was hoping someone could steer me in the right direction.

tags:
    extension: '.html.eco'
    injectDocumentHelper: (document) ->
        document.setMeta(
            layout: 'page'
            title: "Posts "+document.tagName
            data: """
            <%- @partial('content/tag', @) %>
            """
        )

Error when visiting tag pages

Hi, new Docpad user here, so please excuse me if I fail to provide relevant information.

Using the latest versions of Docpad and your tags plugin as of this morning. I have a setup like so:

tags:
  extension: ".html.jade"
  injectDocumentHelper: (document) ->
    document.setMeta(
      layout: 'default'
      data: "!=partial('tag')"
    )

I get correctly-formatted tag pages in out/tags/whatever.html.

I'm using cleanurls. If I hit http://localhost:9778/tags/sometag, I get the following error:

TypeError: Cannot read property 'size' of null
at DocPad.serveDocument (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:4098:50)
at DocPad.serveDocument (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:5:61)
at /home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:4143:23
at DocPad.getFileByRoute (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:593:7)
at DocPad.serverMiddlewareRouter (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:4133:14)
at Object.handle (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:5:61)
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at pass (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/lib/router/index.js:110:24)
at Router._dispatch (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/lib/router/index.js:173:5)
at Object.router (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/lib/router/index.js:33:10)
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at DocPad.serverMiddlewareHeader (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:4126:7)
at Object.handle (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/out/lib/docpad.js:5:61)
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.handle (/home/nolan/Projects/thewordnerd.info/docpad.coffee:78:20)
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.methodOverride as handle
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.json as handle
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.urlencoded as handle
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.expressInit as handle
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.query as handle
at next (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Function.app.handle (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/proto.js:201:3)
at app (/home/nolan/Projects/thewordnerd.info/node_modules/docpad/node_modules/express/node_modules/connect/lib/connect.js:65:37)
at EventEmitter.emit (events.js:98:17)
at request (/home/nolan/Projects/thewordnerd.info/node_modules/docpad-plugin-livereload/node_modules/primus/transformer.js:135:36)
at Server.EventEmitter.emit (events.js:98:17)
at HTTPParser.parser.onIncoming (http.js:2108:12)
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at Socket.socket.ondata (http.js:1966:22)
at TCP.onread (net.js:525:27)

I tried hitting tags/whatever.html since I'm using cleanurls and I wondered if that might be an issue, but no luck. I only see this with tag pages; others on my site seem to generate and render fine.

Thoughts? Please let me know if I can provide more details. I'm new enough at Docpad that I don't quite understand what interacts with what else and how. Thanks!

Confused about name...

@balupton
The plugin name is docpad-plugin-tags, and has a description which describes tags pages.

Yet it seems to be a Tumblr importer plugin... Perhaps you confused projects?

Sorting?

Just a quick query - would it be possible to add a sort? or at least respect the sort in the supplied collection?

I have a huge list of back-catalogue of articles tagged as reviews, which start in 1996 - and are only really there for my benefit. The the reviews collection looks like this:

reviews: ->
    @getCollection('documents').findAllLive({relativeOutDirPath: 'posts', tags: $in: 'Reviews' }, [{date: -1}])

and the options for the tag

    plugins:
        # Tags
        tags:
            extension: '.html.eco'
            injectDocumentHelper: (document) ->
                document.setMeta(
                    layout: 'default'
                        data: """
                            <%- @partial('tag', @) %>
                            """
                )

Am I missing something?

Pagination of Tag Listing

Create a Partial for the tag listing page:

<div class="articles">
    <% for file in @getFiles(tags: $has: @document.tag).toJSON(): %>
        <%- @partial('tile', false, {'document': file) %>
    <% end %>
</div>

The above works, however, adding pagination to the tagged list is problematic as the partials don't quite support it.

Support subdirectory value for relativeDirPath

I'm trying to render tags to 'blog/tagged', but this does not seem to work, it throws the following error:

error: Something went wrong with the action
error: An error occured: 
TypeError: Cannot read property 'length' of undefined
  at Object.eval (<anonymous>:54:35)
  at Object.eval (<anonymous>:75:8)
  at eval (<anonymous>:77:6)
  at Function.eco.render (/home/nathan/Projects/komodo-website/node_modules/docpad-plugin-eco/node_modules/eco/lib/index.js:26:25)
  at EcoPlugin.render (/home/nathan/Projects/komodo-website/node_modules/docpad-plugin-eco/out/eco.plugin.js:24:32)
  at ambi (/home/nathan/Projects/komodo-website/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:25:27)
  at Task.<anonymous> (/home/nathan/Projects/komodo-website/node_modules/docpad/node_modules/event-emitter-grouped/out/lib/event-emitter-grouped.js:45:23)
  at ambi (/home/nathan/Projects/komodo-website/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:23:18)
  at fire (/home/nathan/Projects/komodo-website/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:162:23)
  at b (domain.js:183:18)
  at Domain.run (domain.js:123:23)
  at Task.fire (/home/nathan/Projects/komodo-website/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:169:25)
  at processImmediate [as _immediateCallback] (timers.js:330:15)

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.