GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(serve): --base-path serves docs from a subpath to match GitHub pages by iamdanfox · Pull Request #47 · docsifyjs/docsify-cli

Conversation

@iamdanfox

@iamdanfox iamdanfox commented Nov 19, 2018

Copy link
Copy Markdown

Before this PR

Using a base-path in $docsify config makes doscify serve . unusable for local development - all requests just return 404.

    window.$docsify = {
      name: 'my-project',
      basePath: '/my-project',
    }

After this PR

I'll be able to run docsify serve . --base-path 'my-project' to replicate the behaviour of GitHub pages (which always uses a sub path, e.g. https://iamdanfox.github.io/my-project).

fixes #32 cc @davestewart who originally filed the issue

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cdtinney, timaschew, oshliaer, yuku, and Tomas2D reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@iamdanfox
feat(serve): --base-path serves docs from a subpath to match GitHub p…
37f323d
…ages
@iamdanfox

iamdanfox commented Nov 19, 2018

Copy link
Copy Markdown
Author

Seems like the red build has the same cause as the red builds on master:

[05:49:20] Failed to load external module @babel/register
[05:49:20] Requiring external module babel-register
fs.js:25
'use strict';
^
ReferenceError: internalBinding is not defined
    at fs.js:25:1
    at req_ (/Users/travis/build/docsifyjs/docsify-cli/node_modules/natives/index.js:137:5)
    at Object.req [as require] (/Users/travis/build/docsifyjs/docsify-cli/node_modules/natives/index.js:54:10)
    at Object.<anonymous> (/Users/travis/build/docsifyjs/docsify-cli/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/travis/build/docsifyjs/docsify-cli/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cdtinney

cdtinney commented Dec 19, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Great PR..

Is there another way around this for local development?

EDIT: For anyone else reading, my workaround was to dynamically set base path depending on window.location. It's hacky but it works:

function basePath() {
  var origin = window.location.origin;
  var path = window.location.pathname;
  return origin + path.replace(/index.html/gi, '');
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

trusktr
trusktr approved these changes Jan 20, 2020
View reviewed changes

@trusktr trusktr left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, just needs conflicts resolved.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@trusktr

trusktr commented Jan 20, 2020

Copy link
Copy Markdown
Member

A workaround is to use another static serve like apache or nginx, and configure the root path in one of those.

jameshalsall reacted with thumbs down emoji
All reactions
  • 👎 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trusktr

trusktr commented Jan 20, 2020

Copy link
Copy Markdown
Member

Unfortunately, it seems like the popular NPM packages for static serving don't support this feature. Unless I overlooked it, serve, http-server, and live-server don't have any options for this. Seems like such a standard necessary feature for a static server.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cdtinney

cdtinney commented Jan 21, 2020

Copy link
Copy Markdown

@trusktr It's supported via middleware. It should be possible to rewrite all requests matching the configured path.

e.g.

local-web-server - https://github.com/lwsjs/rewrite
serve - https://github.com/zeit/serve-handler#rewrites-array

And so on.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trusktr

trusktr commented Jan 22, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Seems like what we should do is instead of building our own static server CLI with defaults, allow any options to be passed to the underlying tool, support passing in middleware, and maybe have our own default set of middleware if we need. Thoughts?

EDIT: even if we were to do this later, I'm still in favor of merging this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MonkeyAndres

MonkeyAndres commented Nov 18, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I fixed that for the moment using local-web-server - https://github.com/lwsjs/rewrite

Running command: ws -p 3000 -r '/base-path/(.*) -> http://localhost:3000/$1'. It seems to work on / and on /base-path/

Maybe when I'll get some time will fix the CI and complete the PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fsubal fsubal mentioned this pull request Mar 22, 2022
docsify-cli をやめて vite でドキュメントの動作確認を行う pixiv/charcoal#16
Merged
2 tasks
This was referenced May 8, 2024
Draft VerifiedJoseph/vigilant#190
Closed
Created a Vigilant logo and added a documentation site VerifiedJoseph/vigilant#191
Closed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@trusktr trusktr trusktr approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add root path to serve

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@iamdanfox @cdtinney @trusktr @MonkeyAndres
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.