Skip to content

The path to backlinks #749

@boehs

Description

@boehs

Enter your suggestions in details:

Hi, I'm futzing with Lume for my site, which already uses Vento and Eleventy. Reading the docs I had some philosophical reservations, but I suspect many of them will be alleviated once I actually get to using Lume as its a bit of a paradigm shift in many regards (and, to be clear, it already looks like there's a lot of decisions I think are huge improvements)

The one thing I can't conceivably envision a workaround for is the backlinks feature, which displays on pages the other pages that link to that page (holy word salad). In Eleventy, I do this with a disgusting computedData hack. As far as I can tell, Lume doesn't have computed data which was a big shocker, but quite honestly maybe is an improvement.

At its most basic, the backlink feature requires the following things

  1. The ability to export data generated during markdown template rendering

If I wanted I could implement my own loader to do this. This would be a mild hack but tolerable. It is possible that, as objects are reference types, I could modify the value of data?

  async function render(
    content: string,
    data?: Record<string, unknown>,
    filename?: string,
  )

is this officially supported? can it be? What would happen is my wikilinks plugin would, for each wikilink, do data.linksTo.push('/path/to/page')

  1. Use this data in a layout

The layout would do something like search.pages("linksTo.includes('{{thisPageUrl}}')") (yes this syntax is invalid but you get the idea).

A different page could specify renderOrder so that all data is available. This is not possible here because backlinks are displayed in the page itself, so the layout would need to set renderOrder. According to order of operations, "For each group of pages with the same renderOrder .... Render the page using the assigned template engine and layout," so this is not possible.

A really easy path to this that occurs to me would be to internally model layouts as pages. How this would work is when lume encounters the layout specifier, the page queue is amended as if the layout was a page itself, and is just passed {{ content, ...data }} for what the value of data would be. That way, layouts would by default be rendered fairly close to directly after the content page, but if renderOrder was set higher this would be deferred for free.


If you see any other options for how backlinks could be done today, or other paths to lume supporting this, please let me know! I'd be happy to discuss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions