docpad / docpad-plugin-multiplelayouts

Multiple layouts per document for DocPad
Other
10 stars 3 forks source link

New docs get created in docpad, but they don't actually get rendered / written (?) #9

Closed nfriedly closed 9 years ago

nfriedly commented 10 years ago

I'm importing documents from MongoDB and trying to send them to a second layout with this plugin. I poked around with the plugin, adding logging at various places, and for the most part it appears to be working correctly - it creates new docs, sets the layout, relativePath, etc. But they never get rendered - I just get 404's in development and there's no trace of the extra files in the static output. There are no errors logged in a normal docpad run.

The only thing I notice was that the new docs were keeping the url value from the old ones, but even after I modified the plugin to correct that, I still don't get rendered files.

My source documents look like this:

    {

        "id": "rave",
        "production": true,
        "name": "Visualization Rendering",
        "url": "visualization-rendering.html",
        "category": "relating",
        "urlIcon": "img/service-icons/rave.png",
        "urlGif": "img/service-gifs/rave.png",
        "shortDescription": "Graphical representations of data analysis for easier understanding",
        "description": "...",
        "urlDocumentation": "http://rave.mybluemix.net/learn.html",
        "urlJumpTo": "http://rave.mybluemix.net/downloads.html",
        "urlJumpToText": "Download SDK",
        "hideBluemix": true,
        "urlDemo": "@rave@",
        "needsTeam": false,
        "needsContent": false,
        "needsTraining": false,
        "team": false,
        "content": false,
        "training": false,
        "input": [
            "Data to be visualized and a visualization description"
        ],
        "output": [
            "Interactive visualizations of the input data in your application"
        ],
        "intendedUseHeadline": "This service is an SDK that can be used to visualize any numeric data.",
        "contentSet_beta": null,
        "domainModel_beta": null,
        "example": "..."
    }

And this is the relevant bits of my config:

  plugins:

    mongodb:
      collectionDefaults:
        connectionString: services?.mongolab?[0]?.credentials?.uri || "mongodb://localhost/localdev"
      collections: [
        {
          collectionName: "Service" # note: we define a sub-collection named "services" that skips some services in production
          injectDocumentHelper: (doc) ->
            doc.set('title', doc.get('name'))
            doc.set('relativePath', doc.get('url'))
          meta: {
            layout: 'service-landing-page'
            stylesheet: 'service.css'
            scripts: ['js/vendor/bootstrap-scrollspy.js', 'js/vendor/jquery-scrollto.js', 'js/service-landing-page.js']
            additionalLayouts: 'embed'
          }
          sort:
            name: 1 # alphabetically, A's first
        }
        #, ...
      ]

This is the MongoDB plugin I'm using: https://github.com/nfriedly/docpad-plugin-mongodb

And, lastly, I'm on windows if that makes a difference. (Although I don't think it does - cloned this repo and ran the tests and they all passed.)

Any idea what's going on?

nfriedly commented 10 years ago

Found it: my documents have an id field, and that apparently throws off DocPad - if I add id: null to the newDoc.setMeta call, then the new document actually gets written!

I think this is actually a bug in DocPad core - if two docs can't have the same ID, then doc.clone() / docpad.cloneModel() should remove the ID from the clone.

nfriedly commented 9 years ago

(I just deleted some of my comments because it was a silly tangent that distracted from the actual point.)