-
Notifications
You must be signed in to change notification settings - Fork 68
Add Snippets support to Github Files #832
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
base: main
Are you sure you want to change the base?
Conversation
Co-Authored-By: Claude <[email protected]>
This reverts commit adc8613.
Co-Authored-By: Claude <[email protected]>
|
Co-Authored-By: Claude <[email protected]>
Hey @ntindle I'll take a look over the weekend and make sure that we support it, through this PR or another |
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
maybe fixes #446 |
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
import { getFileExtension } from './utils'; | ||
|
||
const embedBlock = createComponent< | ||
{ url?: string }, | ||
{ visible: boolean }, | ||
{ url?: string; visible?: boolean }, |
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.
this fixes the hide/show header
@@ -130,6 +140,710 @@ const embedBlock = createComponent< | |||
}, | |||
}); | |||
|
|||
const snippetBlock = createComponent< |
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.
adds a snippet block that takes in a URL and one or more snippet tag
}, | ||
}); | ||
|
||
const simpleGithubBlock = createComponent< |
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.
Adds a block that lets you query by owner/repo/branch/file/snippets + supports multiple snippets
**GitHub Snippet**: Insert the snippet block, provide a GitHub URL and a snippet tag (e.g., "BaseOAuthExample"), and the integration will extract and display only the code between the `--8<-- [start:tag]` and `--8<-- [end:tag]` markers. You can also add multiple snippets to combine them into a single code block. | ||
|
||
**Simple GitHub Reference**: Insert the simple GitHub block and provide repository details (owner, repo, branch, file path) for an easier way to reference files without full URLs. |
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.
these could probably use some work on clarity
const constructGithubUrl = (owner: string, repo: string, branch: string, filePath: string) => { | ||
return `https://github.com/${owner}/${repo}/blob/${branch}/${filePath}`; | ||
}; | ||
|
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.
technically this won't work for self hosted github enterprise server instances, not sure if that matters. If so, we can change the config to include a baseline root URL
We're looking at migrating over from mkdocs-material and one of the features we use heavily is
snippets
based on https://facelessuser.github.io/pymdown-extensions/extensions/snippets/This brings over a simple version of that to cover our needs