Skip to content

haguri-peng/tistory-blog-new

Repository files navigation

Tistory Blog

๐Ÿธ Haguri & Peng's Blog ๐Ÿง

Vue3 + Typescript + Vite์„ ํ†ตํ•ด ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•˜์˜€์œผ๋ฉฐ, Ex-Repository ์˜ ์†Œ์Šค๋ฅผ ๋ฆฌํŒฉํ† ๋ง ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

โœ Changelog

  • 2024/11/20 ๋‚ ์งœ ๊ด€๋ จ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ณ€๊ฒฝ (Moment.js -> date-fns)
  • 2024/11/10 Content์—์„œ ํ˜„์žฌ ํ™œ์„ฑํ™”(active) ์ค‘์ธ aside ์˜์—ญ์— underline ์„ค์ •
  • 2024/10/11 ๋Œ“๊ธ€ ๋ชจ๋‹ฌ์—์„œ ESC ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋‹ซํžˆ๋„๋ก ์„ค์ •. ์—ด๋ฆด ๋•Œ focus ์„ค์ •
  • 2024/10/3 ๋นŒ๋“œ๋œ ํŒŒ์ผ์„ ๋ธ”๋กœ๊ทธ์— ์ž๋™์œผ๋กœ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋„๋ก ์Šคํฌ๋ฆฝํŠธ ๋ฐ˜์˜

Vue

Pinia (Vuex -> Pinia)

๊ฒŒ์‹œ๊ธ€(post)์—์„œ ์ด์ „ ํŽ˜์ด์ง€๋กœ ์ด๋™ ์‹œ ํŽ˜์ด์ง€ ์ •๋ณด์™€ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ

// category.ts
import { reactive, computed } from 'vue';
import { defineStore } from 'pinia';

import { CategoryInfo } from '@/types';

const setValue = <T>(obj: T, key: keyof T, value: T[keyof T]) => {
  obj[key] = value;
};

export const useCategoryStore = defineStore('category', () => {
  const categoryInfo = reactive(<CategoryInfo>{});

  const getCategoryInfo = computed(() => categoryInfo);

  function setCategoryInfo(pCategoryInfo: CategoryInfo) {
    for (const key of Object.keys(pCategoryInfo)) {
      const categoryKey = key as keyof CategoryInfo;
      setValue<CategoryInfo>(
        categoryInfo,
        categoryKey,
        pCategoryInfo[categoryKey],
      );
    }
  }

  function clearCategoryInfo() {
    const initData = <CategoryInfo>{};
    for (const key of Object.keys(categoryInfo)) {
      const categoryKey = key as keyof CategoryInfo;
      setValue<CategoryInfo>(categoryInfo, categoryKey, initData[categoryKey]);
    }
  }

  return { categoryInfo, getCategoryInfo, setCategoryInfo, clearCategoryInfo };
});

Icon

Modal

  • Gitart Vue Dialog
    (๋Œ“๊ธ€/๋ฐฉ๋ช…๋ก ๋“ฑ๋ก, RecentTag)

Libraries

Color

Color Hunt

Tistory

2024/3/5 ์ดํ›„๋กœ Tistory Open API๋Š” ์„œ๋น„์Šค ์ข…๋ฃŒ!!

Tistory ์—์„œ ์ œ๊ณตํ•˜๋Š” Open API ๋ฅผ ํ™œ์šฉ (Tistory Open API).
์ œ๊ณตํ•ด์ฃผ๋Š” Open API ์— ํ•œ๊ณ„๊ฐ€ ์žˆ์–ด ์ด๋ฅผ ๊ฐ์•ˆํ•˜๊ณ  ๊ฐœ๋ฐœํ•˜์˜€์œผ๋‹ˆ ์ฐธ๊ณ  ๋ฐ”๋ž๋‹ˆ๋‹ค.

๋ชจ๋ฐ”์ผ ํŽ˜์ด์ง€๋Š” Tistory์—์„œ ์ž๋™์œผ๋กœ ์ œ๊ณตํ•˜๋ฉฐ,
๋ชจ๋ฐ”์ผ๋กœ ์ ‘์†ํ•˜๋Š” ๊ฒฝ์šฐ์— ๋ชจ๋ฐ”์ผ ํŽ˜์ด์ง€(/m)๋กœ redirect ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

Open API๋Š” 2024๋…„ 2์›”๊นŒ์ง€ ์ˆœ์ฐจ์ ์œผ๋กœ ์„œ๋น„์Šค๊ฐ€ ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.
์„œ๋น„์Šค ์ข…๋ฃŒ ์•ˆ๋‚ด ๋งํฌ

๊ณต์ง€์‚ฌํ•ญ

  • Header์— ๊ณต์ง€์‚ฌํ•ญ(Notice) ๋ฉ”๋‰ด ์ ์šฉ

์นดํ…Œ๊ณ ๋ฆฌ

  • ์นดํ…Œ๊ณ ๋ฆฌ Level(1, 2)๋ณ„ ์ด๋™ ์ฒ˜๋ฆฌ
  • ์นดํ…Œ๊ณ ๋ฆฌ ํด๋ฆญ ์‹œ, ํ•˜์œ„ ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ํ•˜์œ„ ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ๋ณด์—ฌ์คŒ
  • ํ•ด๋‹น ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ๋น„์–ด(์ž‘์„ฑ๊ธ€ 0๊ฐœ) ์žˆ๋Š” ๊ฒฝ์šฐ ๋…ธ์ถœํ•˜์ง€ ์•Š์Œ

๊ธฐ๋Šฅ๊ตฌํ˜„ ๋ชฉ๋ก

  • ๊ธ€ ๋ชฉ๋ก ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ
  • ๊ฒ€์ƒ‰ ๋ฐ ๊ฒ€์ƒ‰ ํŽ˜์ด์ง€ ์ด๋™
  • ๋Œ“๊ธ€ ๋“ฑ๋ก
  • ๋Œ“๊ธ€ ์ˆ˜์ •/์‚ญ์ œ
  • ๋ฐฉ๋ช…๋ก ๋“ฑ๋ก
  • ๋ฐฉ๋ช…๋ก ์ˆ˜์ •/์‚ญ์ œ
  • ์ข‹์•„์š” ์„ค์ •/ํ•ด์ œ
  • ๊ด‘๊ณ 

๊ด‘๊ณ 

  • Google Adsense: ๋ธ”๋กœ๊ทธ ์ „๋ฐ˜์— ์ ์šฉ
  • Kakao Adfit: Side ์˜์—ญ ๋ฐ ํฌ์ŠคํŒ…์— ํ•œ ๊ฐœ์”ฉ ์ ์šฉ
  • Tenping: ํฌ์ŠคํŒ…์— ํ•œ ๊ฐœ์”ฉ ์ ์šฉ

๊ฐ ๊ฒŒ์‹œ๊ธ€์— ์ ์šฉ๋˜๋Š” ๋ถ€๋ถ„์€ ์ž‘์„ฑ ์‹œ์— ์—๋””ํ„ฐ์—์„œ ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.

โš™๏ธ Configuration

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup

Type Support For .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

๐Ÿ—๏ธ Build & Deploy

npm run build

์ •์ƒ์ ์œผ๋กœ ๋นŒ๋“œ๋˜๋ฉด, dist ํด๋”์— ๊ด€๋ จ ํŒŒ์ผ๋“ค์ด ์ƒ์„ฑ๋˜๋Š”๋ฐ, index.html ํŒŒ์ผ๊ณผ /images ํด๋” ๋‚ด์— ์žˆ๋Š” ํŒŒ์ผ์„ ๋ชจ๋‘ ์Šคํ‚จ์— ์—…๋กœ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

postbuild

  • ๋นŒ๋“œ ์ž‘์—… ์ดํ›„์— ์•„๋ž˜ ๋‘ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ž๋™์œผ๋กœ(package.json์˜ scripts์— postbuild๋กœ ์ •์˜) ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค.
  • replace-paths.cjs : ๊ฐœ๋ฐœ ์‹œ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉํ–ˆ๋˜ ๊ฒฝ๋กœ๋ฅผ ์‹ค์ œ ๋ธ”๋กœ๊ทธ ๊ฒฝ๋กœ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ์ž‘์—…
  • tistory-skin.cjs : ๋นŒ๋“œ๋œ ํŒŒ์ผ์„ ๋ธ”๋กœ๊ทธ์˜ ์Šคํ‚จ์— ์—…๋กœ๋“œ

replace-paths.cjs

https://tistory4.daumcdn.net/tistory/2876097/skin/
/tistory/ ๊ฒฝ๋กœ ๋‹ค์Œ์— ๋‚˜์˜ค๋Š” ์ˆซ์ž ๊ฐ’์ด Tistory ๋ธ”๋กœ๊ทธ๋งˆ๋‹ค ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ณ ์œ  ID ๊ฐ’์ธ ๊ฒƒ ๊ฐ™์€๋ฐ์š”. ์ด ๊ฐ’์€ ์‹ค์ œ ๋ฐฐํฌํ•œ ๋‹ค์Œ์— console ์ฐฝ์— error ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ๊ฐ’์„ ํ™•์ธํ•ด์•ผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹ค์ œ ์„ค์ •๋˜๋Š” ๊ฐ’(์˜ˆ: js ํŒŒ์ผ)์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
https://tistory4.daumcdn.net/tistory/2876097/skin/images/index-[name].js

tistory-skin.cjs

๋นŒ๋“œ๋œ ํŒŒ์ผ์„ ๋ธ”๋กœ๊ทธ์— ์—…๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค.
(๋‹จ, ๋กœ๊ทธ์ธ ํ•  ๋•Œ๋งˆ๋‹ค TSSESSION ๊ฐ’์ด ๋ฐ”๋€Œ๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ถ€๋ถ„์€ ์ž‘์—…ํ•˜๊ธฐ ์ด์ „์— ํ™•์ธ์š”๋ง) ๊ฐ„ํ˜น '์ผ์‹œ์ ์ธ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒ'์ด๋ผ๋ฉด์„œ ์—…๋กœ๋“œ๊ฐ€ ์•ˆ ๋˜๋Š”๋ฐ, ๋‹ค์‹œ ๋นŒ๋“œ ๋ช…๋ น์–ด๋ฅผ ๋‚ด๋ฆฌ๋ฉด ์ •์ƒ์ ์œผ๋กœ ์—…๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค.