Skip to content

Commit c471e78

Browse files
authored
Merge pull request #113 from bsospace/develop
Develop
2 parents 21b60c5 + 73cb680 commit c471e78

3 files changed

Lines changed: 51 additions & 33 deletions

File tree

Jenkinsfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pipeline {
3131
default:
3232
env.ENVIRONMENT = 'other'
3333
env.DOCKER_COMPOSE_FILE = ''
34-
echo "Branch ${branchName} is not supported. Skipping deployment."
34+
env.ENV_FILE_CREDENTIAL = 'blog-dev-env-file'
3535
}
3636

3737
echo "Environment: ${env.ENVIRONMENT}"
@@ -41,9 +41,6 @@ pipeline {
4141
}
4242

4343
stage('Setup .env') {
44-
when {
45-
expression { env.ENVIRONMENT != 'other' }
46-
}
4744
steps {
4845
script {
4946
withCredentials([file(credentialsId: env.ENV_FILE_CREDENTIAL, variable: 'SECRET_ENV_FILE')]) {
@@ -75,6 +72,14 @@ pipeline {
7572
}
7673
}
7774

75+
stage('Maual Build') {
76+
steps {
77+
script {
78+
sh 'npm run build'
79+
}
80+
}
81+
}
82+
7883
stage('Run Tests') {
7984
steps {
8085
script {

app/api/posts/edit/[id]/route.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@ import prisma from "@/prisma/client";
33
import { slugify } from "@/app/utils/slugify";
44
import { v4 as uuidv4 } from "uuid";
55
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
6+
import envConfig from "@/app/configs/envConfig";
67

7-
// Cloudflare R2 settings
8-
const R2_BUCKET_NAME = process.env.R2_BUCKET_NAME;
9-
const R2_ACCESS_KEY = process.env.R2_ACCESS_KEY;
10-
const R2_SECRET_KEY = process.env.R2_SECRET_KEY;
11-
const R2_ACCOUNT_ID = process.env.R2_ACCOUNT_ID;
12-
const R2_ENDPOINT = `https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com`;
8+
9+
const R2_ENDPOINT = `https://${envConfig.cloudflareR2AccessId}.r2.cloudflarestorage.com`;
1310

1411
const s3Client = new S3Client({
1512
region: "auto",
1613
endpoint: R2_ENDPOINT,
1714
credentials: {
18-
accessKeyId: R2_ACCESS_KEY!,
19-
secretAccessKey: R2_SECRET_KEY!,
15+
accessKeyId: envConfig.cloudflareR2AccessKey,
16+
secretAccessKey: envConfig.cloudflareR2SecretKey,
2017
},
2118
});
2219

@@ -32,16 +29,6 @@ async function uploadImagesFromContent(content: string): Promise<string> {
3229

3330
// If it's not an external URL (e.g., https://), consider it a blob
3431
const isExternalUrl = imgSrc.startsWith("https://");
35-
const oldBucketUrl = imgSrc.startsWith("https://bso-image.posyayee.shop/");
36-
37-
if (oldBucketUrl) {
38-
const newImageUrl = imgSrc.replace(
39-
"https://bso-image.posyayee.shop/",
40-
`https://assets.bsospace.com/`
41-
);
42-
43-
content = content.replace(imgSrc, newImageUrl);
44-
}
4532

4633
if (!isExternalUrl) {
4734
// Separate the image type and base64 data
@@ -59,15 +46,15 @@ async function uploadImagesFromContent(content: string): Promise<string> {
5946
// Upload image to Cloudflare R2
6047
const uploadPromise = s3Client.send(
6148
new PutObjectCommand({
62-
Bucket: R2_BUCKET_NAME,
49+
Bucket: envConfig.cloudflareR2BucketName,
6350
Key: newFileName,
6451
Body: imageBuffer,
6552
ContentType: contentType,
6653
})
6754
);
6855

6956
// Create new URL from Cloudflare R2
70-
const newImageUrl = `https://bso-image.posyayee.shop/${newFileName}`;
57+
const newImageUrl = `${envConfig.cloudflareR2Domain}/${newFileName}`;
7158
content = content.replace(imgSrc, newImageUrl);
7259

7360
uploads.push(uploadPromise);

app/components/Layout.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
11
"use client";
2-
import { ReactNode } from "react";
2+
import { ReactNode, useEffect, useState } from "react";
33
import ThemeSwitcher from "./ThemeSwitcher";
44
import Image from "next/image";
55
import logo from "../../public/BSO LOGO.svg";
66
import Link from "next/link";
7+
import axios from "axios";
8+
import Script from "next/script";
79

8-
interface LayoutProps {
9-
children: ReactNode;
10-
}
10+
export default function Layout({ children }: { children: ReactNode }) {
11+
const [version, setVersion] = useState<string>("unknown");
12+
13+
useEffect(() => {
14+
const fetchLatestVersion = async () => {
15+
try {
16+
const response = await axios.get(
17+
"https://api.github.com/repos/bsospace/BSOSpace-Blog-Frontend/releases/latest"
18+
);
19+
setVersion(response.data.tag_name || "unknown");
20+
} catch (error) {
21+
console.error("Error fetching latest version from GitHub:", error);
22+
setVersion("unknown");
23+
}
24+
};
25+
26+
fetchLatestVersion();
27+
}, []);
1128

12-
export default function Layout({ children }: LayoutProps) {
1329
return (
1430
<div className="flex flex-col min-h-screen dark:bg-space-dark bg-space-light">
15-
{/* eslint-disable-next-line @next/next/no-sync-scripts */}
16-
<script data-name="BMC-Widget" data-cfasync="false" src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js" data-id="bsospace" data-description="Support me on Buy me a coffee!" data-message="" data-color="#FF813F" data-position="Right" data-x_margin="18" data-y_margin="18"></script>
31+
<Script
32+
data-name="BMC-Widget"
33+
data-cfasync="false"
34+
src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js"
35+
data-id="bsospace"
36+
data-description="Support me on Buy me a coffee!"
37+
data-message=""
38+
data-color="#FF813F"
39+
data-position="Right"
40+
data-x_margin="18"
41+
data-y_margin="18"
42+
></Script>
1743
{/* Header */}
1844
<header className="sticky top-0 p-2 z-50 bg-white dark:bg-[#1F1F1F] shadow-md">
1945
<div className="container mx-auto px-4 flex justify-between items-center">
@@ -55,8 +81,8 @@ export default function Layout({ children }: LayoutProps) {
5581
{/* Footer */}
5682
<footer className="bg-white dark:bg-[#1F1F1F] py-4">
5783
<div className="container mx-auto text-center md:text-body-15pt-medium text-[10px]">
58-
Be Simple but Outstanding | &copy; 2025 BSO Space Blog. All rights
59-
reserved.
84+
Be Simple but Outstanding | Version: {version} | &copy; 2025 BSO Space
85+
Blog. All rights reserved.
6086
</div>
6187
</footer>
6288
</div>

0 commit comments

Comments
 (0)