mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: branch naming
This commit is contained in:
1 parent
a06fc87009
commit
adf00a0bbd
4 files changed
+26
-14
No files matched your search
@@ -1,11 +1,11 @@
|
||||
---
|
||||
import { imgur } from '@blitzkit/core';
|
||||
import { Code, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { BRANCH_NAMES } from '../constants/branches';
|
||||
import { undefined } from 'astro:schema';
|
||||
import { resolveBranchName } from '../core/blitzkit/branches';
|
||||
|
||||
const isBranchNamed =
|
||||
import.meta.env.PUBLIC_ASSET_BRANCH &&
|
||||
BRANCH_NAMES[import.meta.env.PUBLIC_ASSET_BRANCH];
|
||||
const branchName = resolveBranchName();
|
||||
const isBranchNamed = branchName !== undefined;
|
||||
---
|
||||
|
||||
<style>
|
||||
@@ -58,7 +58,7 @@ const isBranchNamed =
|
||||
{
|
||||
isBranchNamed && (
|
||||
<Code size="8" color="gray" highContrast variant="outline">
|
||||
{BRANCH_NAMES[import.meta.env.PUBLIC_ASSET_BRANCH!]}
|
||||
{branchName}
|
||||
</Code>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,16 +17,16 @@ import {
|
||||
Separator,
|
||||
Text,
|
||||
} from '@radix-ui/themes';
|
||||
import { BRANCH_NAMES } from '../constants/branches';
|
||||
import { resolveBranchName } from '../core/blitzkit/branches';
|
||||
import { homeTool, TOOLS } from '../constants/tools';
|
||||
import { PatreonIcon } from './PatreonIcon';
|
||||
import { NavbarAccount } from './NavbarAccount';
|
||||
import { undefined } from 'astro:schema';
|
||||
|
||||
const toolsFiltered = TOOLS.filter((tool) => !('href' in tool));
|
||||
const tools = [homeTool, ...toolsFiltered];
|
||||
const isBranchNamed =
|
||||
import.meta.env.PUBLIC_ASSET_BRANCH &&
|
||||
BRANCH_NAMES[import.meta.env.PUBLIC_ASSET_BRANCH];
|
||||
const branchName = resolveBranchName();
|
||||
const isBranchNamed = branchName !== undefined;
|
||||
---
|
||||
|
||||
<style>
|
||||
@@ -124,7 +124,7 @@ const isBranchNamed =
|
||||
{
|
||||
isBranchNamed && (
|
||||
<Code color="gray" size="1" highContrast variant="outline">
|
||||
{BRANCH_NAMES[import.meta.env.PUBLIC_ASSET_BRANCH!]}
|
||||
{branchName}
|
||||
</Code>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export const BRANCH_NAMES: Record<string, string> = {
|
||||
dev: 'dev',
|
||||
opentest: 'opentest',
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
|
||||
const BRANCH_NAMES: Record<string, string> = {
|
||||
dev: 'beta',
|
||||
opentest: 'opentest',
|
||||
};
|
||||
|
||||
export function resolveBranchName() {
|
||||
if (assertSecret(import.meta.env.MODE) === 'development') {
|
||||
return 'dev';
|
||||
} else {
|
||||
return BRANCH_NAMES[assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH)] as
|
||||
| string
|
||||
| undefined;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user