Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

fix: resolve markdown links to handle relative URLs#358

Merged
camwiegert merged 5 commits intomasterionic-team/ionic-docs:masterfrom
absolute-linksionic-team/ionic-docs:absolute-linksCopy head branch name to clipboard
Jan 28, 2019
Merged

fix: resolve markdown links to handle relative URLs#358
camwiegert merged 5 commits intomasterionic-team/ionic-docs:masterfrom
absolute-linksionic-team/ionic-docs:absolute-linksCopy head branch name to clipboard

Conversation

@ltm
Copy link
Contributor

@ltm ltm commented Jan 26, 2019

No description provided.

@ltm ltm requested a review from camwiegert January 26, 2019 18:23
scripts/build-pages/markdown-renderer/link.ts Outdated Show resolved Hide resolved
@camwiegert
Copy link
Contributor

Looking at the way that GitHub resolves links in a README, they seem to resolve all base paths as if they were a directory.

githubResolve('/some/path', '../other-path') => '/some/other-path'
githubResolve('/some/path/', '../other-path') => '/some/other-path'

Whereas Node's plain url.resolve would handle it like this:

url.resolve('/some/path', '../other-path') => '/other-path'
url.resolve('/some/path/', '../other-path') => '/some/other-path'

So I think we should handle it like GitHub and append a trailing slash during resolution if there isn't one.

resolve(/\/$/.test(basePath) ? basePath : `${basePath}/`, href)

Does that make sense?

@ltm
Copy link
Contributor Author

ltm commented Jan 28, 2019

@camwiegert I was achieving that with the trailing slash here:

const baseUrl = `/docs/api/${title.slice(4)}/`;

But it looks like that got lost in the merge.

@camwiegert
Copy link
Contributor

@ltm Oh, I see. I think I'd rather move that into the link renderer so that it will apply to every link instead of just the API pages.

@ltm
Copy link
Contributor Author

ltm commented Jan 28, 2019

@camwiegert 👍

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.