-
Notifications
You must be signed in to change notification settings - Fork 673
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
Remove legacy github slugger #872
Conversation
to regenerate |
Let's merge once you have updated |
I am actually now thinking that in the other PR we make a "legitimate" use of the slugger, so although it's no longer used in the heading generation (which tbh I think is no longer used anywhere), we should keep the slugger. At the same time, probably we don't need the full package, but just the actual slugging function from https://github.com/Flet/github-slugger/blob/master/index.js wdyt? |
Yes, I know. That's why I commented there. I'm not sure how legitimate it is, because:
The direction Foam seems to be taking in this regard is title = slug = filename. I believe it's the right direction and it's the same than Obsidian does. I'm not necessarily opposed to a more general slugifying solution (two-way and configurable for different styles) but short of that I believe it's more coherent to promote the title = slug = filename convention and leave other options to be fully manual. In particular, I dislike having the github slugger dependency just to implement an ad hoc solution. |
If we're going to keep some form of slug, the minimal implementation that seems consistent to me is:
Alternatively the configuration may allow to customize slugs a bit, perhaps a But, as I said, I'm ok with removing all traces of slugs instead. I've been checking what Obsidian does again and it doesn't even add a |
The point of slugs potentially opening doors we can keep closed now is a fair one. But I am thinking it might be ok to provide basic support for slugs, defined as:
If you click on
By slug I mean the github-slug, no other slugs are supported, I am comfortable drawing that line in the sand - because for me the goal in the end is the one stated above: give an easy path to URL friendly name. I can see a case where someone wants to put a title, but wants the file name (and connections to it) to use the slug... it wouldn't me my way of doing things, but why not. The only support for slug I am happy to provide is
The only thing Foam wants is that wikilink/identifier is based on filename/path, we don't have requirements around titles, slugs, or else.
I do like how in Obsidian the file name is the note title, but that's not possible in Foam because in Obsidian it's the editor that is "constrained" in the UI, and VS Code doesn't allow us that (and I am not sure whether I'd take that if I could). And of course you can add a title at the top, in that case you'd have filename != title.
I totally agree, we can just copy/paste the function (in the end it's just a regex + lowercase for the simple latin case). We should remove the dependency on github-slugger Now, all of that being said, I am actually a bit torn because of the very first 3 lines of this comment. |
Yes, I understand this and I like it to be so, I'm just saying that foam is making this convention work OOTB while still allowing other conventions (with manual intervention).
But with this content by default:
If we're going this way I'd like to do this slightly better. If you don't want the config option, perhaps the |
I could implement the zero-config proposal or the more elaborate proposal in #872 (comment). |
That's correct, that's what I mean by "not providing first class support for slugs" :)
I like what you are trying to achieve, but I am not fond of the magic, I think there are tricky edge cases (off the top of my head, plus some I might not be thinking about). Just to share with you, here are my first questions:
It's not about the answers here per se, but having to consider all of these (and what else?) that makes me uncomfortable with moving forward with this at this stage. At the same time I do think your heuristic is pretty good, and probably many users will appreciate it. So, I would shelve implementing the idea for now, and write a proposal about "Slugs in foam" to get the conversation started (also because I really don't know how many people actually care, and my guess is "not many"). |
Ok, once you merge #865 I'm going to adapt this PR to provide a simple |
For now let's remove the slugger as it's not currently used. When we decide to introduce a feature that uses it, like #865, we will consider how to reintroduce it with a simple |
We should update yarn.lock. |
damn, I missed that, will do now |
I'm pushing a PR right now. |
Foam was originally using Markdown Notes for wikilink resolution, which will slugify the link. |
Why tho? Is that hard to give an explanation on the motives? Other than "it's harder to maintain". I don't think is that unreasonable to expect backwards compatibility. Even for those who already invested way to much time and effort into the foam ecosystem. |
I have seen you already found it, but in case it's helpful for others more information on the rationale for moving away from slugification is found here: #1033 |
There's no rationale there. Only a "we're moving away from slugified links without giving reasons other than a moved file bug". Can you please help me understand the why? I personally don't see the benefit and would need to look alternatives to keep my links usable. We're talking about hundred of links rendered unusable. Or maybe allow us to downgrade to a slugified working version. |
Why? Because as in every other project, there are limited resources here, complexity creeps and the slug part was particularly messy with a legacy of not very consistent code and criteria. As you can see I've proposed a compromise version above so that some use cases could be preserved, but anyway I tend to agree with Ricardo here, not least because he is the one doing most of the heavy lifting. Perhaps you can write a simple script that deslugify your files or work in a PR that may or may not be accepted (probably not if you just hack some code in order to support your and just your use case). After all, you're using code that's not only free but also: which is clearly stated in the project github home. |
I'm aware of that @memeplex I'm an open source contributor myself. But please try to emphasize a little bit with my story. I started using foam from almost day one. Made hundreds and hundreds of notes with it. Fast forward a year and tried to retake my writings just to find out that all my links are broken. I'm not expecting anything but some empathy here, please try to understand my frustration. I'm just trying to recover my links and without luck in finding a clear way to do so. |
Is it that difficult to deslugify your wiki? You can contact me if you need help doing that. |
hi @zomars, I hear what you say. When this choice was made I was aware that some people were going to be affected. And yes in those days Foam was really alpha! (it still kinda is, yet we haven't released the API exactly because even when we say we are alpha users still then expect the API being backwards compatible) Inspired by #1033, let's go back to the reasons why I decided to make the switch (which I was expecting to create some disagreements, but I thought the tradeoffs were still positive):
Beside all of those reasons, from a design POV I simply don't believe that slugs are a good foundation, and that's why I chose to get rid of them. I might be wrong, by all means, I have just not been persuaded by the arguments yet. At the same time we had some features in the works that would have softened the blow for people that really like to use slugified filenames:
If we find a clean solution to supporting slugification we might add it, by all means. With the building blocks we currently have:
We are getting very close to have an almost seamless support for slugification (if you are happy with all your links looking like And maybe in the future we'll have link definitions (my last point above) as a great way to support "non-aliased" slugs links in Foam, but that is not a priority in my opinion at this point. I don't expect everyone to agree with the design choice, and I do appreciate the feedback (when done constructively), slug vs non-slug has been an ongoing topic, and I do want to build a solution that in the end works for the majority of users. Back to your situation, here are a few alternatives to keep using the old-fashioned slugs:
|
How do you deal with publishing your notes on the web? Most of the early day examples and templates were heavily focused on publishing to the web. Which is tied hand-to-hand with suglification. I know because I've contributed to eleventy and next.js examples myself. |
I appreciate the explanation tho. How could tell VS Code to use a previous foam version? |
@riccardoferretti I'm not sure how do you regenerate yarn.lock so I've only changed package.json.
I decided to leave the slug term as it's used in many places, I think it has a legitimate meaning. Regarding the references used to find resources in the workspace, one could say a reference is:
AFAICS the current code is consistent with this terminology.
I've added a
refactor
label since I expect to send a few more purely-refactoring PRs, but feel free to delete or rename it.