Skip to content
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

Integrate wiki-link plugin #51

Merged
merged 8 commits into from
Dec 4, 2023
Merged

Integrate wiki-link plugin #51

merged 8 commits into from
Dec 4, 2023

Conversation

tukib
Copy link
Member

@tukib tukib commented Dec 1, 2023

This PR:

  • implements a wrapper for the @docusaurus/plugin-content-docs plugin
  • integrates the remark-wiki-link plugin into Docusaurus, which fixes Port and update Wikilink Docusaurus plugin #32
  • adds some associated styling
  • adds unlisted1 page to demo some of this: Wiki-Link Demo (not live so replace the hostname)
  • adds another unlisted page that broken/new wiki links point to, which we should fill out at a later stage: Create a Page

I've used TypeScript for this, which builds fine with our current configuration, and can of course be switched to JS if needed.

Some items not in scope for this PR:

  • VSCode is giving me a warning for wikilinks (link.no-such-reference)
  • Spaces are not replaced when checking/generating slugs in the page name resolver, we need a policy for filenames. (affects line 52, slugReference)
    • Assuming snake-case for doc (mdx) files, we should include some policy in the content guide.
  • Would be nice for the 404 page to include a link to create the page on github. addressed already
  • The page resolver already knows if a page does not exist, so the permalinks list is redundant, but changing this is probably not trivial.

Footnotes

  1. Unlisted pages https://docusaurus.io/blog/releases/3.0#unlisted-content

docs/wikilink_demo.mdx Outdated Show resolved Hide resolved
src/css/custom.css Outdated Show resolved Hide resolved
@danswann
Copy link
Member

danswann commented Dec 1, 2023

We can fix the build failure caused by the broken link check by using options.hrefTemplate in the remark-wiki-link plugin.

If you return an empty array from options.pageResolver when there is no valid document, you can check for that in options.hrefTemplate and set a default path. See the prototype wiki configuration for an example.

This also allows us to explicitly set it up so that broken wiki links will link to a page describing how to add a new page, without requiring us to interfere with the default 404 behavior, which we may want to preserve. You can see it in action in the first two links present on the prototype wiki.

@danswann
Copy link
Member

danswann commented Dec 1, 2023

This also does not have feature parity with the prototype version. This is probably my fault, as while I named the issue "port and..." I failed to specify in the issue body what porting meant and that an existing working version even existed.

I'd like to see support for an array of custom link text (e.g. we might want [[robovac_catesby]] and [[catesby]] to both correctly resolve to a page with a slug of /foo/bar/robovac_catesby). There's also an argument that this would be redundant with remark-wiki-link's support for aliases, so maybe this is just me. I'm happy to consider this out of scope if we want, since it wasn't clear from the issue description.

Other than that one thing, this is a significantly better version than the one I made. The wrapper is very clean, and my fears of harming maintainability are assuaged. Nice work.

@tukib tukib marked this pull request as ready for review December 2, 2023 04:00
@tukib tukib requested a review from danswann December 2, 2023 04:00
Copy link
Member

@danswann danswann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes made, default page feature added, looks good.

@tukib tukib merged commit 147c254 into main Dec 4, 2023
3 checks passed
@tukib tukib deleted the tukib/wikilinks-plugin branch December 4, 2023 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port and update Wikilink Docusaurus plugin
2 participants