[Fix] parseMarkdown startDelimiter by NicolasRoehm · Pull Request #24 · stackbit/unibit · GitHub
Skip to content

[Fix] parseMarkdown startDelimiter#24

Open
NicolasRoehm wants to merge 3 commits into
stackbit:masterfrom
NicolasRoehm:master
Open

[Fix] parseMarkdown startDelimiter#24
NicolasRoehm wants to merge 3 commits into
stackbit:masterfrom
NicolasRoehm:master

Conversation

@NicolasRoehm

Copy link
Copy Markdown

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
Copy Markdown
Author

Comment thread src/utils.js Outdated

@NicolasRoehm NicolasRoehm left a comment

Copy link
Copy Markdown
Author

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

@smnh smnh left a comment

Copy link
Copy Markdown
Contributor

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 thread src/unibit.js
Comment on lines +355 to +357

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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.

2 participants