-
Notifications
You must be signed in to change notification settings - Fork 4
Fix edit links of modules #8
Comments
An alternative solution is override the default EditUrlFunction, with a check of whether the first line content of the file pointed to by |
I had a quick look earlier and I didn't notice that it was actually a symbolic file. I created an override function and it works on my local. Do you think that's a clean solution? |
Looks good. I don't write much JavaScript, so can't tell you if there is a cleaner solution. But maybe put it as a separate function with clear documentation comment on top. Happy to accept this as PR. |
@brsvh I just realized this. Your PR produces a view URL, but we want edit url. For eg., go to https://zero-to-flakes.com/haskell-flake/start and click on Edit.
|
I took a stab at improving the situation so now the user is at least taken to the default branch view URL where the edit link is no longer grayed out. But this TODO remains, |
I forgot to mention earlier that I use commit HASH instead of hardcoding
About this part, I think potential issues falling into two categories:
However, most projects in the Nix realm are currently hosted on GitHub, so it's possible that I have over-engineered it. If you still intend to maintain a singular document instance, I intend to enhance this when time permits. My current plan is to augment the parsing of
Then check what the default branch of the origin repository is based on the forge, something like this: if (gitmodule['forge'] == 'github') {
const defaultBranch = (async () => {
const owner = gitmodule['owner']
const repo = gitmodule['repo']
try {
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/branches`);
if (!response.ok) {
throw new Error('something wrong.');
}
const data = await response.json();
const defaultBranch = data.find(
branch => branch.name === data[0].name
);
} catch (error) {
console.error('Error:', error.message);
}
})();
} else if (gitmodule['forge'] == ...) {
...
} else { ... } |
Docusaurus is not flexible enough to allow overriding edit links en masse at folder level.
See https://zero-to-flakes.com/haskell-flake/examples - where the edit link is broken.
We can workaround this by patching the YAML frontmatter of all
.md
files in CI, during site build.The text was updated successfully, but these errors were encountered: