Open galaxy001 opened 9 years ago
How should this be provided then? With a global preference? Would an entry inside the Jekyll front matter work? Something like:
media_root: ~/git/test.github.io
Global preference is a easy way.
A smarter way should be check whether the opened file is in a git repo with git rev-parse --show-toplevel
, and set that dir as media_root
.
And, ~
is not working in HTML, we should use real path in HTML.
I don’t really want to tie things to a specific tool, so the git trick is out. Setting a global preference is easy, but might not make a lot of sense if you want to manage multiple sites.
Maybe something like EditorConfig is better (just thinking out loud). #396 seems like a more general version of this problem.
In #396, since you are going to search every path along something like /User/Galaxy/Documents/git/myblog/_posts/2016-01-01.md
for .macdown
, it should also be acceptable to check whether the first /root/prefixed/media.png
can be found as ./root/prefixed/media.png
.
Such as, /root/prefixed/media.png
can be found as /User/Galaxy/Documents/git/myblog/./root/prefixed/media.png
.
Then, if media_root
is not set, we can maintain a in-memory hash to remember all file within /User/Galaxy/Documents/git/myblog/_posts/
should have their media_root
set to /User/Galaxy/Documents/git/myblog/
.
Of course some counting on different root-prefixed-medias will make it more smart.
A global preference and some symlinks can easily do the trick. From now on, I made links in / (yes really ugly workaround) but a "root directory" global option is the only thing I need.
Forgive me, as I'm new to both Macdown and Jekyll. I'm not sure if this issue is solved, or not.
This is what my markdown looks like:
![Withings Aura Sleep System]({{ site.baseurl }}/media/withings-aura.jpg) *The Withings Aura Smart Sleep system*
When I run Jekyll build, the URL is properly resolved and the images are displayed in the compiled post. In MacDown preview, the images cannot be found, presumably, because I don't know how to tell MacDown the value of site.baseurl
. Is this possible to do?
@zimmeee If the per-file configuration mentioned in #396 is finally implemented, then maybe we can allow user to specify site.baseurl
there. I agree with @uranusjr on this topic (per-file/per-project settings over global settings).
@galaxy001 I think you mean this:
When MacDown open a file
/User/Galaxy/Documents/git/myblog/_posts/2016-01-01.md
with an image path /root/prefixed/media.png
, if MacDown cannot find the image at /root/prefixed/media.png
, it search all its parent folders in the path, i.e.
/User/Galaxy/Documents/git/myblog/_posts/
/User/Galaxy/Documents/git/myblog/
/User/Galaxy/Documents/git/
For each of the paths, try appending the image path to it, yielding
/User/Galaxy/Documents/git/myblog/_posts/root/prefixed/media.png
/User/Galaxy/Documents/git/myblog/root/prefixed/media.png
/User/Galaxy/Documents/git/root/prefixed/media.png
for the first path where an image is found,
Please correct me if I missed anything.
@franklinyu Yes. I hope this can be added soon.
Further more, if necessary, the searching result for each folder can be cached into MacDown user data, and the cached path should be tried first for all files inside same folder.
This would be an awesome improvement to the workflow of anybody using Macdown to author Jekyll blogs!
@franklinyu This looks like a good solution. Honestly I have no idea how to implement it into the WebView API, but this should be the way to go.
@galaxy001 By
Further more, if necessary, the searching result for each folder can be cached into MacDown user data, and the cached path should be tried first for all files inside same folder.
Do you mean that (continuing my example before) MacDown save something like this as a per-user preference:
$REPO_DIR/myblog/_posts/
=> $REPO_DIR/myblog/
$REPO_DIR/another-blog/_articles/fancy-folder/
=> $REPO_DIR/another-blog/
$REPO_DIR/my-issues/oh/yeah/_issues/a/very/deep/structure
=> $REPO_DIR/my-issues/oh/yeah/
(I replaced /User/Galaxy/Documents/git
with $REPO_DIR
because the former is a bit too long.)
Yes, sort of.
A more representative example is:
I mean, this is a per directory record.
Moreover, I am not sure whether it is possible to be more smart as below:
Which is a per git repo record.
However, the smart way might fail if someone use git submodule
:
@galaxy001 The "more smart" way depends on Git, while @uranusjr explicitly stated that
I don’t really want to tie things to a specific tool, so the git trick is out.
And I agree with this. Introducing a (complicated) external dependency for just a single use case (static site generator) sounds more like an overkill.
@franklinyu @uranusjr So, will you consider the per directory record way ?
Static site generator support will be useful if we want to keep a notebook sync to web blog.
An example is:
@galaxy001 Yes, that is a pretty feasible idea. However, I'm sorry that I cannot guarantee a timeline for this feature.
Some Jekyll site have to set media path to absolute path like
/assets/images/test.jpg
, and cannot be rendered on local machine.If user can provide Jekyll repo path like
~/git/test.github.io
, it will be helpful to format those media with URL begin as/
to~/git/test.github.io/assets/images/test.jpg
.