requarks / wiki-v1

Legacy version (1.x) of Wiki.js
https://wiki.js.org
GNU Affero General Public License v3.0
101 stars 75 forks source link

Sidebar Rework #174

Closed whiskeyu closed 5 years ago

whiskeyu commented 5 years ago

Hi Everyone,

I'm pretty new to node.js and markdown so bare with me. I'm trying to rework the sidebar so that it doesn't auto generate from headers but I want to generate from something else.

I poked into the view.pug file and wondering how much work is this really gunna take me or is there an easier way.

Thanks.

cscherban commented 5 years ago

Did you end up figuring out what to do?

FiyaFly commented 5 years ago

I know this was closed, but I got curious.

I can't necessarily say it'd be easy or that it wouldn't be a small chunk of work, but it doesn't look too hard, and I just have some rudimentary knowledge of pug and javascript overall.

I didn't have a lot of time to go digging, but here's some information I can give you:

in the view.pug file, the navigation is generated by the top section: mixin tocMenu(ti). Links are generated from the a(href) piece obviously, and the mixin gets the information for this from the variable pageData.tree.

pageData.tree is generated in server/libs/entries.js, at line 123-128:

  let pageData = {
    markdown: (options.includeMarkdown) ? contents : '',
    html,
    meta: (options.parseMeta) ? mark.parseMeta(contents) : {},
    tree: (options.parseTree) ? mark.parseTree(contents) : []
  }

From there it would require tracing back through the code to figure out where contents come from or how it's parsed in. I guess a large part of how much work this would take would be what exactly you plan on having it generate from. I'd like to dig into it more given the chance, so if you're still curious, let me know.