question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docsify-server-renderer error

See original GitHub issue

My code here:

// docs-renderer.js
const fs = require('fs')
const path = require('path')
const docsifyRenderer = require('docsify-server-renderer')
const templatePath = path.resolve(__dirname, '../../docs/index.template.html')

const docsifyConfig = {
  basePath: '/src',
  // ...
}

const renderer = new docsifyRenderer({
  template: fs.readFileSync(templatePath, 'utf-8'),
  config: docsifyConfig
})

async function test () {
  renderer.renderToString('docs/')
    .then(console.log)
    .catch(console.log)
}

test()

module.exports = renderer

Then:

TypeError: Cannot read property 'indexOf' of undefined
    at AbstractHistory.parse (/Users/zhangshuyao/Sites/git/docs/node_modules/docsify-server-renderer/build.js:349:30)
    at Compiler.compile (/Users/zhangshuyao/Sites/git/docs/node_modules/docsify-server-renderer/build.js:553:37)
    at Renderer.<anonymous> (/Users/zhangshuyao/Sites/git/docs/node_modules/docsify-server-renderer/build.js:1126:28)
    at Generator.next (<anonymous>)
    at c (/Users/zhangshuyao/Sites/git/docs/node_modules/docsify-server-renderer/build.js:14:99)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

There is shotcut of docsify-server-renderer/build.js

// line 553
  var curFileName = this$1.router.parse().file;
// line 346-360
  AbstractHistory.prototype.parse = function parse (path$$1) {
    var query = '';

    var queryIndex = path$$1.indexOf('?');
    if (queryIndex >= 0) {
      query = path$$1.slice(queryIndex + 1);
      path$$1 = path$$1.slice(0, queryIndex);
    }

    return {
      path: path$$1,
      file: this.getFile(path$$1),
      query: parseQuery(query)
    }
  };

I think maybe there is something wrong with my code or build.js after rollup-build, pls help me to check it.

Best

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
zmnvcommented, Feb 8, 2019

All works with old 4.1.7 version.

"docsify-cli": "^4.1.7",

Last version 4.3.0 returns error

4reactions
wll8commented, Apr 16, 2019

It seems that the examples on docsify-ssr-demo are incomplete and incorrect. I don’t know why.

I don’t know how https://docsify.now.sh/ssr is implemented.

git clone https://github.com/docsifyjs/docsify-ssr-demo
cd docsify-ssr-demo
npm i 
npm start
# open http://localhost:4000
# TypeError: Cannot read property 'indexOf' of undefined
git clone https://github.com/docsifyjs/docsify
cd docsify
npm i
npm run dev:ssr
# open http://localhost:3000
# UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'indexOf' of undefined
Read more comments on GitHub >

github_iconTop Results From Across the Web

docsify-server-renderer - npm
Start using docsify-server-renderer in your project by running ... There are 5 other projects in the npm registry using docsify-server-renderer.
Read more >
docsify-server-renderer | Yarn - Package Manager
var Renderer = require('docsify-server-renderer') var readFileSync ... readFileSync // init var renderer = new Renderer({ template: ... Bug Fixes. render: ...
Read more >
docsify-server-renderer: Versions | Openbase
Full version history for docsify-server-renderer including change logs. ... Fix microsoft/playwright-github-action error (#1534); Fix Cannot read property ...
Read more >
docsify
A magical documentation site generator. Simple and lightweight; No statically built html files; Multiple themes. GitHub Getting Started.
Read more >
docsify-template - CodeSandbox
Run the local server with docsify serve . ... If you want, you can show a loading dialog before docsify starts to render...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found