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] parseMarkdown startDelimiter #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NicolasRoehm
Copy link

I was not able to build the pages on Windows 10 using unibit build or unibit develop.
It always outputs [Unibit] Generating 0 pages...
I removed the \n on each startDelimiter and it now works.
Surprisingly, endDelimiter works fine as is, for example, \n---.

@NicolasRoehm
Copy link
Author

I have found other issues related to Windows 10 :

  • In unibit.js -> getPages(), the split by '/' result is irrelevant because Windows provides '\\'
    • A trick can be to add some urlPath = urlPath.replace('\\', '/'); here and there
  • In browser routing with base/index pages does not work and sends 404, Windows users must add /index manually at the end of the URL

Because Unibit works great on Linux, I'll continue to use it in the right way.
You can close this issue and/or ping me with guidelines to fix these issues properly.

Thank you for sharing this library, it's very useful and working well (on real OS) ! :)

src/utils.js Outdated Show resolved Hide resolved
Copy link
Author

@NicolasRoehm NicolasRoehm left a comment

Choose a reason for hiding this comment

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

Updated in 49108ea

@NicolasRoehm NicolasRoehm requested a review from smnh May 21, 2021 14:02
Copy link
Member

@smnh smnh left a comment

Choose a reason for hiding this comment

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

@NicolasRoehm thanks for the PR.

Good catch with the EOL.

Regarding path.sep, please see comments inline

Comment on lines +355 to +357
let pageUrl = _.trim(_.get(page, 'url'), path.sep);
pageUrl = prettyUrl(pageUrl);
const pageUrlParts = _.split(pageUrl, '/');
const pageUrlParts = _.split(pageUrl, path.sep);
Copy link
Member

Choose a reason for hiding this comment

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

Here we are handling page URL paths. URLs always use forward slash disregards to the underlying system /.
On windows system, the path.sep will be \ so the logic will not work for URL paths

Copy link
Author

Choose a reason for hiding this comment

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

Here the path.sep is not about URL but rather about file routing/parsing.

On windows system, the page.url value prints \\blog\\author\\dianne-ameter.

  • When we try to remove the leading and trailing / character(s) with _.trim, nothing happens :
    • pageUrl contains \\blog\\author\\dianne-ameter instead of blog\\author\\dianne-ameter.
  • Then we split the url parts by the hardcoded /, so we get :
    • pageUrlParts = [ '\\blog\\author\\dianne-ameter' ] instead of ['blog', 'author', 'dianne-ameter'].

This causes the blog page to not list any blog posts and all subdirectory routes are skipped/broken.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting,
Then I guess the root cause of this bug is somewhere before the execution of this code.
The page.url should never have OS specific separators and should always have standard URL forward slash - /.
Maybe the code that constructs the original url property?

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

Successfully merging this pull request may close these issues.

None yet

2 participants