-
-
Notifications
You must be signed in to change notification settings - Fork 237
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
porting a jekyll site to nodejs #286
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! |
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. |
just notes it not the same page as I pout out but there is page. title variable being passed in. |
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 |
As I said , LiquidJS is a template engine, the
Did you try the globals option, like |
that how is it rn with the |
also i am passing in the variable {{content}} as unparsed liquid. should it be passed to work? |
|
I will try that |
No idea. It helps if you can provide a minimal demo or a jsFiddle link. |
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/ |
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. |
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:
|
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. |
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)
|
@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. |
@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). |
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 |
Ok ok...... |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
The text was updated successfully, but these errors were encountered: