xcatliu / pagic

A static site generator powered by Deno + React
https://pagic.org
MIT License
1.64k stars 104 forks source link

Allow arbitrary links in sidebar #71

Closed x87 closed 3 years ago

x87 commented 3 years ago

Hi there! I'm trying to add a new item in the sidebar that points to some location (a local file, but it could be an external url as well).

Something like:

            {
              text: 'Download file',
              link: 'dir/file.zip'
            }

I get the error during build:

[Pagic] Plugin sidebar start
error: Uncaught (in promise) TypeError: Cannot read property 'outputPath' of undefined
      item.link = pagic.pagePropsMap[item.link].outputPath;

Describe the solution you'd like

I understand the current implementation might be limited to reference local pages only. But I would like to be able to add any arbitrary links in the sidebar. So in my case I would see a new line in the sidebar:

Download file

which would point to dir/file.zip.

Thanks for your tool. It's very handy and easy to use.

xcatliu commented 3 years ago

Thanks for your advice! This feature has been released in v1.1.0

Now sidebar support any arbitrary links like dir/file.zip or complete url like https://github.com/xcatliu/pagic

Example:

export default {
  sidebar: {
    '/docs/': [
      {
        text: 'Intro',
        link: 'docs/introduction.md'
      },
      {
        link: 'assets/hello.doc'
      },
      {
        text: 'Hello',
        link: '/assets/hello.doc'
      },
      {
        text: 'GitHub link',
        link: 'https://github.com/xcatliu/pagic'
      }
    ]
  }
}