-
Notifications
You must be signed in to change notification settings - Fork 142
RDoc-3598 Implement Edit on GitHub functionality #2222
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
Conversation
963a035 to
5b6b170
Compare
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.
The user flow is incorrect.
https://issues.hibernatingrhinos.com/issue/RDoc-3449/Plan-Edit-on-GitHub-button-for-community-fixes#focus=Comments-67-1071423.0-0
He's redirected to language-specific (currently selected) page content on GitHub (edit mode)
Instead of redirecting to GitHub article .mdx page (view mode) we need to generate links to according language-specific files in edit mode (based on the selected language context)
e.g. https://github.com/ravendb/docs/edit/main/docs/client-api/_setting-up-authentication-and-authorization-csharp.mdx instead of https://github.com/ravendb/docs/blob/main/docs/client-api/setting-up-authentication-and-authorization.mdx
So if I'm viewing Python version of a doc, I'm redirected to edit that specific Python version.
If the document is language-agnostic, fallback to the default article page.
|
@poissoncorp It should also point to the selected version, right? |
That might be hard to achieve because we have inconsistency in language-specific content placement. Some of the files are placed inside an additional It could probably be possible using a customized editUrl functionality, but that's beyond my reach. @kalczur what do you think? |
5b6b170 to
c0c577a
Compare
Added handling of this |
| title: "Connection String to Azure OpenAI" | ||
| sidebar_label: Azure OpenAI | ||
| sidebar_position: 1 | ||
| supportedLanguages: ["csharp"] |
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.
Should be snake_case for consistency?
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.
Changed, used camel case at first because it's used as a property in the code but it's more important to have consistent frontmatter syntax
src/theme/DocItem/Footer/index.tsx
Outdated
| {canDisplayEditMetaRow && ( | ||
| <EditMetaRow | ||
| className={clsx(ThemeClassNames.docs.docFooterEditMetaRow)} | ||
| editUrl={getEditUrlWithLanguage(editUrl, language, metadata.frontMatter.supportedLanguages)} |
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.
Extend DocFrontMatter type to get proper type for supportedLanguages.
You can put it in src/typescript/docMetadata.d.ts
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.
Extended
src/theme/DocItem/Footer/index.tsx
Outdated
| import { HIDDEN_EDIT_PAGE_ROUTES } from "@site/src/typescript/hiddenEditPageRoutes"; | ||
| import {useLanguage} from "@site/src/components/LanguageStore"; | ||
|
|
||
| const getEditUrlWithLanguage = (url: string, language: string, supportedLanguages: string[]) : string => { |
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.
| const getEditUrlWithLanguage = (url: string, language: string, supportedLanguages: string[]) : string => { | |
| const getEditUrlWithLanguage = (url: string, language: DocsLanguage, supportedLanguages: DocsLanguage[]) : string => { |
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.
Changed
https://issues.hibernatingrhinos.com/issue/RDoc-3598/Edit-on-GitHub-Implementation