-
Notifications
You must be signed in to change notification settings - Fork 251
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
using meta.json #22
Comments
Hi, I hope I understand your problem. You are trying to access a variable defined in the meta.json from a markdown. Can you write a bit more about your use-case? I just want to make sure I understand @mixu - Correct me if I'm wrong- I see you changed it in 54682e3 . Maybe it can be resurrected as an optional feature (if it is indeed the intended use-case) |
Hi guys; thanks for your feedback apparently I was not clear enough; I am not trying to use a meta-variable from a markdown but simply from page.html, like I can see {{title}} is being used;
and then to use {{tab}} in page.html but when I want to define variable 'bar' for all the markdowns, using the meta.json above, I can't get {{bar}} to correctly instantiate in the resulting html this is the intended use, right ? |
Oh, now I understand. You're looking for a variable that can be shared across 'projects' (directories) something similar to a global constant. The |
OK, I had that right; but...
and I have an input file in thanks ! |
"index" projectName: either the file name, or the folder name of this file it's the file name when its parent dir is the input dir |
hi @parmentelat - thanks for filing this issue. I improved the docs a bit around this, hope that helps. I do think that there would be room for improvement, specifically:
The current implementation was mostly written to maintain compatibility with the |
Hi there My proposal indeed aimed at a cascading scheme In a nutshell, I would propose that the dictionary used to deal with file /a/b/c.md would be computed this way (using python style as I am more of a python guy :) : This should be rather straightforward to write; I am willing to give this a try when I have a chance, but probably not before september or so... Note that definitions in meta['a/b/c'] are specific to the file; but that these should be overridden by metadata from the file itself IMO, hence this order That same scheme could apply to files at the root level (i.e. files right under the input directory) with no change at all. As far as naming, one could also consider using instead - in the same order Or any variation along these 2, again I guess rhe choice here is more about legacy than anything else. Any pointer to how integration tests should be written could come in handy and would be greatly appreciated Thanks for the feedback in any case --- Thierry
|
Sounds good to me - I think its OK to move away from the legacy mechanism (which was somewhat limited) since I think the migration will be fairly straightforward and I'm pretty sure the people who wanted to move to the 2.x releases have done so by now. I like the second naming convention a bit more, since it's closer to how glob expressions are written. I probably won't have too much time to work on this soonish but it's good to have something specced out. As for integration tests, this test can probably be extended a bit to cover the new cases https://github.com/mixu/markdown-styles/blob/master/test/integration.test.js#L71 |
…ixu#22 Specifically for a file named <path-to-input>/a/b/c.md, the following sources for solving metavariables are considered . metadata from the file . meta['a/b/c'] . meta['a/b/*'] . meta['a/*'] . meta['*'] with the first one in this list taking precedence similarly a file named <path-to-input>/a.md, the following sources for solving metavariables are considered . metadata from the file . meta['a'] . meta['*'] In particular this means that if 'foo' is set in the file's metadata, then this value will be used for {{foo}} no matter what meta.json says
Hi I have just committed a proposal for implementing this feature in my own fork here in essence: . I add a 'relative' property to each 'item' object (and do not use projectName in mergeMeta anymore at all) I would appreciate a quick review; as I said I am not very fluent in JS so this might be a little awkward or tedious at times |
as a final note at first glance it might very well be that projectName was only used in merge-meta.js (apart from other references in test/) so it would make sense to remove the 8 lines that are about setting this property in set-output-path.js like here |
published on npm as |
Hi there
First off, many thanks for putting this together ! Looks like a really cool idea and I got my micro website up and running in an eye blink :)
I'm at the point where I'd need to leverage this meta.json business.
It first took me some time to figure I had to install it inside the input/ directory
after I instrumented the code I can see now that my file is read all right, but the corresponding {{foo}} replacements do not take place, and I am trying to figure out what it is that I do wrong
I guess there is some confusion in my mind as to what is expected in that dictionary. The doc at https://github.com/mixu/markdown-styles#metajson explains how to define variable repoUrl for files under input/foo; what about files at the toplevel right in input/ ?
I have tried various tricks for defining 'bar' like
{
"" : { 'bar' : 'value'},
"." : { 'bar' : 'value'},
'bar' : 'value',
'input' : { 'bar' : 'value'},
}
but apparently to no avail, the occurrences of {{bar}} all come up empty;
I can feel there is something I do just wrong but I can't spot it, can you please help ?
Besides, given this scoping mechanism, I would fancy there should be a means to define a given variable at different levels of the filesystem tree, with the most precise (the longest prefix) taking precedence, is it the case right now ?
I have net yet taken the step of splitting my inputs into subdirs, but if that feature was working as I describe I might go down this road later on.
Thanks again in any case
The text was updated successfully, but these errors were encountered: