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

feat: parse docs in 2 steps to avoid user waiting with no content #7149

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions ui/src/components/docs/ContextDocs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@
if (!("canShare" in navigator)) {
content = content.replaceAll(/\s*web-share\s*/g, "");
}
const parse = await getMDCParser()
ast.value = await parse(content);
const parse = await getMDCParser();
// this hack alleviates a little the parsing load of the first render on big docs
// by only rendering the first 50 lines of the doc on opening
// since they are the only ones visible in the beginning
const firstLinesOfContent = content.split("---\n")[2].split("\n").slice(0, 50).join("\n") + "\nLoading the rest...\n";
ast.value = await parse(firstLinesOfContent);
setTimeout(async () => {
ast.value = await parse(content);
}, 50);
}

watch(docPath, async (val) => {
Expand Down