mbanting / metalsmith-prismic

A Metalsmith.io plugin to pull in content from Prismic.io
MIT License
48 stars 19 forks source link

Create files based on prismic query results. #5

Closed galeksic90 closed 10 years ago

galeksic90 commented 10 years ago

Hi,

I have one more question, how metalsmith can loop the prismic for example blog posts and create .md file for each?

Here is example how to loop metalsmith collection, but how i can loop prismic query? http://www.gelatindesign.co.uk/blog/post/creating-a-blog-with-metalsmith/

mbanting commented 10 years ago

I've been thinking about adding this functionality into the plugin itself. Perhaps something like a source file that has the Prismic YAML containing

This one file could then generate the multiple files based on the collection returned by the query.

galeksic90 commented 10 years ago

Exactly! I had been thinking about the same solution, that would be great.

Do you plan to make it this days?

I need to publish 1 site in few days so i don't know what i should do, make files manually or wait for feature. :)

Thanks

mbanting commented 10 years ago

Currently in progress. We need this too. Hopefully something in a day or two if all goes according to plan.

mbanting commented 10 years ago

Available in 0.4.0. Give it a try and provide any feedback. Thanks!

galeksic90 commented 10 years ago

Hello,

Great job!

I have tried and its working wonderful but when i want to use link resolver nothing happen.

.use(prismic({
        "url": "xxxxxxxxxxxxxxxxx",
        "linkResolver": function(doc) {
            return '/news/' + doc.slug;
        }
    }
    ))

Also i have tried your code from test folder.

"linkResolver": function (ctx, doc) {
                    if (doc.isBroken) return false;
                    return '/' + doc.type + '/' + doc.slug + (ctx.maybeRef ? '?ref=' + ctx.maybeRef : '');
                }

And still nothing happen..

It builds always by default linkresolver funcion.

screen shot 2014-08-21 at 14 27 34

mbanting commented 10 years ago

Thanks. Created Issue #7 to track this.