-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Automatically render wiki TOC #19873
Conversation
Automatically add sidebar in the wiki view containing a TOC for the wiki page. Fix go-gitea#822 Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
I think the problem is the toc need a hide button but that could be another PR. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Happy for this to be moved into 1.17 btw. |
done |
I would like it becomes a per-user setting to show or hide the directory defaultly and also we need a more width screen for the main area. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise lgtm, just the helper function can cause some issues when used by future code.
Signed-off-by: Andrew Thornton <art27@cantab.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry for asking but I am not able to find the information in the code diff. How should a markdown file look like that Gitea render an automatic TOC for it? Something like this?
And how would the result look like? Do you have a screenshot? |
You can try it on try.gitea.io: https://try.gitea.io/wxiaoguang/test/wiki/test-toc
|
I assume I miss understand something. This link goes to a wiki page. Does this work for markdown-files (e.g. README.md) also? I also would say it is not a good idea to render the TOC as a separate element. It is lost where it is now. A toc should be there where the TOC-Placeholder (e.g. something like Let me give you an example: Here you see
|
Nope, this PR is only for Wiki TOC.
Since this PR has got approvals and got merged, there could be new issues for the features & enhancements. |
Add this to the top of your markdown file. ---
gitea: none
include_toc: true
--- |
* giteaofficial/main: Prevent NPE whilst migrating if there is a team request review (go-gitea#19855) [skip ci] Updated translations via Crowdin Add support for rendering terminal output with colors (go-gitea#19497) Fix viewed images not loading in a PR (go-gitea#19919) Remove out-dated comments (go-gitea#19921) Automatically render wiki TOC (go-gitea#19873) Improve wording on delete access token modal (go-gitea#19909) [skip ci] Updated translations via Crowdin Add breaking email restrictions checker in doctor (go-gitea#19903) Ensure minimum mirror interval is reported on settings page (go-gitea#19895) Improve UX on modal for deleting an access token (go-gitea#19894) update discord invite (go-gitea#19907) Only log non ErrNotExist errors in git.GetNote (go-gitea#19884) [skip ci] Updated translations via Crowdin Update frontend guideline (go-gitea#19901) Make AppDataPath absolute against the AppWorkPath if it is not (go-gitea#19815)
Where can I find the documentation about it? The term Are there some more modifiers for the toc? e.g. I don't like the fold-mechanism and the headline is not in h1-style. |
Thank you very much for your excellent work. Could you add this feature to TOC ? When user scroll the page down, make the TOC fixed to top,. function convertRemToPixels(rem) {
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
}
function UpdateTOCPosition() {
if (!jQuery) {
return;
}
const toc = jQuery(".wiki-content-toc");
if (toc.length <= 0) {
return;
}
const parent = toc[0].parentElement;
const parentRect = parent.getBoundingClientRect();
if (parentRect.top < 0) {
const padding = convertRemToPixels(2)
toc.css({ position: "fixed", width: parent.clientWidth-padding, "top": 0 })
} else {
toc.css({ position: "inherit", width: "auto" })
}
}
window.addEventListener("scroll", UpdateTOCPosition);
window.addEventListener("resize", UpdateTOCPosition); |
Automatically add sidebar in the wiki view containing a TOC for the wiki page. Make the TOC collapsable Signed-off-by: Andrew Thornton <art27@cantab.net>
Automatically add sidebar in the wiki view containing a TOC for the wiki page.
Fix #822
Signed-off-by: Andrew Thornton art27@cantab.net