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

🔗 Add support for myst.xref.json #372

Merged
merged 5 commits into from
May 7, 2024
Merged

🔗 Add support for myst.xref.json #372

merged 5 commits into from
May 7, 2024

Conversation

fwkoch
Copy link
Contributor

@fwkoch fwkoch commented May 4, 2024

Cross references for external MyST projects is added here: jupyter-book/mystmd#1180 - this PR finesses the themes so those changes work well:

  • myst.xref.json is served by the theme, similar to objects.inv
  • page json responses have permissive cors response to allow external sites to load the data
  • non-existent /api/lookup is no longer used for external links

@@ -14,7 +14,17 @@ function api404(message = 'No API route found at this URL') {

export const loader: LoaderFunction = async ({ request, params }) => {
const { slug } = params;
// Handle /myst.xref.json as slug
if (slug === 'myst.xref') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much nicer if we could have a separate loader in a different file [myst.xref.json].tsx. However, that URL gets gobbled up by this file, where $slug is resolved to myst.xref...

return json(data);
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
Copy link
Contributor Author

@fwkoch fwkoch May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers the basic case of loading cross-reference tool-tips from external sites. It won't work for github pages.

@rowanc1 rowanc1 merged commit 7eae252 into main May 7, 2024
2 checks passed
@rowanc1 rowanc1 deleted the feat/myst-xref branch May 7, 2024 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants