mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: code split correctly
This commit is contained in:
1 parent
f48c5d246d
commit
9bf1554c30
3 files changed
+10
-11
No files matched your search
@@ -4,7 +4,7 @@ import { CatalogItemAccessor } from './catalogItemAccessor';
|
|||||||
import { MetadataAccessor } from './metadata';
|
import { MetadataAccessor } from './metadata';
|
||||||
|
|
||||||
export class SocketMetadataAccessor extends MetadataAccessor {
|
export class SocketMetadataAccessor extends MetadataAccessor {
|
||||||
private items: Record<string, CatalogItem> = {};
|
items: Record<string, CatalogItem> = {};
|
||||||
|
|
||||||
constructor(metadata: Metadata) {
|
constructor(metadata: Metadata) {
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import type { MetadataAccessor } from 'packages/core/src';
|
import type { MetadataAccessor } from 'packages/core/src';
|
||||||
import { remoteMetadata } from './metadata.remote';
|
|
||||||
import { socketMetadata } from './metadata.socket';
|
|
||||||
|
|
||||||
let accessor: MetadataAccessor;
|
let accessor: MetadataAccessor;
|
||||||
|
|
||||||
if (import.meta.env.SSR) {
|
if (import.meta.env.SSR) {
|
||||||
accessor = socketMetadata;
|
accessor = await import('./metadata.socket').then((m) => m.socketMetadata);
|
||||||
} else {
|
} else {
|
||||||
accessor = remoteMetadata;
|
accessor = await import('./metadata.remote').then((m) => m.remoteMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const metadata = accessor;
|
export const metadata = accessor;
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
import type { APIRoute, GetStaticPaths, GetStaticPathsItem } from 'astro';
|
import type { APIRoute, GetStaticPaths, GetStaticPathsItem } from 'astro';
|
||||||
import { catalog } from 'packages/website-ue/src/core/blitz/metadata';
|
import { socketMetadata } from 'packages/website-ue/src/core/blitz/metadata.socket';
|
||||||
|
|
||||||
export const getStaticPaths: GetStaticPaths = () => {
|
export const getStaticPaths: GetStaticPaths = () => {
|
||||||
const paths: GetStaticPathsItem[] = [];
|
const paths: GetStaticPathsItem[] = [];
|
||||||
|
|
||||||
for (const item in catalog.items) {
|
for (const item in socketMetadata.items) {
|
||||||
paths.push({ params: { item } });
|
paths.push({ params: { item } });
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GET: APIRoute<{}, { item: string }> = ({ params }) => {
|
export const GET: APIRoute<{}, { item: string }> = async ({ params }) => {
|
||||||
return new Response(catalog.get(params.item).encode(), {
|
return new Response(
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
await socketMetadata.get(params.item).then((item) => item.encode()),
|
||||||
});
|
{ headers: { 'Content-Type': 'application/octet-stream' } },
|
||||||
|
);
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user