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

get auth from 3rd party identity provider by vim _sidebar.md #2520

Closed
xuanjinnan opened this issue Dec 18, 2024 · 2 comments
Closed

get auth from 3rd party identity provider by vim _sidebar.md #2520

xuanjinnan opened this issue Dec 18, 2024 · 2 comments

Comments

@xuanjinnan
Copy link

xuanjinnan commented Dec 18, 2024

Feature request

vue code work at _sidebar.md

Problem or desire

i want to auth the sidebar
redirect to docsify url like this:

 http://localhost:4000/#/?token=EESDCCSSDA.AEEEXW.EEEEE

index.html

<script>
    window.$docsify = {
      name: '',
      repo: '',
      loadSidebar: true,
      requestHeaders: {
        'x-token': 'xxx',
      },
        vueGlobalOptions: {
          data() {
            return {
              ],
              myRouter: []
            };
          },
          created() {
            fetch('http://localhost:8080/getRouterByToken?token=' + window.location.hash.substr(window.location.hash.search('=')+1))
              .then(response => response.json())
              .then(data => {
                this.myRouter = data
                console.log(this.myRouter,'this.myRouter')
              })
              .catch(err => console.log(err));
          }

my _sidebar.md

{{ myRouter[0]}} <br> 
{{ myRouter[1]}} <br>
{{ myRouter[2]}} <br>
{{ myRouter[3]}} <br>

* [home](/)
* [guide](/guide.md " guide title")

but the display is :(
image
it not work at _sidebar.md ,neithor at normal .md file

Proposal

maybe i take the wrong way use docsify,but my proposal is support auth the files

Implementation

i think docsify's implement is html build by .md add html build by vue ,and display the total html

can we change the order : mixed vue and .md to prue .md then pure md to html :)

i know the vue to .md is hard , i dont know how to implement ,sorry.

i'm a backend coder ,just want the request like a baby ,xd.

@sy-records
Copy link
Member

The content should support loading remote files, but _sidebar.md doesn't, and you can generate it in some other way than loading it on access.

@sy-records sy-records closed this as not planned Won't fix, can't repro, duplicate, stale Dec 18, 2024
@trusktr
Copy link
Member

trusktr commented Dec 18, 2024

@jhildenbiddle might have a hunch as to if Vue interpolation should work there. Seems like it should, for global Vue components. In theory it shouldn't be very difficult to apply it to sidebar in Docsify.

As a workaround you can use JavaScript to modify the sidebar in a custom way. Do it in a Docsify plugin:

https://docsify.js.org/#/write-a-plugin

Perhaps you'll want to do it in hook.ready:

https://docsify.js.org/#/write-a-plugin?id=ready

Or maybe in your Vue mounted is fine too.

const link = document.createElement('a')
a.href = myRouter[0]
sidebarSection.append(a)
// etc

If myRouter[0] contains [foo](/foo) change that to only /foo.

You could also interpolate that the standard Vue way:

<a :href="myRouter[0].href">{{myRouter[0]}}.name</a>

is myRouter is {href: "foo", name: "foo"} for example. Then you can cloneNode the the list and append to sidebar.

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

No branches or pull requests

3 participants