Skip to content

Commit 29846c8

Browse files
committed
move assets to static folder for static file serving
1 parent 25ced27 commit 29846c8

22 files changed

+19
-12
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
volumes:
99
- ./mdx:/usr/src/app/mdx
1010
- ./public:/usr/src/app/public
11+
- ./static:/usr/src/app/static
1112
nginx:
1213
depends_on:
1314
- server

nginx/nginx.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ server {
5353
proxy_redirect off;
5454
}
5555

56-
location /public/ {
57-
alias /usr/src/app/public/;
56+
location /static/ {
57+
alias /usr/src/app/static/;
5858
}
5959

6060
}
@@ -97,8 +97,8 @@ server {
9797
proxy_redirect off;
9898
}
9999

100-
location /public/ {
101-
alias /usr/src/app/public/;
100+
location /static/ {
101+
alias /usr/src/app/static//;
102102
}
103103

104104
}

src/components/mdx.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,19 @@ function Image({ src, alt }: { src: string; alt: string }) {
181181
return (
182182
<div className="relative w-full h-full flex justify-center items-center">
183183
<img
184-
src={src}
184+
src={`/static${src}`}
185185
alt={alt}
186186
className="rounded-lg shadow-md my-5 mx-auto min-w-[200px] w-2/3 h-auto"
187+
onError={() => {
188+
setLoading(false);
189+
}}
187190
onLoad={() => {
188191
setLoading(false);
189192
}}
190193
style={{
191194
display: "block",
192-
opacity: loading ? 0 : 1,
193-
transition: "opacity 0.3s ease-in-out",
195+
opacity: loading ? 0.25 : 0.75,
196+
transition: "opacity 1s ease-in-out",
194197
}}
195198
/>
196199
<div

src/components/ui/Logos.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ export function PostgresLogo({ className }: { className: string }) {
381381

382382
export function TanstackLogo({ className }: { className: string }) {
383383
return (
384-
<img src="/tanstack-logo.png" alt="Tanstack Logo" className={className} />
384+
<img
385+
src="static/tanstack-logo.png"
386+
alt="Tanstack Logo"
387+
className={className}
388+
/>
385389
);
386390
}
387391

src/routes/about.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function AboutComponent() {
4343
frontmatter={frontmatter}
4444
leadImage={
4545
<img
46-
src="/self_portrait.jpg"
46+
src="static/self_portrait.jpg"
4747
alt="A picture of the author on a rainy day surrounded by cherry blossom trees"
4848
className="rounded-lg shadow-md my-5 mx-auto min-w-[200px] w-1/2"
4949
/>

src/utils/mdx-fetcher.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const bundler = (file: string, directory: string): Promise<IMDX> => {
3434
return bundleMDX({
3535
file: path.join(BASE_DIRECTORY, directory, file),
3636
cwd: BASE_DIRECTORY,
37-
bundleDirectory: path.join(BASE_DIRECTORY, "public/" + fileName),
38-
bundlePath: "/" + fileName + "/",
37+
bundleDirectory: path.join(BASE_DIRECTORY, directory),
38+
bundlePath: directory,
3939
mdxOptions(options: Options) {
4040
options.rehypePlugins = [
4141
...(options.rehypePlugins ?? []),
@@ -115,7 +115,6 @@ function getCategories(frontmatters: IFrontMatter[]) {
115115

116116
export const fetchMDXCode = createServerFn({ method: "GET" })
117117
.validator((data: { directory: string; slug: string }) => {
118-
console.log(data);
119118
return {
120119
directory: data.directory.toLowerCase(),
121120
slug: data.slug.toLowerCase(),
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)