docsify icon indicating copy to clipboard operation
docsify copied to clipboard

Question: How can I render docsify page through an express server?

Open aceamarco opened this issue 3 years ago • 0 comments

I'm making an express server and I'd like it to respond to all GET requests with the page rendered by docsify. Is there anything special I have to do or can I just reference index.html?

...
app.get('*', (req:Request, res:Response) => {
  res.render('./docs/index');
}

...

aceamarco avatar Jul 14 '22 16:07 aceamarco

Well you could also serve a static folder with express and then route to your index.html.

app.use('/docs', express.static('docs'))

See http://expressjs.com/en/starter/static-files.html

This way docs will then be accessible on '/docs'. You can redirect certain paths with res.redirect(url). I won't use '*' as it attaches to all routes. Or doesn't it? You wont be able to switch to the different markdown docs otherwise.

If you only render the index.html and send it to the client I'm not sure if you will be able to switch to different doc files. I guess you would have to send the hole docs folder for this to work.

LuGr-01 avatar Sep 06 '22 07:09 LuGr-01

Here's a good project you can refer to it. https://docsify-this.net/

sy-records avatar Sep 06 '22 08:09 sy-records