mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix: return customId in URL
This commit is contained in:
parent
e4546de377
commit
5975273752
3 changed files with 10 additions and 4 deletions
|
@ -63,7 +63,8 @@ const fileType = customType<{ data: string; driverData: string }>({
|
|||
fromDriver(value) {
|
||||
// TODO: Get this from somewhere else
|
||||
const studioUrl =
|
||||
process.env.ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file';
|
||||
(import.meta as any).env.PUBLIC_ASTRO_STUDIO_FILE_SERVER ||
|
||||
'https://studio.astro.build/api/serve_file';
|
||||
|
||||
return `${studioUrl}?id=${value}`;
|
||||
},
|
||||
|
|
|
@ -73,7 +73,7 @@ async function storageRequest(fileKind: 'all' | 'image' = 'all', serveUrl: strin
|
|||
function rearrangeData(data: any, serveUrl: string) {
|
||||
const grouped: Record<string, any> = {};
|
||||
for (const item of data) {
|
||||
grouped[item.name] = { ...item, serve_url: `${serveUrl}?id=${item.id}` };
|
||||
grouped[item.name] = { ...item, serve_url: `${serveUrl}?id=${item.customId}` };
|
||||
}
|
||||
|
||||
return grouped;
|
||||
|
|
|
@ -5,12 +5,17 @@ export function getAstroStudioEnv(envMode = ''): Record<`ASTRO_STUDIO_${string}`
|
|||
return env;
|
||||
}
|
||||
|
||||
export function getPublicAstroStudioEnv(): Record<`PUBLIC_ASTRO_STUDIO_${string}`, string> {
|
||||
const env = loadEnv('', process.cwd(), 'PUBLIC_ASTRO_STUDIO_');
|
||||
return env;
|
||||
}
|
||||
|
||||
export function getAstroStudioUrl(): string {
|
||||
const env = getAstroStudioEnv();
|
||||
return env.ASTRO_STUDIO_URL || 'https://studio.astro.build';
|
||||
}
|
||||
|
||||
export function getAstroStudioFileServerUrl(): string {
|
||||
const env = getAstroStudioEnv();
|
||||
return env.ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file';
|
||||
const env = getPublicAstroStudioEnv();
|
||||
return env.PUBLIC_ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue