porting a jekyll site to nodejs #291
Replies: 19 comments
-
The front matter and In case you want do it from scratch, the scope you passed in should be look like this: parseAndRender(template, {
page: { nomenu: false, fullname: 'foo', title: 'bar' }
}) And since the front matter is not supported by LiquidJS, you'll need the layout tag. Always feel free to create your first Discussion! |
Beta Was this translation helpful? Give feedback.
-
Ik and I pass all the data it needs to render the site (see code block below) and it sill not working right. I think it needs to able to pass the data from the site and page to all other layout and include but is not doing that write. i try setting it as globals and passing it into parseAndRender (individually and at the same time). What am i doing wrong?
if need i can put the code up on github. |
Beta Was this translation helpful? Give feedback.
-
just notes it not the same page as I pout out but there is page. title variable being passed in. |
Beta Was this translation helpful? Give feedback.
-
I will put a copy of the code up on GitHub on request. this is from the same page as
I think there is a difference in how Jekyll liquid to pass variables and how liquids pass variables. I already did have to make some mods to the liquid files changing |
Beta Was this translation helpful? Give feedback.
-
As I said , LiquidJS is a template engine, the
Did you try the globals option, like |
Beta Was this translation helpful? Give feedback.
-
that how is it rn with the |
Beta Was this translation helpful? Give feedback.
-
also i am passing in the variable {{content}} as unparsed liquid. should it be passed to work? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I will try that |
Beta Was this translation helpful? Give feedback.
-
No idea. It helps if you can provide a minimal demo or a jsFiddle link. |
Beta Was this translation helpful? Give feedback.
-
this is the code i am working on (some of the code strip out). It sill a WIP it not a very minimal demo or jsFiddle. The real website to compare the address is https://pirateparty.org.uk/materials/ |
Beta Was this translation helpful? Give feedback.
-
I have been working on this thing for two weeks, and I am stuck as heck with something that should be so simple—globals used as a global variable. I can't find where I am going wrong, and the data I am passing in seem to be right. I am thing about porting to a different templating engine to the to come over this perceived bug this project (it could be sill in my code), but I would really do want to keep in liquids-js 😞. If I give up on using this library in my code, I want to say I really like the idea of this project and if the bug is in your code, I hope u find it and fix it soon. |
Beta Was this translation helpful? Give feedback.
-
Sadly I have no bandwidth to debug into you repo, but I managed to update the demo/nodejs/ to demonstrate a working usage for globals used in templates imported by
The global data
You'll see output like:
|
Beta Was this translation helpful? Give feedback.
-
Here's a mediocre example of rendering a Markdown file with global and local variables (from the Markdown file's front matter): const matter = require("gray-matter");
const { Liquid } = require("liquidjs");
const marked = require("marked");
const pkg = require("./package.json");
main();
async function main() {
const globals = {
name: "alice",
age: 45,
homepage: "https://bing.com/",
// Make values from package.json available globally.
pkg
};
const engine = new Liquid({ globals });
await renderFile("./docs.md", engine);
}
async function renderFile(file, engine = new Liquid()) {
const { content, data: locals } = matter.read(file);
const md = await engine.parseAndRender(content.trim(), locals);
const html = marked(md);
console.log(html);
} Where my "./docs.md" file looks like this: ---
# Local variables
title: This is a title
---
<!-- {{ pkg.name }}@{{ pkg.version }} -->
# {{ title }}
And a paragraph.
And another one.
A second paragraph.
[links]({{ homepage }})
— By {{ name | capitalize }}
But to echo @harttle's comments above, probably better just to use 11ty (which supports Liquid templates by default) and let 11ty worry about processing source folders and output folders and all the other plumbing needed for a static blog. |
Beta Was this translation helpful? Give feedback.
-
After a look at 11ty, I don't think to meet my other needs. what I think I cant do form reading online with 11ty or with plugins for 11ty
what 11ty can do (with or without plugins)
|
Beta Was this translation helpful? Give feedback.
-
@pdehaan you had a look at my code form what you have seen is it a bug in my code, the template itself, liquid-js code or hesitate to comment/Don't know. |
Beta Was this translation helpful? Give feedback.
-
@UP822718 I haven't really had a chance to look through the code in the repo or above because, well, it's a lot of code. But based on the docs and my simple test case above, I don't think it'd be a bug in liquidjs since I can get globals and local variables to render in a template. As for the 11ty questions above, yeah, 11ty is just a static site generator, so most of the HTTP2/3 and server stuff is out of scope. You'd either need to wrap the generated static files in an Express server, or some other solution (like building everything in Next.js+React, or doing a lot of the work with client side JavaScript). |
Beta Was this translation helpful? Give feedback.
-
ok, thx @pdehaan I will have a look at Next.js+React. @harttle. just noticed there was two message way back right next to each other and I did not notice at the time and skipped one. my bad. i think I will be able to do it now maybe |
Beta Was this translation helpful? Give feedback.
-
Ok ok...... |
Beta Was this translation helpful? Give feedback.
-
I have been trying to port a Jekyll web site for fun to nodejs. but for the life of me, I can't seem to make the website render right
This is what my attempt looks like
this is what it meant to look like
I am passing the title in as a global but it not working right.
just to make sure I am supposed to pass the global variable as an object?
oh and not meant to be political going to reuse and edit the theme for something else
Beta Was this translation helpful? Give feedback.
All reactions