-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Something wrong with the writeTemplate function, where it writes the same HTML from the first' posts' entry on my rooftopCMS into every page with that template for me. For example if i add console.logs:
function writeTemplate (ct, compiler, compilation, addDataTo, cb) {
const data = addDataTo.rooftop[ct.name]
const filePath = path.join(compiler.options.context, ct.template.path)
return node.call(fs.readFile.bind(fs), filePath, 'utf8')
.then((template) => {
return W.map(data, (item) => {
addDataTo = Object.assign(addDataTo, { item: item })
compiler.resourcePath = filePath
// webpack context is used by default in spike for plugins, so we need
// to mock it so that plugins dont crash
const fakeContext = { addDependency: (x) => x, resourcePath: filePath }
const options = loader.parseOptions.call(fakeContext, this.util.getSpikeOptions().reshape)
// W.map fires events as quickly as possible, so the locals will be
// swapped for the last item unless bound to the result function
return reshape(options)
.process(template)
.then(((locals, res) => {
console.log(ct.template.output(item));
const html = res.output(locals);
console.log(html);
compilation.assets[ct.template.output(item)] = {
source: () => html,
size: () => html.length
}
}).bind(null, Object.assign({}, options.locals)), cb)
})
})
}
I get:
pages/another-page.html
<!-- <extends src='views/layout.html'>
<block name='content'>
<h4>test</h4>
{{JSON.stringify(item)}}
<br><BR>
</block>
</extends> -->{"id":2,"date":"2017-08-08T05:04:35","date_gmt":"2017-08-08T05:04:35","modified":"2017-08-08T05:04:36","modified_gmt":"2017-08-08T05:04:36","slug":"sample-page","status":"publish","type":"page","title":"Here’s a Rooftop page","author":391,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"eee":[],"taxonomies":[],"forms":[],"content":{"basic":"<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\n<blockquote><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote>\n<p>...or something like this:</p>\n<blockquote><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\n<p>As a new Rooftop user, you should go to <a href=\"http://rooftopcms.io/docs/\">documentation</a> to delete this page and create new pages for your content. Have fun!</p>\n","advanced":[]}}
pages/about.html
<!-- <extends src='views/layout.html'>
<block name='content'>
<h4>test</h4>
{{JSON.stringify(item)}}
<br><BR>
</block>
</extends> -->{"id":2,"date":"2017-08-08T05:04:35","date_gmt":"2017-08-08T05:04:35","modified":"2017-08-08T05:04:36","modified_gmt":"2017-08-08T05:04:36","slug":"sample-page","status":"publish","type":"page","title":"Here’s a Rooftop page","author":391,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"eee":[],"taxonomies":[],"forms":[],"content":{"basic":"<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\n<blockquote><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote>\n<p>...or something like this:</p>\n<blockquote><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\n<p>As a new Rooftop user, you should go to <a href=\"http://rooftopcms.io/docs/\">documentation</a> to delete this page and create new pages for your content. Have fun!</p>\n","advanced":[]}}
pages/sample-page.html
<!-- <extends src='views/layout.html'>
<block name='content'>
<h4>test</h4>
{{JSON.stringify(item)}}
<br><BR>
</block>
</extends> -->{"id":2,"date":"2017-08-08T05:04:35","date_gmt":"2017-08-08T05:04:35","modified":"2017-08-08T05:04:36","modified_gmt":"2017-08-08T05:04:36","slug":"sample-page","status":"publish","type":"page","title":"Here’s a Rooftop page","author":391,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"eee":[],"taxonomies":[],"forms":[],"content":{"basic":"<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\n<blockquote><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote>\n<p>...or something like this:</p>\n<blockquote><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\n<p>As a new Rooftop user, you should go to <a href=\"http://rooftopcms.io/docs/\">documentation</a> to delete this page and create new pages for your content. Have fun!</p>\n","advanced":[]}}
compiled (2.868s)
Kindof messy to look at, but basically its calling the api correctly and writing the page urls correctly, but returning the same page data to every template, because options.locals returns the same page!
Metadata
Metadata
Assignees
Labels
No labels