Skip to content

Commit

Permalink
Merge pull request #516 from Mile-Writings/feat/#500/dynamicOGImage
Browse files Browse the repository at this point in the history
[ Feat/#500 ] 주석제거 및 og:url env로 추가
  • Loading branch information
ljh0608 authored Dec 25, 2024
2 parents d6c1318 + 2331395 commit 799eb82
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import axios from 'axios';

type GroupPostIdentifierTypes = {
groupId: string;
postId: string; // key는 문자열,
postId: string;
};
const generatePerformanceRoutes = async ({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
Expand All @@ -22,7 +22,6 @@ const generatePerformanceRoutes = async ({ mode }) => {

data.map((items: GroupPostIdentifierTypes) => {
dynamicRoutes.push(`/detail/${items.groupId}/${items.postId}`); // 정적 경로와 동적 경로를 결합하여 반환
// const metaData = await getPostDetailParsingMetaTg(`${items.value}`);
});

return dynamicRoutes;
Expand All @@ -33,30 +32,11 @@ function extractLastSegment(url: string): string {
return lastIndex !== -1 ? url.substring(lastIndex + 1) : url;
}

// async function ssr(url) {
// const browser = await puppeteer.launch({ headless: true });
// const page = await browser.newPage();
// await page.goto(url, { waitUntil: 'networkidle0' });
// const html = await page.content(); // serialized HTML of page DOM.
// await browser.close();
// return html;
// }

export default defineConfig(async ({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const dynamicRoutes = await generatePerformanceRoutes({ mode });

// const browser = await puppeteer.launch({
// executablePath: '/path/to/Chrome',
// });
return {
// server: {
// proxy: {
// // 문자열만: http://localhost:5173/foo -> http://localhost:4567/foo
// '/api': 'http://localhost:5173',
// },
// },

esbuild: {
// configure this value when the browser version of the development environment is lower
// minimum support es2015
Expand Down Expand Up @@ -122,17 +102,7 @@ export default defineConfig(async ({ mode }) => {
host: 'localhost',
port: 5173,
},
// puppeteer: async () => {
// const browser = await puppeteer.launch({
// headless: true,
// args: [
// '--no-sandbox',
// '--cdisable-setuid-sandbox',
// `-–chrome-version=${env.CHROME_VERSION}`,
// ],
// });
// },
// postProcess: postProcess,

rendererOptions: {
maxConcurrentRoutes: 1,
launchOptions: {
Expand All @@ -155,12 +125,9 @@ export default defineConfig(async ({ mode }) => {
`${env.VITE_DEV_BASE_URL}/api/post/${extractLastSegment(renderRoute.route)}`,
);

console.log(data);
const title = data.data.title;
const imageUrl = data.data.imageUrl;
console.log(title);
console.log(imageUrl);
// console.log(`${env.VITE_DEV_BASE_URL}/api/post/${extractLastSegment(renderRoute.route)}`);

renderRoute.html = renderRoute.html
.replace(/http:/i, 'https:')
.replace(/(https:\/\/)?(localhost|127\.0\.0\.1):\d*/i, 'https://www.milewriting.com');
Expand All @@ -182,7 +149,7 @@ export default defineConfig(async ({ mode }) => {
}" />
<meta name="keywords" content="글쓰기, 글모임, 글, 커뮤니티, 아티클" />
<meta property="og:description" content="${'링크를 클릭해 마일의 글을 만나보세요'}" />
<meta property="og:url" content="${env.VITE_DEV_BASE_URL}${renderRoute.route}" />
<meta property="og:url" content="${env.VITE_CLIENT_URL}${renderRoute.route}" />
</head>
`,
);
Expand Down

0 comments on commit 799eb82

Please sign in to comment.