-
Notifications
You must be signed in to change notification settings - Fork 24
F/mint text url preprocessing #1066
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
630b82b
feat: wrap text node urls for mint mdx
fernando-aviles 2bc6973
fix: lint
fernando-aviles cc5c08a
chore: changeset
fernando-aviles d058d69
chore: cleanup
fernando-aviles 6b2b11d
fix: small refactor
fernando-aviles e325ce1
fix: lint
fernando-aviles abffedc
fix: consolidate
fernando-aviles d05bca8
fix: address parentheses issues
fernando-aviles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'gtx-cli': patch | ||
| --- | ||
|
|
||
| Wrapping text node URLs for Mintlify MDX to align with their parser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { Settings } from '../../../types/index.js'; | ||
| import { isValidMdx } from '../../../utils/validateMdx.js'; | ||
|
|
||
| /** | ||
| * Runs MDX-specific preprocessing. Returns a skip reason if the file | ||
| * should be skipped, or null if validation passed. | ||
| */ | ||
| export function preprocessMdx( | ||
| content: string, | ||
| filePath: string, | ||
| settings: Settings | ||
| ): string | null { | ||
| if (!settings.options?.skipFileValidation?.mdx) { | ||
| const validation = isValidMdx(content, filePath); | ||
| if (!validation.isValid) { | ||
| return `MDX file is not AST parsable${validation.error ? `: ${validation.error}` : ''}`; | ||
| } | ||
| } | ||
| return null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Settings } from '../../../types/index.js'; | ||
| import { applyMintlifyTitleFallback } from '../../../utils/mintlifyTitleFallback.js'; | ||
| import wrapPlainUrls from '../../../utils/wrapPlainUrls.js'; | ||
|
|
||
| /** | ||
| * Runs all Mintlify-specific preprocessing on file content. | ||
| */ | ||
| export function preprocessMintlify( | ||
| content: string, | ||
| filePath: string, | ||
| fileType: string, | ||
| settings: Settings | ||
| ): string { | ||
| let result = content; | ||
|
|
||
| if ( | ||
| fileType === 'mdx' && | ||
| settings.options?.mintlify?.inferTitleFromFilename | ||
| ) { | ||
| result = applyMintlifyTitleFallback( | ||
| result, | ||
| filePath, | ||
| settings.defaultLocale | ||
| ).content; | ||
| } | ||
|
|
||
| if (fileType === 'mdx') { | ||
| result = wrapPlainUrls(result); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { Settings } from '../../types/index.js'; | ||
| import { preprocessMdx } from './preprocess/mdx.js'; | ||
| import { preprocessMintlify } from './preprocess/mintlify.js'; | ||
| import sanitizeFileContent from '../../utils/sanitizeFileContent.js'; | ||
|
|
||
| /** | ||
| * Preprocesses file content before upload. Returns the processed content, | ||
| * or { skip: reason } if the file should be skipped. | ||
| */ | ||
| export function preprocessContent( | ||
| content: string, | ||
| filePath: string, | ||
| fileType: string, | ||
| settings: Settings | ||
| ): string | { skip: string } { | ||
| let result = content; | ||
|
|
||
| // File-type-specific | ||
| if (fileType === 'mdx') { | ||
| const skipReason = preprocessMdx(result, filePath, settings); | ||
| if (skipReason) return { skip: skipReason }; | ||
| } | ||
|
|
||
| // Framework-specific | ||
| if (settings.framework === 'mintlify') { | ||
| result = preprocessMintlify(result, filePath, fileType, settings); | ||
| } | ||
|
|
||
| // Universal | ||
| result = sanitizeFileContent(result); | ||
|
|
||
| return result; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| // This file is auto-generated. Do not edit manually. | ||
| export const PACKAGE_VERSION = '2.6.27'; | ||
| export const PACKAGE_VERSION = '2.6.29'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.