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

Fix assets not found in Express server #720

Merged
merged 2 commits into from
Jun 2, 2018
Merged

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Jun 2, 2018

Motivation

Fixes #600

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  1. Create an image file in docs/assets/docusaurus.png

  2. Paste this to docs/getting-started-installation.md content
    ![docusaurus](/docs/assets/docusaurus.png)

  3. Run server on windows

cd website
npm start

http://localhost:3000/docs/en/next/installation.html

Before this PR
before

After this PR
after

Explanation:

According to https://expressjs.com/en/starter/static-files.html
The function signature is:

express.static(root, [options])

Previous code

  app.use(
    join(siteConfig.baseUrl, 'docs', 'assets'),
    express.static(join(CWD, '..', readMetadata.getDocsPath(), 'assets'))
  );
  app.use(
    join(siteConfig.baseUrl, 'blog', 'assets'),
    express.static(join(CWD, 'blog', 'assets'))
  );

We should not use path.join on Express root argument. Express.js expect something like /docs/assets/ as a root argument. path.join in Unix systems work differently when in Windows work.

Example:

console.log(path.join(siteConfig.baseUrl, 'docs', 'assets'));

In UNIX /docs/assets
In Windows \docs\assets

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 2, 2018
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 59b2595

https://deploy-preview-720--docusaurus-preview.netlify.com

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jun 2, 2018

Deploy preview for docusaurus-preview ready!

Built with commit 0c04019

https://deploy-preview-720--docusaurus-preview.netlify.com

Copy link
Contributor

@JoelMarcey JoelMarcey left a comment

Choose a reason for hiding this comment

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

❤️

Thank you @endiliey!

@JoelMarcey JoelMarcey merged commit b00e9d1 into facebook:master Jun 2, 2018
@endiliey endiliey deleted the assets branch July 12, 2018 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants