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

Add note on absolute links #2507

Merged
merged 24 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
80be602
Add note on absolute links
jingting1412 Apr 8, 2024
6e3617b
Fix typos
jingting1412 Apr 8, 2024
92000fe
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 9, 2024
37dae13
Add tip to more pages
jingting1412 Apr 9, 2024
337ec36
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 11, 2024
fc0e857
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 11, 2024
7f25bb9
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 11, 2024
c9f1a47
Add negative example
jingting1412 Apr 11, 2024
cf4251f
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 11, 2024
ac5bc63
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 12, 2024
0fd7aa1
Update docs/userGuide/troubleshooting.md
jingting1412 Apr 12, 2024
5a2bb07
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
1f207ee
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
cdd953c
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
ed502e8
Add more details
jingting1412 Apr 12, 2024
686e19b
Improve explanation
jingting1412 Apr 12, 2024
ced6b4d
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 12, 2024
edfd5b0
Improve look of tip
jingting1412 Apr 12, 2024
9dff565
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
263eacd
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
1df6f67
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
2d9d4f4
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 15, 2024
262c987
Implement review changes
jingting1412 Apr 15, 2024
1693d54
Merge branch 'master' into popup-docs
Tim-Siu Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/userGuide/syntax/includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ When setting the `id` of a fragment, be careful not to clash with heading anchor
</box>

<include src="panels.md#script_and_styles_warning"></include>
<div id="baseUrl-warning">
<box type="warning" header="Add `{{ '{{ baseUrl }}' }}` to local URLs to always point to the same target!">
jingting1412 marked this conversation as resolved.
Show resolved Hide resolved

For links within `<include>` to always point to the same target, make it an absolute link with `{{ '{{ baseUrl }}' }}` included.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you include a negative example so users know what what not to do as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep sure included! lmk if its not clear or anything


For example, if file `folder1/file1.md` contains an absolute link `{{ '{{ [link]({{ baseUrl }}/folder1/target.html) }} ' }}` when `file1.md` is included in `folder2/file2.md`, the link will point to `folder1/target1.html`. Keep this in mind when putting content with links within `<include>`.
jingting1412 marked this conversation as resolved.
Show resolved Hide resolved
</box>
</div>


<include src="tip.md" boilerplate >
<span id="tip_body">
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ To ensure that links in the <code>_markbind/</code> folder work correctly across
{% endraw %}
</div>

<include src="includes.md#baseUrl-warning"/>

****Relative paths****

<div class="indented">
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ To safeguard against unintended consequences, consider directly incorporating th
</variable>
</include>

<include src="includes.md#baseUrl-warning"/>

**If `preload` attribute is provided, the panel body will load the HTML when the page renders instead of after being expanded.**

<include src="codeAndOutput.md" boilerplate >
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/popovers.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
</variable>
</include>

<include src="includes.md#baseUrl-warning"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-04-12 at 8 34 22 PM When embedded, it seems like the warning is very large and disrupts the flow of the text. Actually, even when it's not included the placing feels a little awkward. What if all or some of the content was in an expandable panel, so that it's out of the way? Just the header might be good? I suppose you could also experiment with having the example be expandable instead.

Copy link
Contributor Author

@jingting1412 jingting1412 Apr 12, 2024

Choose a reason for hiding this comment

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

yep sure, I've put the example into a panel and changed the explanation to make it more clear! I think since this issue is about links breaking when being included with <include>, the note at the includes section in the UG and troubleshooting section is also just about this specific problem.

If there's another cause to the link breaking issue other than include I think we can make a more generic one?


**Using trigger for Popover:**<br>

<include src="codeAndOutput.md" boilerplate >
Expand Down
13 changes: 12 additions & 1 deletion docs/userGuide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,15 @@ You could signpost Markdown either by:
<box> **This will be rendered as plain text**</box>
</variable>
</include>
</panel>
</panel>

##### Content with local links not working when included with `<include>`

jingting1412 marked this conversation as resolved.
Show resolved Hide resolved
If you notice that relative links in a page pointing to another page no longer works after adding it into a page via `<include>`, it may be because the relative link no longer points to the correct address in the new page with `<includes>`.

To solve this, change the relative URL into an **absolute** URL by adding `{{ '{{ baseUrl }}' }}`. This will ensure that the link will always point to the same address regardless of the page it is included in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a box here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep sure I have included it now!

###### Example: Adding `{{ '{{ baseUrl }}' }}` to make absolute URLs

Copy link
Contributor

Choose a reason for hiding this comment

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

This example is the same as other parts. Could we use includes to reduce duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep sure, the example can now be included using includes

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are using include from the include section, I was thinking whether we should create one that is more generic since user may be confused by the mentions of include? Wdyt? @jingting1412 @yucheng11122017

If file `folder1/file1.md` contains an absolute link `{{ '{{ [link]({{ baseUrl }}/folder1/target.html) }} ' }}`, when `file1.md` is included in `folder2/file2.md`, the link will point to `folder1/target1.html` even if the target is not in the same directory as `file2.md`.

Loading