-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 finding front matter #5
Comments
@rparree Thanks for the issue! If you're reporting a bug, please be sure to include:
|
@rparree sorry for missing this before. This plugin will use When the There are a couple of ways to use this to ensure the data is present when creating the permalink:
app.create('blog')
.use(permalink({
first: function (arr) {
return arr ? arr[0] : "";
}
}));
app.toStream('blog')
.pipe(app.permalink('blog/:first(categories)/:name.html'));
app.create('blog')
.use(permalink({
first: function (arr) {
return arr ? arr[0] : "";
}
}));
app.toStream('blog')
.pipe(through.obj(function(file, enc, next) {
file.permalink('blog/:first(categories)/:name.html'));
next(null, file);
})); The differences between these are that the You might also want to take a look at what we're doing in the assemble docs. We're using a custom plugin (view-events) to bubble up the permalink event to an application level handler called |
@rparree I updated this plugin so that it makes use of the
Sorry, the If you use it on a collection: Let me know if this is working for you. I've updated the assemblefile.js in the assemble docs to use this plugin on a collection. |
The following seems to work, but i now have another problem (see underneath the code) app.create("blog")
.use(permalinks({
first: function (arr) {
return arr ? arr[0] : ""
}
}));
app.blogs(['./src/templates/blog-pages/**', '!./src/templates/blog-pages/index*']);
function dest(dir) {
return function (file) {
var s = path.join(dir, path.dirname(file.data.permalink) + "/");
return s;
}
}
app.toStream("blogs")
.pipe(flatten())
.pipe(app.permalink('blog/:first(categories)/:name.html'))
.pipe(app.renderFile('*'))
.pipe(extname())
.pipe(app.dest(dest("./build/public/blog"))); In another file (in its own collection) i used to create links to the blog pages, but after a few (32 to be exact) the value the value of // absurl
module.exports = function(basedir){
return function(context){
return "/" + context.data.permalink
}
}; The helper {{#each blogs }}
<a href="{{absurl .}}" >
<div class="grid-item {{#each data.categories}} cat-{{this}} {{/each}}"
data-date="{{formatDate data.date 'YYYYMMDD'}}" data-categories="{{data.categories}}">
<span class="title">{{data.title}}</span></div></a>
{{/each}} An example rendered result is: <!-- above also all working correctly-->
<a href="/blog/web/get-familiar-with-backbone-js.html" >
<div class="grid-item cat-web "
data-date="20130920" data-categories="web">
<span class="title">Get Familiar with Backbone.js</span></div></a>
<a href="/undefined" >
<div class="grid-item cat-java "
data-date="20140408" data-categories="java">
<span class="title">Glassfish - Commercial to Open Source</span></div></a>
<!-- all below have "undefined" --> |
Never mind the last problem, async problem. Solved it by processing the index after the articles have completed: app.build('assemble-blog', function (err) {
if (err) throw err;
app.build('assemble-blog-index', function (err) {
if (err) throw err
});
}); |
I am in the process of creating a docker image for my site. During the process i am upgrading as much as i can (node
4.4.2
, assemble:~0.16.0
, assemble-permalinks:0.3.1
).However now the permalinks no longer find data from the front matter data:
The code
Now throws an error that it can't find
categories
.The text was updated successfully, but these errors were encountered: