Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permalinks not rendering pages added using glob or filename #9

Open
markdorrill opened this issue Sep 2, 2016 · 6 comments
Open

Permalinks not rendering pages added using glob or filename #9

markdorrill opened this issue Sep 2, 2016 · 6 comments

Comments

@markdorrill
Copy link

markdorrill commented Sep 2, 2016

Hi,

I've been learning assemble all week (previously knowing the grunt version), it really looks like powerful set of tools.

I've just been attempting to get a basic site outline set using the blog example from the main assemble repo. My aim is to use and this and submit a pr of a working example for other beginners.

The possible bug: It looks like pages are not rendering with permalinks when they have been added to a collection using a glob or single filename.

Also; what is the method to define new permanlink variables as :site.base returns a Failed to read error?

Here is my assemblefile that outlines a scenario to demonstrate this:

'use strict';

var path = require('path');
var extname = require('gulp-extname');
var permalinks = require('assemble-permalinks');
var getDest = require('view-get-dest');
var assemble = require('assemble');
var app = assemble();

/**
 * Plugins
 */

app.use(getDest());
app.use(permalinks());

app.data({
  site: {
    base: 'setfromdata'
  }
});

/**
 * Create views collection for our site pages and blog posts.
 * Posts will be written in markdown.
 */

app.create('pages');
app.create('posts', {
  pager: true,
  renameKey: function(key, view) {
    return view ? view.basename : path.basename(key);
  }
});

// add a page


/**
 * Register a handlebars helper for processing markdown.
 * This could also be done with a gulp plugin, or a
 * middleware, but helpers are really easy and provide
 * the most control.
 */

app.helper('markdown', require('helper-markdown'));
app.helper('link-to', require('helper-link-to'));
//app.helper('helper-not', require('assemble-helper-not'));

app.helper('log', function(val) {
  console.log(val);
});

/**
 * Tasks for loading and rendering our templates
 */

app.task('load', function(cb) {
  console.log('hello from load');

  app.page('thisis.md', {content: '...'}); // permalinks - works
  app.page('home.md', {content: '...'}); // permalinks - works

  app.page('src/templates/pages/blog.hbs'); // permalinks - not working

  app.partials('src/templates/includes/*.hbs'); // permalinks - not working
  app.layouts('src/templates/layouts/*.hbs'); // permalinks - not working
  app.pages('src/templates/pages/*.hbs'); // permalinks - not working
  app.posts('src/content/*.md'); // permalinks - working ** but rendering outside the dest folder **
  cb();
});

/**
 * Default task
 */

app.task('default', ['load'], function() {

  return app.toStream('pages')
    .pipe(app.toStream('posts'))
    .on('error', console.log)
    .pipe(app.renderFile('md'))
    .on('error', console.log)
    .pipe(extname())
    .pipe(app.permalink(app.data('site.base') + '/site/:name.html'))
    //.pipe(app.permalink(app.data(':site.base/site/:name.html'))) // Failed to read: :site.base/site/:name.html
    .pipe(app.dest('dest-example'));
    /*
    .pipe(app.dest(function(file) {
      file.path = file.data.permalink;
      file.base = path.dirname(file.path);
      return file.base;
    }));*/
});

/**
 * Expose your instance of assemble to the CLI
 */

module.exports = app;

@assemblebot
Copy link

@markdorrill Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

@markdorrill
Copy link
Author

Additionally, posts are getting rendered outside the set dest folder. I don't understand why this is?

@markdorrill
Copy link
Author

Version:
npm assemble -v 2.15.5

Output:
[14:25:47] using cwd ~/workspace/md-digital-frontend/example [14:25:48] using assemblefile ~/workspace/md-digital-frontend/example/assemblefile.example.js [14:25:49] starting assemble [14:25:49] starting assemble:default task [14:25:49] starting assemble:load task hello from load [14:25:49] finished assemble:load task [14:25:50] finished assemble:default task [14:25:50] finished assemble 1s [14:25:50] ✔ finished

@doowb
Copy link
Member

doowb commented Sep 2, 2016

Hi @markdorrill will you clean up the formatting of the code examples? You can edit the original post and use 3 ticks for blocks of code:

```js
var foo = 'bar';
```

I'll take a closer look in a little bit. I think some things have changed since the blog example was done, so it might just be a documentation update that's needed.

@markdorrill
Copy link
Author

markdorrill commented Sep 2, 2016

Thanks, that would be a great help.

I've cleaned up the op. Btw, I'm not using the blog example verbatim as I could see some bits were outdated (view events) so reduced it down in simplicity to where it is working.

When the permalinks line is disabled used in the default task, a full list of files is rendered (just comment out the .pipe(app.permalink in default task), hence the issue in this repo.

@markdorrill
Copy link
Author

UPDATE: I took another look and everything is being rendered, just in 3 different locations I didn't notice

pages added by object in assemblefile: dest (desired location)
glob added posts ../../ from dest
glob added pages ../../../ from dest

looks like its something to do with paths that I don't understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants