gcoda / vuepress-backlinks

BackLinks are links from a page back to pages that link to it.
2 stars 0 forks source link

Backlinks not working on relative links with Permalink #1

Open kaihendry opened 5 years ago

kaihendry commented 5 years ago

https://github.com/Webconverger/wiki/commits/vuepress

As you can see no backlinks are shown here: https://beta.webconverger.org/API/ https://s.natalian.org/2018-12-09/backlinks.mp4

I think it's because I have moved from [[API]] to [API](/API/) style relative links?

I am trying not to use that weird /API/README.html structure, but maybe I don't have a choice? Happy to make changes as you suggest.

gcoda commented 5 years ago

It is matching links to current page, no wonder it is not working for relative links, i should probably use path.resolve somewhere in the code. Will work on it soon.

As a side note, you probably can add .mdwn to webpack config, renaming was a fast way for me to try thing out.

kaihendry commented 5 years ago

Thanks! Renaming to .md wasn't an issue. The permalink stuff was a pain. Can I sanely avoid the "README.md" construct?

And I've yet to figure out blogs / RSS et al

gcoda commented 5 years ago

I see that you using permalink /API/ inside api.md, no sure what is the relation to README.md does readme woks like index?

If it works as a link inside vuepress it should work with plugin otherwise it makes no sense.

There is a blog plugin, i did not used it yet, and there is also sitemap plugin that generates xml, i am sure rss will not be a problem

gcoda commented 5 years ago

@kaihendry i am not sure about state of my mind when i started this, but this mess is getting only worse... needs complete rewrite, i understand how vuepress works now.

what i am trying to say - looks like it works now

kaihendry commented 5 years ago

I think it's working! https://s.natalian.org/2018-12-18/blog.mp4

Thank you! https://github.com/Webconverger/wiki/commit/2c908454f9917de6a6f466ef6c7abcb24da9586d

I'll test it further.

gcoda commented 5 years ago

there is
this.$page.pageLinks with .title as mentioned in content click [here](./post) will have title: "here"

this.$pageLinks computed property with correct .title from page itself

kaihendry commented 5 years ago

Some pages linked from home, e.g. https://beta.webconverger.org/system_integrators/ don't have a backlink. Any ideas why?

https://github.com/Webconverger/wiki/blob/vuepress/system_integrators.md

gcoda commented 5 years ago

home page contains [About Webconverger](/about/) and system_integrators.md got "permalink": "/system_integrators/"

i am not even how it works and where is /about defined as redirect

EDIT: If permalink is /about it works. There is no need to replace default sidebar, it might be useful on long pages, Layout.vue

sidebarItems() {
      const defaultSidebar = resolveSidebarItems(
        this.$page,
        this.$page.regularPath,
        this.$site,
        this.$localePath
      )
      return defaultSidebar
        .concat(
          this.$backLinks.length > 0
            ? [
                {
                  title: "Back Links",
                  type: "group",
                  children: this.$backLinks,
                },
              ]
            : []
        )
        .concat(
          this.$pageLinks.length > 0
            ? [
                {
                  title: "Forward Links",
                  type: "group",
                  children: this.$pageLinks,
                },
              ]
            : []
        )
    },
{
    "title": "Webconverger for system integrators",
    "permalink": "/about/",
    "sidebar" : "auto",
}
kaihendry commented 5 years ago

Trying to grok Vuepress themes. https://vuepress.vuejs.org/theme/writing-a-theme.html#content-outlet

It seems that just copying in Layout.vue with your method above (it's a method right?)

wiki$ find .vuepress/theme/ -type f
.vuepress/theme/layouts/Layout.vue

Isn't enough..

screenshot 2018-12-20 at 8 45 41 am

I have to copy in the whole theme? VuePress document implied some elements were optional and I assumed it would just defer to default theme for missing elements. Guess not!

gcoda commented 5 years ago

not really sure what is the correct method... it looks like you copied whole theme in your wiki. so i assumed it should work.

but i just replace imports in files i copy, works

import Home from "@vuepress/theme-default/components/Home.vue"
import Navbar from "@vuepress/theme-default/components/Navbar.vue"
import Page from "@vuepress/theme-default/components/Page.vue"
import Sidebar from "@vuepress/theme-default/components/Sidebar.vue"
import { resolveSidebarItems } from "@vuepress/theme-default/util"
kaihendry commented 5 years ago

I tried it, but I didn't work. I guess I revert to the full theme with your sidebar method?

Sorry, on holiday so only had a few minutes to try. I committed my changes on the vuepress branch though.