Skip to content

Commit d5c378f

Browse files
committed
fix: 전역 스타일 로드 복구
1 parent 0db2f13 commit d5c378f

4 files changed

Lines changed: 63 additions & 37 deletions

File tree

src/components/widget/Profile.astro

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,40 @@
11
---
22
import { Icon } from "astro-icon/components";
3-
import normaAvatar1 from "../../assets/images/norma-1.mp4";
4-
import normaAvatar2 from "../../assets/images/norma-2.mp4";
53
import { profileConfig } from "../../config";
64
import { url } from "../../utils/url-utils";
75
import ImageWrapper from "../misc/ImageWrapper.astro";
86
97
const config = profileConfig;
10-
const avatars = [config.avatar || ""].flat().filter(Boolean);
11-
const avatar = avatars[0] || "";
12-
const isVideoAvatar =
13-
avatars.length > 0 &&
14-
avatars.every((item) => /\.(mp4|webm|ogg)([?#].*)?$/i.test(item));
158
16-
const localVideoAssets = new Map([
17-
["assets/images/norma-1.mp4", normaAvatar1],
18-
["assets/images/norma-2.mp4", normaAvatar2],
19-
]);
20-
const avatarVideoSrcList = [];
21-
for (const item of avatars) {
22-
if (!isVideoAvatar) {
23-
break;
24-
}
9+
const avatar = config.avatar || "";
10+
const avatarVideos = config.avatarVideos ?? [];
11+
const videoAssets = import.meta.glob<{ default: string }>("../../assets/images/*.{mp4,webm,ogg}", {
12+
eager: true,
13+
});
2514
15+
function resolveAvatarSrc(item: string) {
2616
const isLocalAvatar =
2717
!item.startsWith("/") &&
2818
!item.startsWith("http://") &&
2919
!item.startsWith("https://") &&
3020
!item.startsWith("data:");
31-
let src = item;
32-
if (isLocalAvatar) {
33-
const asset = localVideoAssets.get(item);
34-
if (!asset) {
35-
console.error(`\n[ERROR] Video file not found: src/${item}`);
36-
continue;
37-
}
38-
src = asset;
21+
if (!isLocalAvatar) return item.startsWith("/") ? url(item) : item;
22+
23+
const asset = videoAssets[`../../${item}`];
24+
if (!asset) {
25+
console.error(`\n[ERROR] Video file not found: src/${item}`);
26+
return "";
3927
}
40-
avatarVideoSrcList.push(src.startsWith("/") ? url(src) : src);
28+
return asset.default;
4129
}
30+
31+
const avatarVideoSrcList = avatarVideos.map(resolveAvatarSrc).filter(Boolean);
32+
33+
const hasAvatarVideos = avatarVideoSrcList.length > 0;
34+
35+
const isVideoAvatar =
36+
typeof avatar === "string" && /\.(mp4|webm|ogg)([?#].*)?$/i.test(avatar);
37+
const avatarVideoSrc = isVideoAvatar ? resolveAvatarSrc(avatar) : "";
4238
---
4339
<div class="card-base p-3">
4440
<a aria-label="Go to About Page" href={url('/about/')}
@@ -50,16 +46,34 @@ for (const item of avatars) {
5046
class="transition opacity-0 scale-90 group-hover:scale-100 group-hover:opacity-100 text-white text-5xl">
5147
</Icon>
5248
</div>
53-
{isVideoAvatar && <video
54-
src={avatarVideoSrcList[0]}
55-
data-avatar-videos={JSON.stringify(avatarVideoSrcList)}
56-
autoplay
57-
loop
58-
muted
59-
playsinline
60-
class="mx-auto lg:w-full h-full lg:mt-0 object-cover aspect-square"
61-
></video>}
62-
{!isVideoAvatar && <ImageWrapper src={avatar} class="mx-auto lg:w-full h-full lg:mt-0 object-cover aspect-square" alt={config.name}/>}
49+
{
50+
hasAvatarVideos ? (
51+
<video
52+
src={avatarVideoSrcList[0]}
53+
data-avatar-videos={JSON.stringify(avatarVideoSrcList)}
54+
autoplay
55+
loop
56+
muted
57+
playsinline
58+
class="mx-auto lg:w-full h-full lg:mt-0 object-cover aspect-square"
59+
/>
60+
) : avatarVideoSrc ? (
61+
<video
62+
src={avatarVideoSrc}
63+
autoplay
64+
loop
65+
muted
66+
playsinline
67+
class="mx-auto lg:w-full h-full lg:mt-0 object-cover aspect-square"
68+
/>
69+
) : (
70+
<ImageWrapper
71+
src={avatar}
72+
class="mx-auto lg:w-full h-full lg:mt-0 object-cover aspect-square"
73+
alt={config.name}
74+
/>
75+
)
76+
}
6377
</a>
6478
<div class="px-2">
6579
<div class="font-bold text-xl text-center mb-1 dark:text-neutral-50 transition">{config.name}</div>

src/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ export const navBarConfig: NavBarConfig = {
5353
};
5454

5555
export const profileConfig: ProfileConfig = {
56-
avatar: ["assets/images/norma-1.mp4", "assets/images/norma-2.mp4"], // Relative to the /src directory. Relative to the /public directory if it starts with '/'
56+
avatar: "assets/images/norma-1.mp4", // Relative to the /src directory. Relative to the /public directory if it starts with '/'
57+
avatarVideos: [
58+
"assets/images/norma-1.mp4", "assets/images/norma-2.mp4"
59+
],
5760
name: "Minjea Kim | 김민재",
5861
bio: "Make something fun.",
5962
links: [

src/layouts/Layout.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import { defaultFavicons } from "../constants/icon";
1919
import type { Favicon } from "../types/config";
2020
import { pathsEqual, url } from "../utils/url-utils";
2121
import "katex/dist/katex.css";
22+
import "../styles/variables.styl";
23+
import "../styles/main.css";
24+
import "../styles/scrollbar.css";
25+
import "../styles/transition.css";
26+
import "../styles/markdown.css";
27+
import "../styles/markdown-extend.styl";
28+
import "../styles/expressive-code.css";
29+
import "../styles/photoswipe.css";
2230
2331
interface Props {
2432
title?: string;

src/types/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export type NavBarConfig = {
6161
};
6262

6363
export type ProfileConfig = {
64-
avatar?: string | string[];
64+
avatar?: string;
65+
avatarVideos?: string[];
6566
name: string;
6667
bio?: string;
6768
links: {

0 commit comments

Comments
 (0)