mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -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) {
|
fromDriver(value) {
|
||||||
// TODO: Get this from somewhere else
|
// TODO: Get this from somewhere else
|
||||||
const studioUrl =
|
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}`;
|
return `${studioUrl}?id=${value}`;
|
||||||
},
|
},
|
||||||
|
|
|
@ -73,7 +73,7 @@ async function storageRequest(fileKind: 'all' | 'image' = 'all', serveUrl: strin
|
||||||
function rearrangeData(data: any, serveUrl: string) {
|
function rearrangeData(data: any, serveUrl: string) {
|
||||||
const grouped: Record<string, any> = {};
|
const grouped: Record<string, any> = {};
|
||||||
for (const item of data) {
|
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;
|
return grouped;
|
||||||
|
|
|
@ -5,12 +5,17 @@ export function getAstroStudioEnv(envMode = ''): Record<`ASTRO_STUDIO_${string}`
|
||||||
return env;
|
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 {
|
export function getAstroStudioUrl(): string {
|
||||||
const env = getAstroStudioEnv();
|
const env = getAstroStudioEnv();
|
||||||
return env.ASTRO_STUDIO_URL || 'https://studio.astro.build';
|
return env.ASTRO_STUDIO_URL || 'https://studio.astro.build';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAstroStudioFileServerUrl(): string {
|
export function getAstroStudioFileServerUrl(): string {
|
||||||
const env = getAstroStudioEnv();
|
const env = getPublicAstroStudioEnv();
|
||||||
return env.ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file';
|
return env.PUBLIC_ASTRO_STUDIO_FILE_SERVER || 'https://studio.astro.build/api/serve_file';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue