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

Exclude or redirect auto-generated pages #10

Open
IjzerenHein opened this issue Nov 4, 2019 · 2 comments
Open

Exclude or redirect auto-generated pages #10

IjzerenHein opened this issue Nov 4, 2019 · 2 comments

Comments

@IjzerenHein
Copy link

Hi, first of all, thanks for this great plugin, awesome work 👍 👍 👍

Hey I have a question or rather a suggestion. I can probably implement it myself through a PR, but I'd first want to know your thoughts on this before I proceed.

I have a documentation site where some pages are auto-generated API pages (from source). The edit-link is therefore different for these pages, it should point to the source-file, rather than the .md file. To support this, I had the following suggestion in mind, to extend the docEditBase argument so that it also supports a function. And in case it is a function, it is called for that particular page to request the edit-link. And when the function returns false it would disable editing of that page entirely. This would give you some control of which pages are editable and where they live, while keeping the API backwards compatible.

Example:

<script>
  window.$docsify = {
    // your config
    // ...
    plugins: [
      EditOnGithubPlugin.create(
        "https://github.com/IjzerenHein/firestorter/blob/feature-geoquery/docs/",
        function(docName, vm) {
         
          // Point the auto-generated docs to the correct source file
          if (docName.indexOf('api') >= 0) {
            return "https://github.com/IjzerenHein/firestorter/edit/feature-geoquery/src/" + docName.trim('.md') + '.ts';

          // Disable editing of external pages
          } else if (docName.indexOf('external') >= 0){
            return false;
          }
        }
      )
    ]
  }
</script>

I'd love to hear what you think :D

cheers, Hein

@njleonzhang
Copy link
Owner

It's a good idea, notice to be compatible to previous version.

@IjzerenHein
Copy link
Author

.. notice to be compatible to previous version.

Check 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants