Skip to content

Commit

Permalink
📦 Upgrade to v0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 committed May 7, 2024
1 parent 20647dc commit b37b5ac
Show file tree
Hide file tree
Showing 8 changed files with 895 additions and 969 deletions.
6 changes: 5 additions & 1 deletion theme/app/routes/$project.$slug[.json].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ export const loader: LoaderFunction = async ({ request, params }) => {
const { project, slug } = params;
const data = await getPage({ name: project as string, slug }).catch(() => null);
if (!data) return api404('No page found at this URL.');
return json(data);
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
},
});
};
14 changes: 14 additions & 0 deletions theme/app/routes/$project.[myst.xref.json].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { json, type LoaderFunction } from '@remix-run/node';
import { getMystXrefJson } from '~/utils/loaders.server';

export const loader: LoaderFunction = async ({ params }): Promise<Response> => {
const { project } = params;
if (!project) return new Response('myst.xref.json not found', { status: 404 });
const data = await getMystXrefJson(project);
if (!data) return new Response('myst.xref.json not found', { status: 404 });
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
},
});
};
6 changes: 5 additions & 1 deletion theme/app/routes/$project[.json].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ export const loader: LoaderFunction = async ({ request, params }) => {
const { project } = params;
const data = await getPage({ name: project as string }).catch(() => null);
if (!data) return api404('No page found at this URL.');
return json(data);
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
},
});
};
6 changes: 5 additions & 1 deletion theme/app/routes/overview.$slug[.json].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ export const loader: LoaderFunction = async ({ request, params }) => {
const { slug } = params;
const data = await getPage({ name: 'overview', slug }).catch(() => null);
if (!data) return api404('No page found at this URL.');
return json(data);
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
},
});
};
13 changes: 13 additions & 0 deletions theme/app/routes/overview.[myst.xref.json].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { json, type LoaderFunction } from '@remix-run/node';
import { getMystXrefJson } from '~/utils/loaders.server';

export const loader: LoaderFunction = async (): Promise<Response> => {
const project = 'overview';
const data = await getMystXrefJson(project);
if (!data) return new Response('myst.xref.json not found', { status: 404 });
return json(data, {
headers: {
'Access-Control-Allow-Origin': '*',
},
});
};
4 changes: 4 additions & 0 deletions theme/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ export async function getPage(opts: {
export async function getObjectsInv(project: string): Promise<ArrayBuffer | undefined> {
return cdn.getObjectsInv(getDocsSites(project));
}

export async function getMystXrefJson(project: string): Promise<Record<string, any> | null> {
return cdn.getMystXrefJson(getDocsSites(project));
}
Loading

0 comments on commit b37b5ac

Please sign in to comment.