[{"data":1,"prerenderedAt":3201},["ShallowReactive",2],{"series-\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fan-internal-refactor-for-the-future-growth-of-our-blog":3,"series-context-\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch":2890},{"id":4,"title":5,"body":6,"contentId":2875,"date":2876,"description":2877,"extension":2878,"github":2879,"meetTheInstructor":2881,"meta":2882,"navigation":180,"part":220,"path":2883,"rawbody":2884,"robots":2881,"schemaOrg":2881,"seo":2885,"seriesSlug":2886,"sitemap":2887,"stem":2888,"subtitle":2881,"topics":2881,"__hash__":2889},"series\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fan-internal-refactor-for-the-future-growth-of-our-blog.md","An Internal Refactor for the Future Growth of Our Blog",{"type":7,"value":8,"toc":2870},"minimark",[9,13,24,27,46,49,54,57,73,87,96,258,366,377,630,636,639,735,738,744,1146,1166,1169,1192,1198,1204,1266,1276,1280,1287,1296,1314,1317,1320,1323,1330,1333,1347,1354,1365,1369,1372,1379,1386,1652,1659,1900,1907,2199,2206,2220,2821,2835,2850,2861,2866],[10,11,12],"p",{},"Our blog was established, with the primary focus on content and functioning well.",[10,14,15,16,23],{},"But we aimed to do more. We considered adding ",[17,18,22],"a",{"href":19,"rel":20},"https:\u002F\u002Fsoubiran.dev\u002Fseries\u002Fempower-and-dynamize-our-vitepress-blog-with-a-laravel-api",[21],"nofollow","a comment system",". Once you have an API, numerous possibilities arise. Additionally, we've learned a lot since starting this blog, and we want to apply this knowledge to make it more maintainable and scalable, especially for future growth, although this internal refactor may not seem to improve it immediately.",[10,25,26],{},"This refactor focuses on two main points:",[28,29,30,43],"ol",{},[31,32,33,34,42],"li",{},"Add ",[17,35,38],{"href":36,"rel":37},"https:\u002F\u002Fwww.tailwind-variants.org\u002F",[21],[39,40,41],"strong",{},"Tailwind Variants"," to facilitate the reuse of components",[31,44,45],{},"Transition from a type-based folder structure to a feature-based folder structure",[10,47,48],{},"Let me explain why we want to do this.",[50,51,53],"h2",{"id":52},"why-use-tailwind-variants","Why use Tailwind Variants?",[10,55,56],{},"First, let's understand the problem we're facing. Currently, our codebase has two buttons:",[58,59,60,67],"ul",{},[31,61,62,66],{},[63,64,65],"code",{},"ButtonPrimary.vue",": a primary button",[31,68,69,72],{},[63,70,71],{},"ButtonSecondary.vue",": a secondary button",[10,74,75,76,79,80,83,84,86],{},"The issue is that our site is simple and has only these two buttons. But what if we want to add a tertiary button, a button with a border instead of a background color, or a button with a different size? Or worse, what if we want our ",[63,77,78],{},"Button"," to be a real ",[63,81,82],{},"button"," instead of just an ",[63,85,17],{}," tag? Updating each component individually would be a nightmare to maintain, and small changes would require so much time, leading to loss of productivity, often the reason projects don't succeed.",[10,88,89,90,92,93,95],{},"To resolve this, we can consolidate all buttons into a single component. This is easier than it seems. Consider the ",[63,91,65],{}," and ",[63,94,71],{}," components:",[97,98,103],"pre",{"className":99,"code":100,"filename":65,"language":101,"meta":102,"style":102},"language-vue shiki shiki-themes github-light github-light github-dark","\u003Cscript lang=\"ts\" setup>\ndefineProps\u003C{\n  href: string\n}>()\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"border-4 border-black bg-[var(--color-yellow)] px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#ffdf1b] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n","vue","",[63,104,105,135,144,159,165,175,182,192,201,207,218,224,239,249],{"__ignoreMap":102},[106,107,110,114,118,122,125,129,132],"span",{"class":108,"line":109},"line",1,[106,111,113],{"class":112},"sxrX7","\u003C",[106,115,117],{"class":116},"sovSZ","script",[106,119,121],{"class":120},"snPdu"," lang",[106,123,124],{"class":112},"=",[106,126,128],{"class":127},"sIIMD","\"ts\"",[106,130,131],{"class":120}," setup",[106,133,134],{"class":112},">\n",[106,136,138,141],{"class":108,"line":137},2,[106,139,140],{"class":120},"defineProps",[106,142,143],{"class":112},"\u003C{\n",[106,145,147,151,155],{"class":108,"line":146},3,[106,148,150],{"class":149},"sP4rz","  href",[106,152,154],{"class":153},"s8jYJ",":",[106,156,158],{"class":157},"sBjJW"," string\n",[106,160,162],{"class":108,"line":161},4,[106,163,164],{"class":112},"}>()\n",[106,166,168,171,173],{"class":108,"line":167},5,[106,169,170],{"class":112},"\u003C\u002F",[106,172,117],{"class":116},[106,174,134],{"class":112},[106,176,178],{"class":108,"line":177},6,[106,179,181],{"emptyLinePlaceholder":180},true,"\n",[106,183,185,187,190],{"class":108,"line":184},7,[106,186,113],{"class":112},[106,188,189],{"class":116},"template",[106,191,134],{"class":112},[106,193,195,198],{"class":108,"line":194},8,[106,196,197],{"class":112},"  \u003C",[106,199,200],{"class":116},"a\n",[106,202,204],{"class":108,"line":203},9,[106,205,206],{"class":120},"    :href\n",[106,208,210,213,215],{"class":108,"line":209},10,[106,211,212],{"class":120},"    class",[106,214,124],{"class":112},[106,216,217],{"class":127},"\"border-4 border-black bg-[var(--color-yellow)] px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#ffdf1b] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n",[106,219,221],{"class":108,"line":220},11,[106,222,223],{"class":112},"  >\n",[106,225,227,230,233,237],{"class":108,"line":226},12,[106,228,229],{"class":112},"    \u003C",[106,231,232],{"class":116},"slot",[106,234,236],{"class":235},"sPrNH"," \u002F",[106,238,134],{"class":112},[106,240,242,245,247],{"class":108,"line":241},13,[106,243,244],{"class":112},"  \u003C\u002F",[106,246,17],{"class":116},[106,248,134],{"class":112},[106,250,252,254,256],{"class":108,"line":251},14,[106,253,170],{"class":112},[106,255,189],{"class":116},[106,257,134],{"class":112},[97,259,261],{"className":99,"code":260,"filename":71,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\" setup>\ndefineProps\u003C{\n  href: string\n}>()\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"inline-block border-4 border-black bg-[var(--color-purple)] px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#828cd2] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n",[63,262,263,279,285,293,297,305,309,317,323,327,336,340,350,358],{"__ignoreMap":102},[106,264,265,267,269,271,273,275,277],{"class":108,"line":109},[106,266,113],{"class":112},[106,268,117],{"class":116},[106,270,121],{"class":120},[106,272,124],{"class":112},[106,274,128],{"class":127},[106,276,131],{"class":120},[106,278,134],{"class":112},[106,280,281,283],{"class":108,"line":137},[106,282,140],{"class":120},[106,284,143],{"class":112},[106,286,287,289,291],{"class":108,"line":146},[106,288,150],{"class":149},[106,290,154],{"class":153},[106,292,158],{"class":157},[106,294,295],{"class":108,"line":161},[106,296,164],{"class":112},[106,298,299,301,303],{"class":108,"line":167},[106,300,170],{"class":112},[106,302,117],{"class":116},[106,304,134],{"class":112},[106,306,307],{"class":108,"line":177},[106,308,181],{"emptyLinePlaceholder":180},[106,310,311,313,315],{"class":108,"line":184},[106,312,113],{"class":112},[106,314,189],{"class":116},[106,316,134],{"class":112},[106,318,319,321],{"class":108,"line":194},[106,320,197],{"class":112},[106,322,200],{"class":116},[106,324,325],{"class":108,"line":203},[106,326,206],{"class":120},[106,328,329,331,333],{"class":108,"line":209},[106,330,212],{"class":120},[106,332,124],{"class":112},[106,334,335],{"class":127},"\"inline-block border-4 border-black bg-[var(--color-purple)] px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#828cd2] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n",[106,337,338],{"class":108,"line":220},[106,339,223],{"class":112},[106,341,342,344,346,348],{"class":108,"line":226},[106,343,229],{"class":112},[106,345,232],{"class":116},[106,347,236],{"class":235},[106,349,134],{"class":112},[106,351,352,354,356],{"class":108,"line":241},[106,353,244],{"class":112},[106,355,17],{"class":116},[106,357,134],{"class":112},[106,359,360,362,364],{"class":108,"line":251},[106,361,170],{"class":112},[106,363,189],{"class":116},[106,365,134],{"class":112},[10,367,368,369,372,373,376],{},"They are almost identical! The only difference is the color: ",[63,370,371],{},"bg-[var(--color-yellow)] hover:bg-[#ffdf1b]"," for the first, and ",[63,374,375],{},"bg-[var(--color-purple)] hover:bg-[#828cd2]"," for the second. This can be merged into a single component:",[97,378,381],{"className":99,"code":379,"filename":380,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003C{\n  href: string\n  color: string\n}>()\n\nconst color = computed(() => {\n  switch (props.color) {\n    case 'primary':\n      return 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]'\n    case 'secondary':\n      return 'bg-[var(--color-purple)] hover:bg-[#828cd2]'\n    default:\n      throw new Error('Unknown color')\n  }\n})\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\" :class=\"[color]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n","Button.vue",[63,382,383,399,415,423,432,436,440,461,469,480,488,497,504,511,531,537,543,552,557,566,573,578,596,601,612,621],{"__ignoreMap":102},[106,384,385,387,389,391,393,395,397],{"class":108,"line":109},[106,386,113],{"class":112},[106,388,117],{"class":116},[106,390,121],{"class":120},[106,392,124],{"class":112},[106,394,128],{"class":127},[106,396,131],{"class":120},[106,398,134],{"class":112},[106,400,401,404,407,410,413],{"class":108,"line":137},[106,402,403],{"class":153},"const",[106,405,406],{"class":157}," props",[106,408,409],{"class":153}," =",[106,411,412],{"class":120}," defineProps",[106,414,143],{"class":112},[106,416,417,419,421],{"class":108,"line":146},[106,418,150],{"class":149},[106,420,154],{"class":153},[106,422,158],{"class":157},[106,424,425,428,430],{"class":108,"line":161},[106,426,427],{"class":149},"  color",[106,429,154],{"class":153},[106,431,158],{"class":157},[106,433,434],{"class":108,"line":167},[106,435,164],{"class":112},[106,437,438],{"class":108,"line":177},[106,439,181],{"emptyLinePlaceholder":180},[106,441,442,444,447,449,452,455,458],{"class":108,"line":184},[106,443,403],{"class":153},[106,445,446],{"class":157}," color",[106,448,409],{"class":153},[106,450,451],{"class":120}," computed",[106,453,454],{"class":112},"(() ",[106,456,457],{"class":153},"=>",[106,459,460],{"class":112}," {\n",[106,462,463,466],{"class":108,"line":194},[106,464,465],{"class":153},"  switch",[106,467,468],{"class":112}," (props.color) {\n",[106,470,471,474,477],{"class":108,"line":203},[106,472,473],{"class":153},"    case",[106,475,476],{"class":127}," 'primary'",[106,478,479],{"class":112},":\n",[106,481,482,485],{"class":108,"line":209},[106,483,484],{"class":153},"      return",[106,486,487],{"class":127}," 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]'\n",[106,489,490,492,495],{"class":108,"line":220},[106,491,473],{"class":153},[106,493,494],{"class":127}," 'secondary'",[106,496,479],{"class":112},[106,498,499,501],{"class":108,"line":226},[106,500,484],{"class":153},[106,502,503],{"class":127}," 'bg-[var(--color-purple)] hover:bg-[#828cd2]'\n",[106,505,506,509],{"class":108,"line":241},[106,507,508],{"class":153},"    default",[106,510,479],{"class":112},[106,512,513,516,519,522,525,528],{"class":108,"line":251},[106,514,515],{"class":153},"      throw",[106,517,518],{"class":153}," new",[106,520,521],{"class":120}," Error",[106,523,524],{"class":112},"(",[106,526,527],{"class":127},"'Unknown color'",[106,529,530],{"class":112},")\n",[106,532,534],{"class":108,"line":533},15,[106,535,536],{"class":112},"  }\n",[106,538,540],{"class":108,"line":539},16,[106,541,542],{"class":112},"})\n",[106,544,546,548,550],{"class":108,"line":545},17,[106,547,170],{"class":112},[106,549,117],{"class":116},[106,551,134],{"class":112},[106,553,555],{"class":108,"line":554},18,[106,556,181],{"emptyLinePlaceholder":180},[106,558,560,562,564],{"class":108,"line":559},19,[106,561,113],{"class":112},[106,563,189],{"class":116},[106,565,134],{"class":112},[106,567,569,571],{"class":108,"line":568},20,[106,570,197],{"class":112},[106,572,200],{"class":116},[106,574,576],{"class":108,"line":575},21,[106,577,206],{"class":120},[106,579,581,583,585,588,591,593],{"class":108,"line":580},22,[106,582,212],{"class":120},[106,584,124],{"class":112},[106,586,587],{"class":127},"\"inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"",[106,589,590],{"class":120}," :class",[106,592,124],{"class":112},[106,594,595],{"class":127},"\"[color]\"\n",[106,597,599],{"class":108,"line":598},23,[106,600,223],{"class":112},[106,602,604,606,608,610],{"class":108,"line":603},24,[106,605,229],{"class":112},[106,607,232],{"class":116},[106,609,236],{"class":235},[106,611,134],{"class":112},[106,613,615,617,619],{"class":108,"line":614},25,[106,616,244],{"class":112},[106,618,17],{"class":116},[106,620,134],{"class":112},[106,622,624,626,628],{"class":108,"line":623},26,[106,625,170],{"class":112},[106,627,189],{"class":116},[106,629,134],{"class":112},[10,631,632,633,635],{},"This is a good start but still not scalable. Our button could vary in size, color, variant, state, and more. Managing these in multiple computed properties is not ideal. This is where ",[39,634,41],{}," helps.",[10,637,638],{},"A powerful approach is to decouple the theme, not the style, from the component and framework. With Tailwind Variants, we can define an independent theme for a component adaptable to different contexts in a declarative way:",[97,640,645],{"className":641,"code":642,"filename":643,"language":644,"meta":102,"style":102},"language-ts shiki shiki-themes github-light github-light github-dark","import { tv } from 'tailwind-variants'\n\nconst button = tv({\n  base: 'inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]',\n  variants: {\n    color: {\n      primary: 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]',\n      secondary: 'bg-[var(--color-purple)] hover:bg-[#828cd2]',\n    },\n  },\n})\n","Example","ts",[63,646,647,661,665,680,691,696,701,711,721,726,731],{"__ignoreMap":102},[106,648,649,652,655,658],{"class":108,"line":109},[106,650,651],{"class":153},"import",[106,653,654],{"class":112}," { tv } ",[106,656,657],{"class":153},"from",[106,659,660],{"class":127}," 'tailwind-variants'\n",[106,662,663],{"class":108,"line":137},[106,664,181],{"emptyLinePlaceholder":180},[106,666,667,669,672,674,677],{"class":108,"line":146},[106,668,403],{"class":153},[106,670,671],{"class":157}," button",[106,673,409],{"class":153},[106,675,676],{"class":120}," tv",[106,678,679],{"class":112},"({\n",[106,681,682,685,688],{"class":108,"line":161},[106,683,684],{"class":112},"  base: ",[106,686,687],{"class":127},"'inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]'",[106,689,690],{"class":112},",\n",[106,692,693],{"class":108,"line":167},[106,694,695],{"class":112},"  variants: {\n",[106,697,698],{"class":108,"line":177},[106,699,700],{"class":112},"    color: {\n",[106,702,703,706,709],{"class":108,"line":184},[106,704,705],{"class":112},"      primary: ",[106,707,708],{"class":127},"'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]'",[106,710,690],{"class":112},[106,712,713,716,719],{"class":108,"line":194},[106,714,715],{"class":112},"      secondary: ",[106,717,718],{"class":127},"'bg-[var(--color-purple)] hover:bg-[#828cd2]'",[106,720,690],{"class":112},[106,722,723],{"class":108,"line":203},[106,724,725],{"class":112},"    },\n",[106,727,728],{"class":108,"line":209},[106,729,730],{"class":112},"  },\n",[106,732,733],{"class":108,"line":220},[106,734,542],{"class":112},[10,736,737],{},"Do you see the power of this approach? The base style, shared among variants, is defined centrally. Then we define variants, such as color. Additional properties like size can also be added or compound variants defined for specific styles, like when a button is primary and small.",[10,739,740,741,743],{},"Rewriting our ",[63,742,380],{}," component:",[97,745,747],{"className":99,"code":746,"filename":380,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\">\nimport type { VariantProps } from 'tailwind-variants'\n\nconst button = tv({\n  base: 'border-4 border-black px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem] hover:shadow-[6px_6px_0_black]',\n  variants: {\n    color: {\n      primary: 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]',\n      secondary: 'text-white bg-[var(--color-purple)] hover:bg-[#828cd2]',\n    },\n  },\n  defaultVariants: {\n    color: 'primary',\n  },\n})\n\ntype ButtonVariants = VariantProps\u003Ctypeof button>\n\nexport interface ButtonProps {\n  href: string\n  label: string\n  color?: ButtonVariants['color']\n  class?: any\n}\nexport interface ButtonEmits {}\nexport interface ButtonSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CButtonProps>()\ndefineEmits\u003CButtonEmits>()\ndefineSlots\u003CButtonSlots>()\n\nconst ui = computed(() => button({ class: props.class, color: props.color }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca :href=\"props.href\" :class=\"ui\">\n    {{ props.label }}\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n",[63,748,749,763,777,781,793,802,806,810,818,827,831,835,840,850,854,858,862,883,887,900,908,917,935,945,950,962,973,982,987,1004,1023,1036,1049,1054,1075,1084,1089,1098,1122,1128,1137],{"__ignoreMap":102},[106,750,751,753,755,757,759,761],{"class":108,"line":109},[106,752,113],{"class":112},[106,754,117],{"class":116},[106,756,121],{"class":120},[106,758,124],{"class":112},[106,760,128],{"class":127},[106,762,134],{"class":112},[106,764,765,767,770,773,775],{"class":108,"line":137},[106,766,651],{"class":153},[106,768,769],{"class":153}," type",[106,771,772],{"class":112}," { VariantProps } ",[106,774,657],{"class":153},[106,776,660],{"class":127},[106,778,779],{"class":108,"line":146},[106,780,181],{"emptyLinePlaceholder":180},[106,782,783,785,787,789,791],{"class":108,"line":161},[106,784,403],{"class":153},[106,786,671],{"class":157},[106,788,409],{"class":153},[106,790,676],{"class":120},[106,792,679],{"class":112},[106,794,795,797,800],{"class":108,"line":167},[106,796,684],{"class":112},[106,798,799],{"class":127},"'border-4 border-black px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem] hover:shadow-[6px_6px_0_black]'",[106,801,690],{"class":112},[106,803,804],{"class":108,"line":177},[106,805,695],{"class":112},[106,807,808],{"class":108,"line":184},[106,809,700],{"class":112},[106,811,812,814,816],{"class":108,"line":194},[106,813,705],{"class":112},[106,815,708],{"class":127},[106,817,690],{"class":112},[106,819,820,822,825],{"class":108,"line":203},[106,821,715],{"class":112},[106,823,824],{"class":127},"'text-white bg-[var(--color-purple)] hover:bg-[#828cd2]'",[106,826,690],{"class":112},[106,828,829],{"class":108,"line":209},[106,830,725],{"class":112},[106,832,833],{"class":108,"line":220},[106,834,730],{"class":112},[106,836,837],{"class":108,"line":226},[106,838,839],{"class":112},"  defaultVariants: {\n",[106,841,842,845,848],{"class":108,"line":241},[106,843,844],{"class":112},"    color: ",[106,846,847],{"class":127},"'primary'",[106,849,690],{"class":112},[106,851,852],{"class":108,"line":251},[106,853,730],{"class":112},[106,855,856],{"class":108,"line":533},[106,857,542],{"class":112},[106,859,860],{"class":108,"line":539},[106,861,181],{"emptyLinePlaceholder":180},[106,863,864,867,870,872,875,877,880],{"class":108,"line":545},[106,865,866],{"class":153},"type",[106,868,869],{"class":120}," ButtonVariants",[106,871,409],{"class":153},[106,873,874],{"class":120}," VariantProps",[106,876,113],{"class":112},[106,878,879],{"class":153},"typeof",[106,881,882],{"class":112}," button>\n",[106,884,885],{"class":108,"line":554},[106,886,181],{"emptyLinePlaceholder":180},[106,888,889,892,895,898],{"class":108,"line":559},[106,890,891],{"class":153},"export",[106,893,894],{"class":153}," interface",[106,896,897],{"class":120}," ButtonProps",[106,899,460],{"class":112},[106,901,902,904,906],{"class":108,"line":568},[106,903,150],{"class":149},[106,905,154],{"class":153},[106,907,158],{"class":157},[106,909,910,913,915],{"class":108,"line":575},[106,911,912],{"class":149},"  label",[106,914,154],{"class":153},[106,916,158],{"class":157},[106,918,919,921,924,926,929,932],{"class":108,"line":580},[106,920,427],{"class":149},[106,922,923],{"class":153},"?:",[106,925,869],{"class":120},[106,927,928],{"class":112},"[",[106,930,931],{"class":127},"'color'",[106,933,934],{"class":112},"]\n",[106,936,937,940,942],{"class":108,"line":598},[106,938,939],{"class":149},"  class",[106,941,923],{"class":153},[106,943,944],{"class":157}," any\n",[106,946,947],{"class":108,"line":603},[106,948,949],{"class":112},"}\n",[106,951,952,954,956,959],{"class":108,"line":614},[106,953,891],{"class":153},[106,955,894],{"class":153},[106,957,958],{"class":120}," ButtonEmits",[106,960,961],{"class":112}," {}\n",[106,963,964,966,968,971],{"class":108,"line":623},[106,965,891],{"class":153},[106,967,894],{"class":153},[106,969,970],{"class":120}," ButtonSlots",[106,972,961],{"class":112},[106,974,976,978,980],{"class":108,"line":975},27,[106,977,170],{"class":112},[106,979,117],{"class":116},[106,981,134],{"class":112},[106,983,985],{"class":108,"line":984},28,[106,986,181],{"emptyLinePlaceholder":180},[106,988,990,992,994,996,998,1000,1002],{"class":108,"line":989},29,[106,991,113],{"class":112},[106,993,117],{"class":116},[106,995,121],{"class":120},[106,997,124],{"class":112},[106,999,128],{"class":127},[106,1001,131],{"class":120},[106,1003,134],{"class":112},[106,1005,1007,1009,1011,1013,1015,1017,1020],{"class":108,"line":1006},30,[106,1008,403],{"class":153},[106,1010,406],{"class":157},[106,1012,409],{"class":153},[106,1014,412],{"class":120},[106,1016,113],{"class":112},[106,1018,1019],{"class":120},"ButtonProps",[106,1021,1022],{"class":112},">()\n",[106,1024,1026,1029,1031,1034],{"class":108,"line":1025},31,[106,1027,1028],{"class":120},"defineEmits",[106,1030,113],{"class":112},[106,1032,1033],{"class":120},"ButtonEmits",[106,1035,1022],{"class":112},[106,1037,1039,1042,1044,1047],{"class":108,"line":1038},32,[106,1040,1041],{"class":120},"defineSlots",[106,1043,113],{"class":112},[106,1045,1046],{"class":120},"ButtonSlots",[106,1048,1022],{"class":112},[106,1050,1052],{"class":108,"line":1051},33,[106,1053,181],{"emptyLinePlaceholder":180},[106,1055,1057,1059,1062,1064,1066,1068,1070,1072],{"class":108,"line":1056},34,[106,1058,403],{"class":153},[106,1060,1061],{"class":157}," ui",[106,1063,409],{"class":153},[106,1065,451],{"class":120},[106,1067,454],{"class":112},[106,1069,457],{"class":153},[106,1071,671],{"class":120},[106,1073,1074],{"class":112},"({ class: props.class, color: props.color }))\n",[106,1076,1078,1080,1082],{"class":108,"line":1077},35,[106,1079,170],{"class":112},[106,1081,117],{"class":116},[106,1083,134],{"class":112},[106,1085,1087],{"class":108,"line":1086},36,[106,1088,181],{"emptyLinePlaceholder":180},[106,1090,1092,1094,1096],{"class":108,"line":1091},37,[106,1093,113],{"class":112},[106,1095,189],{"class":116},[106,1097,134],{"class":112},[106,1099,1101,1103,1105,1108,1110,1113,1115,1117,1120],{"class":108,"line":1100},38,[106,1102,197],{"class":112},[106,1104,17],{"class":116},[106,1106,1107],{"class":120}," :href",[106,1109,124],{"class":112},[106,1111,1112],{"class":127},"\"props.href\"",[106,1114,590],{"class":120},[106,1116,124],{"class":112},[106,1118,1119],{"class":127},"\"ui\"",[106,1121,134],{"class":112},[106,1123,1125],{"class":108,"line":1124},39,[106,1126,1127],{"class":112},"    {{ props.label }}\n",[106,1129,1131,1133,1135],{"class":108,"line":1130},40,[106,1132,244],{"class":112},[106,1134,17],{"class":116},[106,1136,134],{"class":112},[106,1138,1140,1142,1144],{"class":108,"line":1139},41,[106,1141,170],{"class":112},[106,1143,189],{"class":116},[106,1145,134],{"class":112},[10,1147,1148,1149,1152,1153,1156,1157,1159,1160,1162,1163,1165],{},"One interesting aspect is extracting variants with ",[39,1150,1151],{},"TypeScript"," and applying them to the props. The ",[63,1154,1155],{},"ButtonVariants"," type includes all ",[63,1158,78],{}," variants based on the ",[63,1161,82],{}," theme. So any theme change reflects in the ",[63,1164,78],{}," component automatically.",[10,1167,1168],{},"You're probably asking: How do Tailwind Variants know which variant to use? Look at this code:",[97,1170,1172],{"className":641,"code":1171,"filename":643,"language":644,"meta":102,"style":102},"const ui = computed(() => button({ class: props.class, color: props.color }))\n",[63,1173,1174],{"__ignoreMap":102},[106,1175,1176,1178,1180,1182,1184,1186,1188,1190],{"class":108,"line":109},[106,1177,403],{"class":153},[106,1179,1061],{"class":157},[106,1181,409],{"class":153},[106,1183,451],{"class":120},[106,1185,454],{"class":112},[106,1187,457],{"class":153},[106,1189,671],{"class":120},[106,1191,1074],{"class":112},[10,1193,1194,1195,1197],{},"The ",[63,1196,82],{}," variable is a function that takes an object with variants as arguments. This way, variants are calculated at runtime based on props and the predefined theme.",[10,1199,1200,1201,1203],{},"We can use our ",[63,1202,78],{}," component like this:",[97,1205,1207],{"className":99,"code":1206,"filename":643,"language":101,"meta":102,"style":102},"\u003CButton href=\"https:\u002F\u002Fsoubiran.dev\" label=\"Primary Button\" \u002F>\n\n\u003CButton href=\"https:\u002F\u002Fsoubiran.dev\" label=\"Secondary Button\" color=\"secondary\" \u002F>\n",[63,1208,1209,1234,1238],{"__ignoreMap":102},[106,1210,1211,1213,1215,1218,1220,1223,1226,1228,1231],{"class":108,"line":109},[106,1212,113],{"class":112},[106,1214,78],{"class":116},[106,1216,1217],{"class":120}," href",[106,1219,124],{"class":112},[106,1221,1222],{"class":127},"\"https:\u002F\u002Fsoubiran.dev\"",[106,1224,1225],{"class":120}," label",[106,1227,124],{"class":112},[106,1229,1230],{"class":127},"\"Primary Button\"",[106,1232,1233],{"class":112}," \u002F>\n",[106,1235,1236],{"class":108,"line":137},[106,1237,181],{"emptyLinePlaceholder":180},[106,1239,1240,1242,1244,1246,1248,1250,1252,1254,1257,1259,1261,1264],{"class":108,"line":146},[106,1241,113],{"class":112},[106,1243,78],{"class":116},[106,1245,1217],{"class":120},[106,1247,124],{"class":112},[106,1249,1222],{"class":127},[106,1251,1225],{"class":120},[106,1253,124],{"class":112},[106,1255,1256],{"class":127},"\"Secondary Button\"",[106,1258,446],{"class":120},[106,1260,124],{"class":112},[106,1262,1263],{"class":127},"\"secondary\"",[106,1265,1233],{"class":112},[10,1267,1268,1269,1271,1272,1275],{},"Automatically, the ",[63,1270,78],{}," component applies the correct style based on the ",[63,1273,1274],{},"color"," prop.",[50,1277,1279],{"id":1278},"why-move-to-a-feature-based-folder-structure","Why move to a feature-based folder structure?",[10,1281,1282,1283,1286],{},"Currently, our codebase is in ",[63,1284,1285],{},".vitepress\u002Ftheme",", split into folders:",[97,1288,1294],{"className":1289,"code":1291,"filename":1292,"language":1293,"meta":102},[1290],"language-text","└── .vitepress\u002Ftheme\n    ├── components\n    ├── composables\n    ├── pages\n    ├── styles\n    └── types\n","By Type","text",[63,1295,1291],{"__ignoreMap":102},[10,1297,1298,1299,1302,1303,1302,1306,1309,1310,1313],{},"We may have additional folders like ",[63,1300,1301],{},"directives",", ",[63,1304,1305],{},"utils",[63,1307,1308],{},"queries",", or ",[63,1311,1312],{},"mutations",". This structure, based on file types, places all components in one folder regardless of their use, which isn't ideal.",[10,1315,1316],{},"It's hard to identify core blog features from the folder structure. With just one feature, it's manageable, but as the blog grows, locating specific components or pages becomes challenging. Hence, a feature-based folder structure is beneficial.",[10,1318,1319],{},"This approach groups multiple folder-by-type structures by feature. It's easy to find specific components, and when working on a feature, all related files are easily accessible. It's an efficient way to manage and scale a project.",[10,1321,1322],{},"In our case, the major features are the blog and projects. The structure could be like this:",[97,1324,1328],{"className":1325,"code":1326,"filename":1327,"language":1293,"meta":102},[1290],"└── .vitepress\u002Ftheme\n    ├── blog\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    └── projects\n        ├── components\n        ├── composables\n        ├── pages\n        └── types\n","By Feature",[63,1329,1326],{"__ignoreMap":102},[10,1331,1332],{},"This way, core blog features are clear, and related files are easily found. Adding new features involves creating a new folder and including related files.",[10,1334,1335,1336,1339,1340,1343,1344,1346],{},"A missing folder here is ",[63,1337,1338],{},"common"," or ",[63,1341,1342],{},"shared",". It contains files shared between features. For example, the ",[63,1345,78],{}," component shared by the blog and projects should be placed here.",[97,1348,1352],{"className":1349,"code":1350,"filename":1351,"language":1293,"meta":102},[1290],"└── .vitepress\u002Ftheme\n    ├── blog\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    ├── projects\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    └── common\n        ├── components\n        ├── composables\n        ├── styles\n        └── types\n","By Feature with Common",[63,1353,1350],{"__ignoreMap":102},[1355,1356,1359],"callout",{"color":1357,"icon":1358},"info","i-ph-info-duotone",[10,1360,1361,1362,1364],{},"I named it ",[63,1363,1338],{},", but you can choose any name that conveys the shared nature of the files not belonging to a specific feature.",[50,1366,1368],{"id":1367},"refactoring-the-codebase","Refactoring the codebase",[10,1370,1371],{},"Aside from the two main points, small codebase changes will enhance readability and reduce code repetition, crucial for maintaining blog style coherence.",[10,1373,1374,1375,1378],{},"First, we'll consolidate everything related to ",[63,1376,1377],{},"Page",". Every page component shares the same wrapper, title, and footer structure. We can easily extract each part into three components:",[28,1380,1381],{},[31,1382,1383],{},[63,1384,1385],{},"Page.vue",[97,1387,1389],{"className":99,"code":1388,"filename":1385,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\">\nconst page = tv({\n  base: 'space-y-16',\n})\nexport interface PageProps {\n  class?: any\n}\nexport interface PageEmits {}\nexport interface PageSlots {\n  default: (props?: object) => any\n}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageProps>()\ndefineEmits\u003CPageEmits>()\ndefineSlots\u003CPageSlots>()\nconst ui = computed(() => page({ class: props.class }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Csection :class=\"ui\">\n    \u003Cslot \u002F>\n  \u003C\u002Fsection>\n\u003C\u002Ftemplate>\n",[63,1390,1391,1405,1418,1427,1431,1442,1450,1454,1465,1476,1501,1505,1513,1517,1533,1550,1561,1572,1591,1599,1603,1611,1626,1636,1644],{"__ignoreMap":102},[106,1392,1393,1395,1397,1399,1401,1403],{"class":108,"line":109},[106,1394,113],{"class":112},[106,1396,117],{"class":116},[106,1398,121],{"class":120},[106,1400,124],{"class":112},[106,1402,128],{"class":127},[106,1404,134],{"class":112},[106,1406,1407,1409,1412,1414,1416],{"class":108,"line":137},[106,1408,403],{"class":153},[106,1410,1411],{"class":157}," page",[106,1413,409],{"class":153},[106,1415,676],{"class":120},[106,1417,679],{"class":112},[106,1419,1420,1422,1425],{"class":108,"line":146},[106,1421,684],{"class":112},[106,1423,1424],{"class":127},"'space-y-16'",[106,1426,690],{"class":112},[106,1428,1429],{"class":108,"line":161},[106,1430,542],{"class":112},[106,1432,1433,1435,1437,1440],{"class":108,"line":167},[106,1434,891],{"class":153},[106,1436,894],{"class":153},[106,1438,1439],{"class":120}," PageProps",[106,1441,460],{"class":112},[106,1443,1444,1446,1448],{"class":108,"line":177},[106,1445,939],{"class":149},[106,1447,923],{"class":153},[106,1449,944],{"class":157},[106,1451,1452],{"class":108,"line":184},[106,1453,949],{"class":112},[106,1455,1456,1458,1460,1463],{"class":108,"line":194},[106,1457,891],{"class":153},[106,1459,894],{"class":153},[106,1461,1462],{"class":120}," PageEmits",[106,1464,961],{"class":112},[106,1466,1467,1469,1471,1474],{"class":108,"line":203},[106,1468,891],{"class":153},[106,1470,894],{"class":153},[106,1472,1473],{"class":120}," PageSlots",[106,1475,460],{"class":112},[106,1477,1478,1481,1483,1486,1489,1491,1494,1497,1499],{"class":108,"line":209},[106,1479,1480],{"class":120},"  default",[106,1482,154],{"class":153},[106,1484,1485],{"class":112}," (",[106,1487,1488],{"class":149},"props",[106,1490,923],{"class":153},[106,1492,1493],{"class":157}," object",[106,1495,1496],{"class":112},") ",[106,1498,457],{"class":153},[106,1500,944],{"class":157},[106,1502,1503],{"class":108,"line":220},[106,1504,949],{"class":112},[106,1506,1507,1509,1511],{"class":108,"line":226},[106,1508,170],{"class":112},[106,1510,117],{"class":116},[106,1512,134],{"class":112},[106,1514,1515],{"class":108,"line":241},[106,1516,181],{"emptyLinePlaceholder":180},[106,1518,1519,1521,1523,1525,1527,1529,1531],{"class":108,"line":251},[106,1520,113],{"class":112},[106,1522,117],{"class":116},[106,1524,121],{"class":120},[106,1526,124],{"class":112},[106,1528,128],{"class":127},[106,1530,131],{"class":120},[106,1532,134],{"class":112},[106,1534,1535,1537,1539,1541,1543,1545,1548],{"class":108,"line":533},[106,1536,403],{"class":153},[106,1538,406],{"class":157},[106,1540,409],{"class":153},[106,1542,412],{"class":120},[106,1544,113],{"class":112},[106,1546,1547],{"class":120},"PageProps",[106,1549,1022],{"class":112},[106,1551,1552,1554,1556,1559],{"class":108,"line":539},[106,1553,1028],{"class":120},[106,1555,113],{"class":112},[106,1557,1558],{"class":120},"PageEmits",[106,1560,1022],{"class":112},[106,1562,1563,1565,1567,1570],{"class":108,"line":545},[106,1564,1041],{"class":120},[106,1566,113],{"class":112},[106,1568,1569],{"class":120},"PageSlots",[106,1571,1022],{"class":112},[106,1573,1574,1576,1578,1580,1582,1584,1586,1588],{"class":108,"line":554},[106,1575,403],{"class":153},[106,1577,1061],{"class":157},[106,1579,409],{"class":153},[106,1581,451],{"class":120},[106,1583,454],{"class":112},[106,1585,457],{"class":153},[106,1587,1411],{"class":120},[106,1589,1590],{"class":112},"({ class: props.class }))\n",[106,1592,1593,1595,1597],{"class":108,"line":559},[106,1594,170],{"class":112},[106,1596,117],{"class":116},[106,1598,134],{"class":112},[106,1600,1601],{"class":108,"line":568},[106,1602,181],{"emptyLinePlaceholder":180},[106,1604,1605,1607,1609],{"class":108,"line":575},[106,1606,113],{"class":112},[106,1608,189],{"class":116},[106,1610,134],{"class":112},[106,1612,1613,1615,1618,1620,1622,1624],{"class":108,"line":580},[106,1614,197],{"class":112},[106,1616,1617],{"class":116},"section",[106,1619,590],{"class":120},[106,1621,124],{"class":112},[106,1623,1119],{"class":127},[106,1625,134],{"class":112},[106,1627,1628,1630,1632,1634],{"class":108,"line":598},[106,1629,229],{"class":112},[106,1631,232],{"class":116},[106,1633,236],{"class":235},[106,1635,134],{"class":112},[106,1637,1638,1640,1642],{"class":108,"line":603},[106,1639,244],{"class":112},[106,1641,1617],{"class":116},[106,1643,134],{"class":112},[106,1645,1646,1648,1650],{"class":108,"line":614},[106,1647,170],{"class":112},[106,1649,189],{"class":116},[106,1651,134],{"class":112},[28,1653,1654],{"start":137},[31,1655,1656],{},[63,1657,1658],{},"PageTitle.vue",[97,1660,1662],{"className":99,"code":1661,"filename":1658,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\">\nconst pageTitle = tv({\n  base: 'text-6xl font-semibold',\n})\nexport interface PageTitleProps {\n  title: string\n  class?: any\n}\nexport interface PageTitleEmits {}\nexport interface PageTitleSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageTitleProps>()\ndefineEmits\u003CPageTitleEmits>()\ndefineSlots\u003CPageTitleSlots>()\nconst ui = computed(() => pageTitle())\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ch1 :class=\"ui\">\n    {{ props.title }}\n  \u003C\u002Fh1>\n\u003C\u002Ftemplate>\n",[63,1663,1664,1678,1691,1700,1704,1715,1724,1732,1736,1747,1758,1766,1770,1786,1803,1814,1825,1844,1852,1856,1864,1879,1884,1892],{"__ignoreMap":102},[106,1665,1666,1668,1670,1672,1674,1676],{"class":108,"line":109},[106,1667,113],{"class":112},[106,1669,117],{"class":116},[106,1671,121],{"class":120},[106,1673,124],{"class":112},[106,1675,128],{"class":127},[106,1677,134],{"class":112},[106,1679,1680,1682,1685,1687,1689],{"class":108,"line":137},[106,1681,403],{"class":153},[106,1683,1684],{"class":157}," pageTitle",[106,1686,409],{"class":153},[106,1688,676],{"class":120},[106,1690,679],{"class":112},[106,1692,1693,1695,1698],{"class":108,"line":146},[106,1694,684],{"class":112},[106,1696,1697],{"class":127},"'text-6xl font-semibold'",[106,1699,690],{"class":112},[106,1701,1702],{"class":108,"line":161},[106,1703,542],{"class":112},[106,1705,1706,1708,1710,1713],{"class":108,"line":167},[106,1707,891],{"class":153},[106,1709,894],{"class":153},[106,1711,1712],{"class":120}," PageTitleProps",[106,1714,460],{"class":112},[106,1716,1717,1720,1722],{"class":108,"line":177},[106,1718,1719],{"class":149},"  title",[106,1721,154],{"class":153},[106,1723,158],{"class":157},[106,1725,1726,1728,1730],{"class":108,"line":184},[106,1727,939],{"class":149},[106,1729,923],{"class":153},[106,1731,944],{"class":157},[106,1733,1734],{"class":108,"line":194},[106,1735,949],{"class":112},[106,1737,1738,1740,1742,1745],{"class":108,"line":203},[106,1739,891],{"class":153},[106,1741,894],{"class":153},[106,1743,1744],{"class":120}," PageTitleEmits",[106,1746,961],{"class":112},[106,1748,1749,1751,1753,1756],{"class":108,"line":209},[106,1750,891],{"class":153},[106,1752,894],{"class":153},[106,1754,1755],{"class":120}," PageTitleSlots",[106,1757,961],{"class":112},[106,1759,1760,1762,1764],{"class":108,"line":220},[106,1761,170],{"class":112},[106,1763,117],{"class":116},[106,1765,134],{"class":112},[106,1767,1768],{"class":108,"line":226},[106,1769,181],{"emptyLinePlaceholder":180},[106,1771,1772,1774,1776,1778,1780,1782,1784],{"class":108,"line":241},[106,1773,113],{"class":112},[106,1775,117],{"class":116},[106,1777,121],{"class":120},[106,1779,124],{"class":112},[106,1781,128],{"class":127},[106,1783,131],{"class":120},[106,1785,134],{"class":112},[106,1787,1788,1790,1792,1794,1796,1798,1801],{"class":108,"line":251},[106,1789,403],{"class":153},[106,1791,406],{"class":157},[106,1793,409],{"class":153},[106,1795,412],{"class":120},[106,1797,113],{"class":112},[106,1799,1800],{"class":120},"PageTitleProps",[106,1802,1022],{"class":112},[106,1804,1805,1807,1809,1812],{"class":108,"line":533},[106,1806,1028],{"class":120},[106,1808,113],{"class":112},[106,1810,1811],{"class":120},"PageTitleEmits",[106,1813,1022],{"class":112},[106,1815,1816,1818,1820,1823],{"class":108,"line":539},[106,1817,1041],{"class":120},[106,1819,113],{"class":112},[106,1821,1822],{"class":120},"PageTitleSlots",[106,1824,1022],{"class":112},[106,1826,1827,1829,1831,1833,1835,1837,1839,1841],{"class":108,"line":545},[106,1828,403],{"class":153},[106,1830,1061],{"class":157},[106,1832,409],{"class":153},[106,1834,451],{"class":120},[106,1836,454],{"class":112},[106,1838,457],{"class":153},[106,1840,1684],{"class":120},[106,1842,1843],{"class":112},"())\n",[106,1845,1846,1848,1850],{"class":108,"line":554},[106,1847,170],{"class":112},[106,1849,117],{"class":116},[106,1851,134],{"class":112},[106,1853,1854],{"class":108,"line":559},[106,1855,181],{"emptyLinePlaceholder":180},[106,1857,1858,1860,1862],{"class":108,"line":568},[106,1859,113],{"class":112},[106,1861,189],{"class":116},[106,1863,134],{"class":112},[106,1865,1866,1868,1871,1873,1875,1877],{"class":108,"line":575},[106,1867,197],{"class":112},[106,1869,1870],{"class":116},"h1",[106,1872,590],{"class":120},[106,1874,124],{"class":112},[106,1876,1119],{"class":127},[106,1878,134],{"class":112},[106,1880,1881],{"class":108,"line":580},[106,1882,1883],{"class":112},"    {{ props.title }}\n",[106,1885,1886,1888,1890],{"class":108,"line":598},[106,1887,244],{"class":112},[106,1889,1870],{"class":116},[106,1891,134],{"class":112},[106,1893,1894,1896,1898],{"class":108,"line":603},[106,1895,170],{"class":112},[106,1897,189],{"class":116},[106,1899,134],{"class":112},[28,1901,1902],{"start":146},[31,1903,1904],{},[63,1905,1906],{},"PageFooter.vue",[97,1908,1910],{"className":99,"code":1909,"filename":1906,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\">\nconst pageFooter = tv({\n  base: 'flex justify-center',\n})\nexport interface PageFooterProps {\n  backTo: { href: string, label: string }\n  class?: any\n}\nexport interface PageFooterEmits {}\nexport interface PageFooterSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageFooterProps>()\ndefineEmits\u003CPageFooterEmits>()\ndefineSlots\u003CPageFooterSlots>()\nconst ui = computed(() => pageFooter({ class: props.class }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Cdiv :class=\"ui\">\n    \u003CButton :href=\"props.backTo.href\" :label=\"props.backTo.label\" \u002F>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[63,1911,1912,1926,1939,1948,1952,1963,1993,2001,2005,2016,2027,2035,2039,2055,2072,2083,2094,2112,2120,2124,2132,2147,2183,2191],{"__ignoreMap":102},[106,1913,1914,1916,1918,1920,1922,1924],{"class":108,"line":109},[106,1915,113],{"class":112},[106,1917,117],{"class":116},[106,1919,121],{"class":120},[106,1921,124],{"class":112},[106,1923,128],{"class":127},[106,1925,134],{"class":112},[106,1927,1928,1930,1933,1935,1937],{"class":108,"line":137},[106,1929,403],{"class":153},[106,1931,1932],{"class":157}," pageFooter",[106,1934,409],{"class":153},[106,1936,676],{"class":120},[106,1938,679],{"class":112},[106,1940,1941,1943,1946],{"class":108,"line":146},[106,1942,684],{"class":112},[106,1944,1945],{"class":127},"'flex justify-center'",[106,1947,690],{"class":112},[106,1949,1950],{"class":108,"line":161},[106,1951,542],{"class":112},[106,1953,1954,1956,1958,1961],{"class":108,"line":167},[106,1955,891],{"class":153},[106,1957,894],{"class":153},[106,1959,1960],{"class":120}," PageFooterProps",[106,1962,460],{"class":112},[106,1964,1965,1968,1970,1973,1976,1978,1981,1983,1986,1988,1990],{"class":108,"line":177},[106,1966,1967],{"class":149},"  backTo",[106,1969,154],{"class":153},[106,1971,1972],{"class":112}," { ",[106,1974,1975],{"class":149},"href",[106,1977,154],{"class":153},[106,1979,1980],{"class":157}," string",[106,1982,1302],{"class":112},[106,1984,1985],{"class":149},"label",[106,1987,154],{"class":153},[106,1989,1980],{"class":157},[106,1991,1992],{"class":112}," }\n",[106,1994,1995,1997,1999],{"class":108,"line":184},[106,1996,939],{"class":149},[106,1998,923],{"class":153},[106,2000,944],{"class":157},[106,2002,2003],{"class":108,"line":194},[106,2004,949],{"class":112},[106,2006,2007,2009,2011,2014],{"class":108,"line":203},[106,2008,891],{"class":153},[106,2010,894],{"class":153},[106,2012,2013],{"class":120}," PageFooterEmits",[106,2015,961],{"class":112},[106,2017,2018,2020,2022,2025],{"class":108,"line":209},[106,2019,891],{"class":153},[106,2021,894],{"class":153},[106,2023,2024],{"class":120}," PageFooterSlots",[106,2026,961],{"class":112},[106,2028,2029,2031,2033],{"class":108,"line":220},[106,2030,170],{"class":112},[106,2032,117],{"class":116},[106,2034,134],{"class":112},[106,2036,2037],{"class":108,"line":226},[106,2038,181],{"emptyLinePlaceholder":180},[106,2040,2041,2043,2045,2047,2049,2051,2053],{"class":108,"line":241},[106,2042,113],{"class":112},[106,2044,117],{"class":116},[106,2046,121],{"class":120},[106,2048,124],{"class":112},[106,2050,128],{"class":127},[106,2052,131],{"class":120},[106,2054,134],{"class":112},[106,2056,2057,2059,2061,2063,2065,2067,2070],{"class":108,"line":251},[106,2058,403],{"class":153},[106,2060,406],{"class":157},[106,2062,409],{"class":153},[106,2064,412],{"class":120},[106,2066,113],{"class":112},[106,2068,2069],{"class":120},"PageFooterProps",[106,2071,1022],{"class":112},[106,2073,2074,2076,2078,2081],{"class":108,"line":533},[106,2075,1028],{"class":120},[106,2077,113],{"class":112},[106,2079,2080],{"class":120},"PageFooterEmits",[106,2082,1022],{"class":112},[106,2084,2085,2087,2089,2092],{"class":108,"line":539},[106,2086,1041],{"class":120},[106,2088,113],{"class":112},[106,2090,2091],{"class":120},"PageFooterSlots",[106,2093,1022],{"class":112},[106,2095,2096,2098,2100,2102,2104,2106,2108,2110],{"class":108,"line":545},[106,2097,403],{"class":153},[106,2099,1061],{"class":157},[106,2101,409],{"class":153},[106,2103,451],{"class":120},[106,2105,454],{"class":112},[106,2107,457],{"class":153},[106,2109,1932],{"class":120},[106,2111,1590],{"class":112},[106,2113,2114,2116,2118],{"class":108,"line":554},[106,2115,170],{"class":112},[106,2117,117],{"class":116},[106,2119,134],{"class":112},[106,2121,2122],{"class":108,"line":559},[106,2123,181],{"emptyLinePlaceholder":180},[106,2125,2126,2128,2130],{"class":108,"line":568},[106,2127,113],{"class":112},[106,2129,189],{"class":116},[106,2131,134],{"class":112},[106,2133,2134,2136,2139,2141,2143,2145],{"class":108,"line":575},[106,2135,197],{"class":112},[106,2137,2138],{"class":116},"div",[106,2140,590],{"class":120},[106,2142,124],{"class":112},[106,2144,1119],{"class":127},[106,2146,134],{"class":112},[106,2148,2149,2151,2153,2156,2158,2160,2163,2166,2168,2170,2172,2174,2176,2179,2181],{"class":108,"line":580},[106,2150,229],{"class":112},[106,2152,78],{"class":116},[106,2154,2155],{"class":112}," :",[106,2157,1975],{"class":120},[106,2159,124],{"class":112},[106,2161,2162],{"class":127},"\"",[106,2164,2165],{"class":112},"props.backTo.href",[106,2167,2162],{"class":127},[106,2169,2155],{"class":112},[106,2171,1985],{"class":120},[106,2173,124],{"class":112},[106,2175,2162],{"class":127},[106,2177,2178],{"class":112},"props.backTo.label",[106,2180,2162],{"class":127},[106,2182,1233],{"class":112},[106,2184,2185,2187,2189],{"class":108,"line":598},[106,2186,244],{"class":112},[106,2188,2138],{"class":116},[106,2190,134],{"class":112},[106,2192,2193,2195,2197],{"class":108,"line":603},[106,2194,170],{"class":112},[106,2196,189],{"class":116},[106,2198,134],{"class":112},[10,2200,2201,2202,2205],{},"These simple components help reduce code repetition and streamline new page creation. Additionally, we can consolidate every prose into a single ",[63,2203,2204],{},"Prose.vue"," component, ensuring consistent blog prose style.",[10,2207,2208,2209,92,2212,2215,2216,2219],{},"Next, we can unify ",[63,2210,2211],{},"ProjectCard.vue",[63,2213,2214],{},"BlogCard.vue"," into ",[63,2217,2218],{},"Card.vue",". Their only differences are title size, description, and padding. Tailwind Variants efficiently manage these differences:",[97,2221,2223],{"className":99,"code":2222,"filename":2218,"language":101,"meta":102,"style":102},"\u003Cscript lang=\"ts\">\nimport type { VariantProps } from 'tailwind-variants'\n\nconst card = tv({\n  slots: {\n    base: 'group relative border-4 border-black bg-white shadow-[8px_8px_0_black] transition duration-150 ease-linear hover:-translate-x-1 hover:-translate-y-1 hover:shadow-[12px_12px_0_black]',\n    title: 'font-medium text-black',\n    description: 'text-black',\n  },\n  variants: {\n    size: {\n      sm: {\n        base: 'space-y-4 p-6',\n        title: 'text-2xl',\n        description: 'text-lg',\n      },\n      md: {\n        base: 'space-y-6 p-12',\n        title: 'text-4xl',\n        description: 'text-xl',\n      },\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n})\ntype CardVariants = VariantProps\u003Ctypeof card>\nexport interface CardProps {\n  href: string\n  title: string\n  description?: string\n  size: CardVariants['size']\n  class?: any\n  ui?: Partial\u003Ctypeof card.slots>\n}\nexport interface CardEmits {}\nexport interface CardSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CCardProps>()\ndefineEmits\u003CCardEmits>()\ndefineSlots\u003CCardSlots>()\nconst ui = computed(() =>\n  card({\n    size: props.size,\n  }),\n)\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Carticle :class=\"ui.base({ class: [props.class, props.ui?.base] })\">\n    \u003Ch2 :class=\"ui.title({ class: props.ui?.title })\">\n      \u003Ca :href=\"props.href\">\n        {{ props.title }}\n        \u003Cspan class=\"absolute inset-0\" \u002F>\n      \u003C\u002Fa>\n    \u003C\u002Fh2>\n    \u003Cp :class=\"ui.description({ class: props.ui?.description })\">\n      {{ props.description }}\n    \u003C\u002Fp>\n  \u003C\u002Farticle>\n\u003C\u002Ftemplate>\n",[63,2224,2225,2239,2251,2255,2268,2273,2283,2293,2303,2307,2311,2316,2321,2331,2341,2351,2356,2361,2370,2379,2388,2392,2396,2400,2404,2414,2418,2422,2440,2451,2459,2467,2476,2492,2500,2517,2521,2532,2543,2551,2555,2571,2589,2601,2613,2629,2637,2643,2649,2654,2663,2668,2677,2694,2710,2726,2732,2752,2762,2772,2788,2794,2803,2812],{"__ignoreMap":102},[106,2226,2227,2229,2231,2233,2235,2237],{"class":108,"line":109},[106,2228,113],{"class":112},[106,2230,117],{"class":116},[106,2232,121],{"class":120},[106,2234,124],{"class":112},[106,2236,128],{"class":127},[106,2238,134],{"class":112},[106,2240,2241,2243,2245,2247,2249],{"class":108,"line":137},[106,2242,651],{"class":153},[106,2244,769],{"class":153},[106,2246,772],{"class":112},[106,2248,657],{"class":153},[106,2250,660],{"class":127},[106,2252,2253],{"class":108,"line":146},[106,2254,181],{"emptyLinePlaceholder":180},[106,2256,2257,2259,2262,2264,2266],{"class":108,"line":161},[106,2258,403],{"class":153},[106,2260,2261],{"class":157}," card",[106,2263,409],{"class":153},[106,2265,676],{"class":120},[106,2267,679],{"class":112},[106,2269,2270],{"class":108,"line":167},[106,2271,2272],{"class":112},"  slots: {\n",[106,2274,2275,2278,2281],{"class":108,"line":177},[106,2276,2277],{"class":112},"    base: ",[106,2279,2280],{"class":127},"'group relative border-4 border-black bg-white shadow-[8px_8px_0_black] transition duration-150 ease-linear hover:-translate-x-1 hover:-translate-y-1 hover:shadow-[12px_12px_0_black]'",[106,2282,690],{"class":112},[106,2284,2285,2288,2291],{"class":108,"line":184},[106,2286,2287],{"class":112},"    title: ",[106,2289,2290],{"class":127},"'font-medium text-black'",[106,2292,690],{"class":112},[106,2294,2295,2298,2301],{"class":108,"line":194},[106,2296,2297],{"class":112},"    description: ",[106,2299,2300],{"class":127},"'text-black'",[106,2302,690],{"class":112},[106,2304,2305],{"class":108,"line":203},[106,2306,730],{"class":112},[106,2308,2309],{"class":108,"line":209},[106,2310,695],{"class":112},[106,2312,2313],{"class":108,"line":220},[106,2314,2315],{"class":112},"    size: {\n",[106,2317,2318],{"class":108,"line":226},[106,2319,2320],{"class":112},"      sm: {\n",[106,2322,2323,2326,2329],{"class":108,"line":241},[106,2324,2325],{"class":112},"        base: ",[106,2327,2328],{"class":127},"'space-y-4 p-6'",[106,2330,690],{"class":112},[106,2332,2333,2336,2339],{"class":108,"line":251},[106,2334,2335],{"class":112},"        title: ",[106,2337,2338],{"class":127},"'text-2xl'",[106,2340,690],{"class":112},[106,2342,2343,2346,2349],{"class":108,"line":533},[106,2344,2345],{"class":112},"        description: ",[106,2347,2348],{"class":127},"'text-lg'",[106,2350,690],{"class":112},[106,2352,2353],{"class":108,"line":539},[106,2354,2355],{"class":112},"      },\n",[106,2357,2358],{"class":108,"line":545},[106,2359,2360],{"class":112},"      md: {\n",[106,2362,2363,2365,2368],{"class":108,"line":554},[106,2364,2325],{"class":112},[106,2366,2367],{"class":127},"'space-y-6 p-12'",[106,2369,690],{"class":112},[106,2371,2372,2374,2377],{"class":108,"line":559},[106,2373,2335],{"class":112},[106,2375,2376],{"class":127},"'text-4xl'",[106,2378,690],{"class":112},[106,2380,2381,2383,2386],{"class":108,"line":568},[106,2382,2345],{"class":112},[106,2384,2385],{"class":127},"'text-xl'",[106,2387,690],{"class":112},[106,2389,2390],{"class":108,"line":575},[106,2391,2355],{"class":112},[106,2393,2394],{"class":108,"line":580},[106,2395,725],{"class":112},[106,2397,2398],{"class":108,"line":598},[106,2399,730],{"class":112},[106,2401,2402],{"class":108,"line":603},[106,2403,839],{"class":112},[106,2405,2406,2409,2412],{"class":108,"line":614},[106,2407,2408],{"class":112},"    size: ",[106,2410,2411],{"class":127},"'md'",[106,2413,690],{"class":112},[106,2415,2416],{"class":108,"line":623},[106,2417,730],{"class":112},[106,2419,2420],{"class":108,"line":975},[106,2421,542],{"class":112},[106,2423,2424,2426,2429,2431,2433,2435,2437],{"class":108,"line":984},[106,2425,866],{"class":153},[106,2427,2428],{"class":120}," CardVariants",[106,2430,409],{"class":153},[106,2432,874],{"class":120},[106,2434,113],{"class":112},[106,2436,879],{"class":153},[106,2438,2439],{"class":112}," card>\n",[106,2441,2442,2444,2446,2449],{"class":108,"line":989},[106,2443,891],{"class":153},[106,2445,894],{"class":153},[106,2447,2448],{"class":120}," CardProps",[106,2450,460],{"class":112},[106,2452,2453,2455,2457],{"class":108,"line":1006},[106,2454,150],{"class":149},[106,2456,154],{"class":153},[106,2458,158],{"class":157},[106,2460,2461,2463,2465],{"class":108,"line":1025},[106,2462,1719],{"class":149},[106,2464,154],{"class":153},[106,2466,158],{"class":157},[106,2468,2469,2472,2474],{"class":108,"line":1038},[106,2470,2471],{"class":149},"  description",[106,2473,923],{"class":153},[106,2475,158],{"class":157},[106,2477,2478,2481,2483,2485,2487,2490],{"class":108,"line":1051},[106,2479,2480],{"class":149},"  size",[106,2482,154],{"class":153},[106,2484,2428],{"class":120},[106,2486,928],{"class":112},[106,2488,2489],{"class":127},"'size'",[106,2491,934],{"class":112},[106,2493,2494,2496,2498],{"class":108,"line":1056},[106,2495,939],{"class":149},[106,2497,923],{"class":153},[106,2499,944],{"class":157},[106,2501,2502,2505,2507,2510,2512,2514],{"class":108,"line":1077},[106,2503,2504],{"class":149},"  ui",[106,2506,923],{"class":153},[106,2508,2509],{"class":120}," Partial",[106,2511,113],{"class":112},[106,2513,879],{"class":153},[106,2515,2516],{"class":112}," card.slots>\n",[106,2518,2519],{"class":108,"line":1086},[106,2520,949],{"class":112},[106,2522,2523,2525,2527,2530],{"class":108,"line":1091},[106,2524,891],{"class":153},[106,2526,894],{"class":153},[106,2528,2529],{"class":120}," CardEmits",[106,2531,961],{"class":112},[106,2533,2534,2536,2538,2541],{"class":108,"line":1100},[106,2535,891],{"class":153},[106,2537,894],{"class":153},[106,2539,2540],{"class":120}," CardSlots",[106,2542,961],{"class":112},[106,2544,2545,2547,2549],{"class":108,"line":1124},[106,2546,170],{"class":112},[106,2548,117],{"class":116},[106,2550,134],{"class":112},[106,2552,2553],{"class":108,"line":1130},[106,2554,181],{"emptyLinePlaceholder":180},[106,2556,2557,2559,2561,2563,2565,2567,2569],{"class":108,"line":1139},[106,2558,113],{"class":112},[106,2560,117],{"class":116},[106,2562,121],{"class":120},[106,2564,124],{"class":112},[106,2566,128],{"class":127},[106,2568,131],{"class":120},[106,2570,134],{"class":112},[106,2572,2574,2576,2578,2580,2582,2584,2587],{"class":108,"line":2573},42,[106,2575,403],{"class":153},[106,2577,406],{"class":157},[106,2579,409],{"class":153},[106,2581,412],{"class":120},[106,2583,113],{"class":112},[106,2585,2586],{"class":120},"CardProps",[106,2588,1022],{"class":112},[106,2590,2592,2594,2596,2599],{"class":108,"line":2591},43,[106,2593,1028],{"class":120},[106,2595,113],{"class":112},[106,2597,2598],{"class":120},"CardEmits",[106,2600,1022],{"class":112},[106,2602,2604,2606,2608,2611],{"class":108,"line":2603},44,[106,2605,1041],{"class":120},[106,2607,113],{"class":112},[106,2609,2610],{"class":120},"CardSlots",[106,2612,1022],{"class":112},[106,2614,2616,2618,2620,2622,2624,2626],{"class":108,"line":2615},45,[106,2617,403],{"class":153},[106,2619,1061],{"class":157},[106,2621,409],{"class":153},[106,2623,451],{"class":120},[106,2625,454],{"class":112},[106,2627,2628],{"class":153},"=>\n",[106,2630,2632,2635],{"class":108,"line":2631},46,[106,2633,2634],{"class":120},"  card",[106,2636,679],{"class":112},[106,2638,2640],{"class":108,"line":2639},47,[106,2641,2642],{"class":112},"    size: props.size,\n",[106,2644,2646],{"class":108,"line":2645},48,[106,2647,2648],{"class":112},"  }),\n",[106,2650,2652],{"class":108,"line":2651},49,[106,2653,530],{"class":112},[106,2655,2657,2659,2661],{"class":108,"line":2656},50,[106,2658,170],{"class":112},[106,2660,117],{"class":116},[106,2662,134],{"class":112},[106,2664,2666],{"class":108,"line":2665},51,[106,2667,181],{"emptyLinePlaceholder":180},[106,2669,2671,2673,2675],{"class":108,"line":2670},52,[106,2672,113],{"class":112},[106,2674,189],{"class":116},[106,2676,134],{"class":112},[106,2678,2680,2682,2685,2687,2689,2692],{"class":108,"line":2679},53,[106,2681,197],{"class":112},[106,2683,2684],{"class":116},"article",[106,2686,590],{"class":120},[106,2688,124],{"class":112},[106,2690,2691],{"class":127},"\"ui.base({ class: [props.class, props.ui?.base] })\"",[106,2693,134],{"class":112},[106,2695,2697,2699,2701,2703,2705,2708],{"class":108,"line":2696},54,[106,2698,229],{"class":112},[106,2700,50],{"class":116},[106,2702,590],{"class":120},[106,2704,124],{"class":112},[106,2706,2707],{"class":127},"\"ui.title({ class: props.ui?.title })\"",[106,2709,134],{"class":112},[106,2711,2713,2716,2718,2720,2722,2724],{"class":108,"line":2712},55,[106,2714,2715],{"class":112},"      \u003C",[106,2717,17],{"class":116},[106,2719,1107],{"class":120},[106,2721,124],{"class":112},[106,2723,1112],{"class":127},[106,2725,134],{"class":112},[106,2727,2729],{"class":108,"line":2728},56,[106,2730,2731],{"class":112},"        {{ props.title }}\n",[106,2733,2735,2738,2740,2743,2745,2748,2750],{"class":108,"line":2734},57,[106,2736,2737],{"class":112},"        \u003C",[106,2739,106],{"class":116},[106,2741,2742],{"class":120}," class",[106,2744,124],{"class":112},[106,2746,2747],{"class":127},"\"absolute inset-0\"",[106,2749,236],{"class":235},[106,2751,134],{"class":112},[106,2753,2755,2758,2760],{"class":108,"line":2754},58,[106,2756,2757],{"class":112},"      \u003C\u002F",[106,2759,17],{"class":116},[106,2761,134],{"class":112},[106,2763,2765,2768,2770],{"class":108,"line":2764},59,[106,2766,2767],{"class":112},"    \u003C\u002F",[106,2769,50],{"class":116},[106,2771,134],{"class":112},[106,2773,2775,2777,2779,2781,2783,2786],{"class":108,"line":2774},60,[106,2776,229],{"class":112},[106,2778,10],{"class":116},[106,2780,590],{"class":120},[106,2782,124],{"class":112},[106,2784,2785],{"class":127},"\"ui.description({ class: props.ui?.description })\"",[106,2787,134],{"class":112},[106,2789,2791],{"class":108,"line":2790},61,[106,2792,2793],{"class":112},"      {{ props.description }}\n",[106,2795,2797,2799,2801],{"class":108,"line":2796},62,[106,2798,2767],{"class":112},[106,2800,10],{"class":116},[106,2802,134],{"class":112},[106,2804,2806,2808,2810],{"class":108,"line":2805},63,[106,2807,244],{"class":112},[106,2809,2684],{"class":116},[106,2811,134],{"class":112},[106,2813,2815,2817,2819],{"class":108,"line":2814},64,[106,2816,170],{"class":112},[106,2818,189],{"class":116},[106,2820,134],{"class":112},[10,2822,2823,2824,2827,2828,2831,2832,2834],{},"Finally, move the ",[63,2825,2826],{},".env.example"," file to the ",[63,2829,2830],{},"src"," folder since VitePress defines the project root in the ",[63,2833,2830],{}," folder.",[10,2836,2837,2838,2843,2844,2849],{},"For the full refactor, refer to commit ",[17,2839,2842],{"href":2840,"rel":2841},"https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fgarabit\u002Fcommit\u002F26b1dd4d767851004d562702a577b9aa41d2d363",[21],"26b1dd4"," of ",[17,2845,2848],{"href":2846,"rel":2847},"https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fgarabit",[21],"Garabit"," as I can't cover all changes in this article.",[10,2851,2852,2853,2855,2856,2860],{},"I hope you found this article insightful and learned something new. The goals were to demonstrate the power of ",[39,2854,41],{}," with a feature-based folder structure and to show that you can start simply and grow step by step as needed. In our case, this refactor sets the stage for adding the ",[17,2857,2859],{"href":19,"rel":2858},[21],"comment system",".",[1355,2862,2863],{"color":1357,"icon":1358},[10,2864,2865],{},"All my projects, even the smallest ones, are based on both Tailwind Variants and a feature-based folder structure. This setup enhances my productivity and, because of the consistent components and folder structure, allows me to switch projects seamlessly without wasting time understanding project architecture. Now, creating a component feels more like a reflex than a task.",[2867,2868,2869],"style",{},"html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sovSZ, html code.shiki .sovSZ{--shiki-light:#22863A;--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sPrNH, html code.shiki .sPrNH{--shiki-light:#B31D28;--shiki-light-font-style:italic;--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":102,"searchDepth":137,"depth":137,"links":2871},[2872,2873,2874],{"id":52,"depth":137,"text":53},{"id":1278,"depth":137,"text":1279},{"id":1367,"depth":137,"text":1368},"5b1b6117-14f0-4f1d-ba13-5b3583f341bf","2025-02-01","Prepare your blog for future growth by refactoring the codebase to ensure it remains maintainable and scalable.","md",{"branch":2880},"11.internal-refactor",null,{},"\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fan-internal-refactor-for-the-future-growth-of-our-blog","---\ncontentId: 5b1b6117-14f0-4f1d-ba13-5b3583f341bf\npart: 11\ntitle: An Internal Refactor for the Future Growth of Our Blog\ndescription: Prepare your blog for future growth by refactoring the codebase to ensure it remains maintainable and scalable.\ngithub:\n  branch: 11.internal-refactor\ndate: 2025-02-01\nseriesSlug: create-a-blog-with-vitepress-and-vue-js-from-scratch\n---\n\nOur blog was established, with the primary focus on content and functioning well.\n\nBut we aimed to do more. We considered adding [a comment system](https:\u002F\u002Fsoubiran.dev\u002Fseries\u002Fempower-and-dynamize-our-vitepress-blog-with-a-laravel-api). Once you have an API, numerous possibilities arise. Additionally, we've learned a lot since starting this blog, and we want to apply this knowledge to make it more maintainable and scalable, especially for future growth, although this internal refactor may not seem to improve it immediately.\n\nThis refactor focuses on two main points:\n\n1. Add [**Tailwind Variants**](https:\u002F\u002Fwww.tailwind-variants.org\u002F) to facilitate the reuse of components\n2. Transition from a type-based folder structure to a feature-based folder structure\n\nLet me explain why we want to do this.\n\n## Why use Tailwind Variants?\n\nFirst, let's understand the problem we're facing. Currently, our codebase has two buttons:\n\n- `ButtonPrimary.vue`: a primary button\n- `ButtonSecondary.vue`: a secondary button\n\nThe issue is that our site is simple and has only these two buttons. But what if we want to add a tertiary button, a button with a border instead of a background color, or a button with a different size? Or worse, what if we want our `Button` to be a real `button` instead of just an `a` tag? Updating each component individually would be a nightmare to maintain, and small changes would require so much time, leading to loss of productivity, often the reason projects don't succeed.\n\nTo resolve this, we can consolidate all buttons into a single component. This is easier than it seems. Consider the `ButtonPrimary.vue` and `ButtonSecondary.vue` components:\n\n```vue [ButtonPrimary.vue]\n\u003Cscript lang=\"ts\" setup>\ndefineProps\u003C{\n  href: string\n}>()\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"border-4 border-black bg-[var(--color-yellow)] px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#ffdf1b] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n```\n\n```vue [ButtonSecondary.vue]\n\u003Cscript lang=\"ts\" setup>\ndefineProps\u003C{\n  href: string\n}>()\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"inline-block border-4 border-black bg-[var(--color-purple)] px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:bg-[#828cd2] hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n```\n\nThey are almost identical! The only difference is the color: `bg-[var(--color-yellow)] hover:bg-[#ffdf1b]` for the first, and `bg-[var(--color-purple)] hover:bg-[#828cd2]` for the second. This can be merged into a single component:\n\n```vue [Button.vue]\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003C{\n  href: string\n  color: string\n}>()\n\nconst color = computed(() => {\n  switch (props.color) {\n    case 'primary':\n      return 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]'\n    case 'secondary':\n      return 'bg-[var(--color-purple)] hover:bg-[#828cd2]'\n    default:\n      throw new Error('Unknown color')\n  }\n})\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca\n    :href\n    class=\"inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]\" :class=\"[color]\"\n  >\n    \u003Cslot \u002F>\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n```\n\nThis is a good start but still not scalable. Our button could vary in size, color, variant, state, and more. Managing these in multiple computed properties is not ideal. This is where **Tailwind Variants** helps.\n\nA powerful approach is to decouple the theme, not the style, from the component and framework. With Tailwind Variants, we can define an independent theme for a component adaptable to different contexts in a declarative way:\n\n```ts [Example]\nimport { tv } from 'tailwind-variants'\n\nconst button = tv({\n  base: 'inline-block border-4 border-black px-8 py-4 text-white shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:shadow-[6px_6px_0_black] hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem]',\n  variants: {\n    color: {\n      primary: 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]',\n      secondary: 'bg-[var(--color-purple)] hover:bg-[#828cd2]',\n    },\n  },\n})\n```\n\nDo you see the power of this approach? The base style, shared among variants, is defined centrally. Then we define variants, such as color. Additional properties like size can also be added or compound variants defined for specific styles, like when a button is primary and small.\n\nRewriting our `Button.vue` component:\n\n```vue [Button.vue]\n\u003Cscript lang=\"ts\">\nimport type { VariantProps } from 'tailwind-variants'\n\nconst button = tv({\n  base: 'border-4 border-black px-8 py-4 shadow-[4px_4px_0_black] transition duration-150 ease-linear hover:-translate-x-[0.125rem] hover:-translate-y-[0.125rem] hover:shadow-[6px_6px_0_black]',\n  variants: {\n    color: {\n      primary: 'bg-[var(--color-yellow)] hover:bg-[#ffdf1b]',\n      secondary: 'text-white bg-[var(--color-purple)] hover:bg-[#828cd2]',\n    },\n  },\n  defaultVariants: {\n    color: 'primary',\n  },\n})\n\ntype ButtonVariants = VariantProps\u003Ctypeof button>\n\nexport interface ButtonProps {\n  href: string\n  label: string\n  color?: ButtonVariants['color']\n  class?: any\n}\nexport interface ButtonEmits {}\nexport interface ButtonSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CButtonProps>()\ndefineEmits\u003CButtonEmits>()\ndefineSlots\u003CButtonSlots>()\n\nconst ui = computed(() => button({ class: props.class, color: props.color }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ca :href=\"props.href\" :class=\"ui\">\n    {{ props.label }}\n  \u003C\u002Fa>\n\u003C\u002Ftemplate>\n```\n\nOne interesting aspect is extracting variants with **TypeScript** and applying them to the props. The `ButtonVariants` type includes all `Button` variants based on the `button` theme. So any theme change reflects in the `Button` component automatically.\n\nYou're probably asking: How do Tailwind Variants know which variant to use? Look at this code:\n\n```ts [Example]\nconst ui = computed(() => button({ class: props.class, color: props.color }))\n```\n\nThe `button` variable is a function that takes an object with variants as arguments. This way, variants are calculated at runtime based on props and the predefined theme.\n\nWe can use our `Button` component like this:\n\n```vue [Example]\n\u003CButton href=\"https:\u002F\u002Fsoubiran.dev\" label=\"Primary Button\" \u002F>\n\n\u003CButton href=\"https:\u002F\u002Fsoubiran.dev\" label=\"Secondary Button\" color=\"secondary\" \u002F>\n```\n\nAutomatically, the `Button` component applies the correct style based on the `color` prop.\n\n## Why move to a feature-based folder structure?\n\nCurrently, our codebase is in `.vitepress\u002Ftheme`, split into folders:\n\n```text [By Type]\n└── .vitepress\u002Ftheme\n    ├── components\n    ├── composables\n    ├── pages\n    ├── styles\n    └── types\n```\n\nWe may have additional folders like `directives`, `utils`, `queries`, or `mutations`. This structure, based on file types, places all components in one folder regardless of their use, which isn't ideal.\n\nIt's hard to identify core blog features from the folder structure. With just one feature, it's manageable, but as the blog grows, locating specific components or pages becomes challenging. Hence, a feature-based folder structure is beneficial.\n\nThis approach groups multiple folder-by-type structures by feature. It's easy to find specific components, and when working on a feature, all related files are easily accessible. It's an efficient way to manage and scale a project.\n\nIn our case, the major features are the blog and projects. The structure could be like this:\n\n```text [By Feature]\n└── .vitepress\u002Ftheme\n    ├── blog\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    └── projects\n        ├── components\n        ├── composables\n        ├── pages\n        └── types\n```\n\nThis way, core blog features are clear, and related files are easily found. Adding new features involves creating a new folder and including related files.\n\nA missing folder here is `common` or `shared`. It contains files shared between features. For example, the `Button` component shared by the blog and projects should be placed here.\n\n```text [By Feature with Common]\n└── .vitepress\u002Ftheme\n    ├── blog\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    ├── projects\n    │   ├── components\n    │   ├── composables\n    │   ├── pages\n    │   └── types\n    └── common\n        ├── components\n        ├── composables\n        ├── styles\n        └── types\n```\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nI named it `common`, but you can choose any name that conveys the shared nature of the files not belonging to a specific feature.\n::\n\n## Refactoring the codebase\n\nAside from the two main points, small codebase changes will enhance readability and reduce code repetition, crucial for maintaining blog style coherence.\n\nFirst, we'll consolidate everything related to `Page`. Every page component shares the same wrapper, title, and footer structure. We can easily extract each part into three components:\n\n1. `Page.vue`\n\n```vue [Page.vue]\n\u003Cscript lang=\"ts\">\nconst page = tv({\n  base: 'space-y-16',\n})\nexport interface PageProps {\n  class?: any\n}\nexport interface PageEmits {}\nexport interface PageSlots {\n  default: (props?: object) => any\n}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageProps>()\ndefineEmits\u003CPageEmits>()\ndefineSlots\u003CPageSlots>()\nconst ui = computed(() => page({ class: props.class }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Csection :class=\"ui\">\n    \u003Cslot \u002F>\n  \u003C\u002Fsection>\n\u003C\u002Ftemplate>\n```\n\n2. `PageTitle.vue`\n\n```vue [PageTitle.vue]\n\u003Cscript lang=\"ts\">\nconst pageTitle = tv({\n  base: 'text-6xl font-semibold',\n})\nexport interface PageTitleProps {\n  title: string\n  class?: any\n}\nexport interface PageTitleEmits {}\nexport interface PageTitleSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageTitleProps>()\ndefineEmits\u003CPageTitleEmits>()\ndefineSlots\u003CPageTitleSlots>()\nconst ui = computed(() => pageTitle())\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Ch1 :class=\"ui\">\n    {{ props.title }}\n  \u003C\u002Fh1>\n\u003C\u002Ftemplate>\n```\n\n3. `PageFooter.vue`\n\n```vue [PageFooter.vue]\n\u003Cscript lang=\"ts\">\nconst pageFooter = tv({\n  base: 'flex justify-center',\n})\nexport interface PageFooterProps {\n  backTo: { href: string, label: string }\n  class?: any\n}\nexport interface PageFooterEmits {}\nexport interface PageFooterSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CPageFooterProps>()\ndefineEmits\u003CPageFooterEmits>()\ndefineSlots\u003CPageFooterSlots>()\nconst ui = computed(() => pageFooter({ class: props.class }))\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Cdiv :class=\"ui\">\n    \u003CButton :href=\"props.backTo.href\" :label=\"props.backTo.label\" \u002F>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n```\n\nThese simple components help reduce code repetition and streamline new page creation. Additionally, we can consolidate every prose into a single `Prose.vue` component, ensuring consistent blog prose style.\n\nNext, we can unify `ProjectCard.vue` and `BlogCard.vue` into `Card.vue`. Their only differences are title size, description, and padding. Tailwind Variants efficiently manage these differences:\n\n```vue [Card.vue]\n\u003Cscript lang=\"ts\">\nimport type { VariantProps } from 'tailwind-variants'\n\nconst card = tv({\n  slots: {\n    base: 'group relative border-4 border-black bg-white shadow-[8px_8px_0_black] transition duration-150 ease-linear hover:-translate-x-1 hover:-translate-y-1 hover:shadow-[12px_12px_0_black]',\n    title: 'font-medium text-black',\n    description: 'text-black',\n  },\n  variants: {\n    size: {\n      sm: {\n        base: 'space-y-4 p-6',\n        title: 'text-2xl',\n        description: 'text-lg',\n      },\n      md: {\n        base: 'space-y-6 p-12',\n        title: 'text-4xl',\n        description: 'text-xl',\n      },\n    },\n  },\n  defaultVariants: {\n    size: 'md',\n  },\n})\ntype CardVariants = VariantProps\u003Ctypeof card>\nexport interface CardProps {\n  href: string\n  title: string\n  description?: string\n  size: CardVariants['size']\n  class?: any\n  ui?: Partial\u003Ctypeof card.slots>\n}\nexport interface CardEmits {}\nexport interface CardSlots {}\n\u003C\u002Fscript>\n\n\u003Cscript lang=\"ts\" setup>\nconst props = defineProps\u003CCardProps>()\ndefineEmits\u003CCardEmits>()\ndefineSlots\u003CCardSlots>()\nconst ui = computed(() =>\n  card({\n    size: props.size,\n  }),\n)\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003Carticle :class=\"ui.base({ class: [props.class, props.ui?.base] })\">\n    \u003Ch2 :class=\"ui.title({ class: props.ui?.title })\">\n      \u003Ca :href=\"props.href\">\n        {{ props.title }}\n        \u003Cspan class=\"absolute inset-0\" \u002F>\n      \u003C\u002Fa>\n    \u003C\u002Fh2>\n    \u003Cp :class=\"ui.description({ class: props.ui?.description })\">\n      {{ props.description }}\n    \u003C\u002Fp>\n  \u003C\u002Farticle>\n\u003C\u002Ftemplate>\n```\n\nFinally, move the `.env.example` file to the `src` folder since VitePress defines the project root in the `src` folder.\n\nFor the full refactor, refer to commit [26b1dd4](https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fgarabit\u002Fcommit\u002F26b1dd4d767851004d562702a577b9aa41d2d363) of [Garabit](https:\u002F\u002Fgithub.com\u002FBarbapapazes\u002Fgarabit) as I can't cover all changes in this article.\n\nI hope you found this article insightful and learned something new. The goals were to demonstrate the power of **Tailwind Variants** with a feature-based folder structure and to show that you can start simply and grow step by step as needed. In our case, this refactor sets the stage for adding the [comment system](https:\u002F\u002Fsoubiran.dev\u002Fseries\u002Fempower-and-dynamize-our-vitepress-blog-with-a-laravel-api).\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nAll my projects, even the smallest ones, are based on both Tailwind Variants and a feature-based folder structure. This setup enhances my productivity and, because of the consistent components and folder structure, allows me to switch projects seamlessly without wasting time understanding project architecture. Now, creating a component feels more like a reflex than a task.\n::\n",{"title":5,"description":2877},"create-a-blog-with-vitepress-and-vue-js-from-scratch",{"loc":2883},"series\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fan-internal-refactor-for-the-future-growth-of-our-blog","TkpEtldIvPVRfNV6yRmt3aMej3pRHZ-iIEEnThkgtfc",{"overview":2891,"chapters":3131},{"id":2892,"title":2893,"body":2894,"contentId":3111,"date":3112,"description":3113,"extension":2878,"github":3114,"meetTheInstructor":3117,"meta":3118,"navigation":180,"part":2881,"path":3119,"rawbody":3120,"robots":2881,"schemaOrg":2881,"seo":3121,"seriesSlug":2886,"sitemap":3122,"stem":3125,"subtitle":3126,"topics":3127,"__hash__":3130},"series\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch.md","Create a Blog with VitePress and Vue.js from Scratch",{"type":7,"value":2895,"toc":3108},[2896,2899,2913,2927,3063,3074,3085,3092,3095,3098,3102],[10,2897,2898],{},"Hello and welcome! 👋",[10,2900,2901,2902,2905,2906,92,2909,2912],{},"You're about to embark on the \"Create a ",[39,2903,2904],{},"Blog"," with ",[39,2907,2908],{},"VitePress",[39,2910,2911],{},"Vue.js"," from Scratch\" series!",[10,2914,2915,2916,2922,2923,2926],{},"Throughout this journey, we will construct a practical blog from the ground up using ",[17,2917,2920],{"href":2918,"rel":2919},"https:\u002F\u002Fvitepress.dev\u002F",[21],[39,2921,2908],{},". We will explore a range of topics from initial configuration to deploying on ",[39,2924,2925],{},"Cloudflare Pages",", including:",[58,2928,2929,2954,2964,2970,2983,2989,2999,3009,3019,3031,3048,3054],{},[31,2930,2931,2934,2935,2938,2939,92,2946,2953],{},[39,2932,2933],{},"Getting Started with VitePress: Project Setup and Essentials",": Learn to set up a fresh ",[39,2936,2937],{},"VitePress project"," by incorporating ",[17,2940,2943],{"href":2941,"rel":2942},"https:\u002F\u002Ftailwindcss.com\u002F",[21],[39,2944,2945],{},"Tailwind CSS",[17,2947,2950],{"href":2948,"rel":2949},"https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components",[21],[39,2951,2952],{},"unplugin-vue-components"," for an enhanced development process.",[31,2955,2956,2959,2960],{},[39,2957,2958],{},"From Default to Custom: Building a VitePress Blog Theme",": We will entirely remove the default theme and create a personalized theme. ",[2961,2962,2963],"em",{},"You'll be surprised by its simplicity!",[31,2965,2966,2969],{},[39,2967,2968],{},"Optimize Your VitePress Blog's Architecture Design",": Discover how to organize code and design your blog for scalability and maintainability.",[31,2971,2972,2975,2976,2860],{},[39,2973,2974],{},"Implementing Blog Index with VitePress and Tailwind CSS",": Create a list of blog posts. This will introduce ",[17,2977,2980],{"href":2978,"rel":2979},"https:\u002F\u002Fvitepress.dev\u002Fguide\u002Fdata-loading",[21],[39,2981,2982],{},"data loaders from VitePress",[31,2984,2985,2988],{},[39,2986,2987],{},"Single Blog Rendering in VitePress with Tailwind Typography",": Create a page dedicated to reading each blog post.",[31,2990,2991,2994,2995,2998],{},[39,2992,2993],{},"Deploy VitePress Blog Globally with Cloudflare Pages",": Integrate ",[39,2996,2997],{},"SEO metadata"," for improved search engine visibility, eliminating the need for manual updates.",[31,3000,3001,3004,3005,3008],{},[39,3002,3003],{},"Showcase Your GitHub Projects on Your VitePress Blog",": Develop a page to display your ",[39,3006,3007],{},"GitHub"," endeavors, extending the use of data loaders and demonstrating their flexibility.",[31,3010,3011,3014,3015,3018],{},[39,3012,3013],{},"Creating Open Graph Images Automatically for Each Blog Post",": Efficiently create ",[39,3016,3017],{},"Open Graph images"," for each post, saving time and enhancing appeal.",[31,3020,3021,3023,3024,3030],{},[39,3022,2993],{},": Seamlessly deploy your blog to ",[17,3025,3028],{"href":3026,"rel":3027},"https:\u002F\u002Fpages.cloudflare.com\u002F",[21],[39,3029,2925],{},", achieving this in just a few clicks!",[31,3032,3033,3036,3037,2905,3040,3047],{},[39,3034,3035],{},"Ensure Blog Quality with Playwright Automated Testing",": Implement ",[39,3038,3039],{},"end-to-end testing",[17,3041,3044],{"href":3042,"rel":3043},"https:\u002F\u002Fplaywright.dev\u002F",[21],[39,3045,3046],{},"Playwright"," to ensure your blog functions as expected.",[31,3049,3050,3053],{},[39,3051,3052],{},"An Internal Refactor for the Future Growth of our Blog",": Prepare your blog for future growth by refactoring the codebase, ensuring it remains maintainable and scalable.",[31,3055,3056,3059,3060,3062],{},[39,3057,3058],{},"Migrating Our VitePress Blog to Tailwind CSS Version 4",": Upgrade our blog to the latest version of ",[39,3061,2945],{}," to leverage its new features and improvements.",[10,3064,3065,3066,3069,3070,3073],{},"By the conclusion, you will possess a fully operational and captivating ",[39,3067,3068],{},"blog",", allowing you to concentrate exclusively on producing ",[39,3071,3072],{},"content",", which is paramount. Simply write and publish, as the blog will autonomously manage the rest.",[3075,3076,3077,3082],"figure",{},[3078,3079],"img",{"alt":3080,"src":3081},"Home Page of our Blog","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages\u002Fvitepress-home.png",[3083,3084,3080],"figcaption",{},[10,3086,3087,3088,3091],{},"This series offers a detailed, step-by-step ",[39,3089,3090],{},"guide",". Rest assured, each aspect will be thoroughly elucidated, from selecting to implementing every feature. While each feature will be minimal and focused on the core, this does not mean we will forgo creating a visually pleasing and functional blog.",[10,3093,3094],{},"Should you have any inquiries, please feel free to engage in the comments section under each article.",[10,3096,3097],{},"I hope you find this series truly enjoyable! 🚀",[50,3099,3101],{"id":3100},"chapters","Chapters",[3103,3104],"series-chapters-list",{"className":3105},[3106,3107],"mx-auto","max-w-5xl",{"title":102,"searchDepth":137,"depth":137,"links":3109},[3110],{"id":3100,"depth":137,"text":3101},"43c95b33-041c-4108-ab98-0d21ef60ed7f","2024-10-10","Build a dynamic blog with VitePress and Vue.js from scratch. Learn setup, SEO, and deployment for a seamless blogging experience.",{"name":3115,"repository":3116},"garabit","barbapapazes\u002Fgarabit","I create this series because \u003Cstrong>VitePress\u003C\u002Fstrong> is way more powerful than it seems at the first glance. I was amazed by the \u003Cstrong>flexibility\u003C\u002Fstrong> and the \u003Cstrong>simplicity\u003C\u002Fstrong> of the tool while building my blog and wanted the community to know about it.",{},"\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch","---\ncontentId: 43c95b33-041c-4108-ab98-0d21ef60ed7f\ntitle: Create a Blog with VitePress and Vue.js from Scratch\nsubtitle: A new perspective on blogging with VitePress and Vue.js\ndescription: Build a dynamic blog with VitePress and Vue.js from scratch. Learn setup, SEO, and deployment for a seamless blogging experience.\ndate: 2024-10-10\ntopics:\n  - vuejs\n  - vitepress\n  - blog\ngithub:\n  name: garabit\n  repository: barbapapazes\u002Fgarabit\nmeetTheInstructor: I create this series because \u003Cstrong>VitePress\u003C\u002Fstrong> is way more powerful than it seems at the first glance. I was amazed by the \u003Cstrong>flexibility\u003C\u002Fstrong> and the \u003Cstrong>simplicity\u003C\u002Fstrong> of the tool while building my blog and wanted the community to know about it.\nseriesSlug: create-a-blog-with-vitepress-and-vue-js-from-scratch\n---\n\nHello and welcome! 👋\n\nYou're about to embark on the \"Create a **Blog** with **VitePress** and **Vue.js** from Scratch\" series!\n\nThroughout this journey, we will construct a practical blog from the ground up using [**VitePress**](https:\u002F\u002Fvitepress.dev\u002F). We will explore a range of topics from initial configuration to deploying on **Cloudflare Pages**, including:\n\n- **Getting Started with VitePress: Project Setup and Essentials**: Learn to set up a fresh **VitePress project** by incorporating [**Tailwind CSS**](https:\u002F\u002Ftailwindcss.com\u002F) and [**unplugin-vue-components**](https:\u002F\u002Fgithub.com\u002Funplugin\u002Funplugin-vue-components) for an enhanced development process.\n- **From Default to Custom: Building a VitePress Blog Theme**: We will entirely remove the default theme and create a personalized theme. _You'll be surprised by its simplicity!_\n- **Optimize Your VitePress Blog's Architecture Design**: Discover how to organize code and design your blog for scalability and maintainability.\n- **Implementing Blog Index with VitePress and Tailwind CSS**: Create a list of blog posts. This will introduce [**data loaders from VitePress**](https:\u002F\u002Fvitepress.dev\u002Fguide\u002Fdata-loading).\n- **Single Blog Rendering in VitePress with Tailwind Typography**: Create a page dedicated to reading each blog post.\n- **Deploy VitePress Blog Globally with Cloudflare Pages**: Integrate **SEO metadata** for improved search engine visibility, eliminating the need for manual updates.\n- **Showcase Your GitHub Projects on Your VitePress Blog**: Develop a page to display your **GitHub** endeavors, extending the use of data loaders and demonstrating their flexibility.\n- **Creating Open Graph Images Automatically for Each Blog Post**: Efficiently create **Open Graph images** for each post, saving time and enhancing appeal.\n- **Deploy VitePress Blog Globally with Cloudflare Pages**: Seamlessly deploy your blog to [**Cloudflare Pages**](https:\u002F\u002Fpages.cloudflare.com\u002F), achieving this in just a few clicks!\n- **Ensure Blog Quality with Playwright Automated Testing**: Implement **end-to-end testing** with [**Playwright**](https:\u002F\u002Fplaywright.dev\u002F) to ensure your blog functions as expected.\n- **An Internal Refactor for the Future Growth of our Blog**: Prepare your blog for future growth by refactoring the codebase, ensuring it remains maintainable and scalable.\n- **Migrating Our VitePress Blog to Tailwind CSS Version 4**: Upgrade our blog to the latest version of **Tailwind CSS** to leverage its new features and improvements.\n\nBy the conclusion, you will possess a fully operational and captivating **blog**, allowing you to concentrate exclusively on producing **content**, which is paramount. Simply write and publish, as the blog will autonomously manage the rest.\n\n![Home Page of our Blog](\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages\u002Fvitepress-home.png)\n\nThis series offers a detailed, step-by-step **guide**. Rest assured, each aspect will be thoroughly elucidated, from selecting to implementing every feature. While each feature will be minimal and focused on the core, this does not mean we will forgo creating a visually pleasing and functional blog.\n\nShould you have any inquiries, please feel free to engage in the comments section under each article.\n\nI hope you find this series truly enjoyable! 🚀\n\n## Chapters\n\n::series-chapters-list\n---\nclass: mx-auto max-w-5xl\n---\n::\n",{"title":2893,"description":3113},{"loc":3119,"images":3123},[3124],{"loc":3081},"series\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch","A new perspective on blogging with VitePress and Vue.js",[3128,3129,3068],"vuejs","vitepress","H9cubHgLKM0Siblzkwf7mDsFVYr2CLbh_ciFOpQrSVk",[3132,3138,3144,3150,3156,3162,3169,3175,3181,3187,3193,3195],{"contentId":3133,"title":2933,"description":3134,"path":3135,"part":109,"github":3136,"topics":2881},"b1b99d95-ac6d-4f25-a121-0851988102a2","From setup to styling with Tailwind CSS and automatic Vue imports, build your content-driven site effortlessly.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fgetting-started-with-vitepress-project-setup-and-essentials",{"branch":3137},"01.project-initialization",{"contentId":3139,"title":2958,"description":3140,"path":3141,"part":137,"github":3142,"topics":2881},"172f2a41-2f7c-44e9-855d-322adc536279","Step-by-step VitePress theme customization: guide to building a unique theme layout, adding Markdown content, and removing defaults.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Ffrom-default-to-custom-building-a-vitepress-blog-theme",{"branch":3143},"02.the-basics-for-a-custom-theme",{"contentId":3145,"title":2968,"description":3146,"path":3147,"part":146,"github":3148,"topics":2881},"900d11a5-ff68-4cc9-8ace-66a5cb1577fa","Discover how to optimize your VitePress blog's architecture design with scalable solutions and efficient Vite plugin integration.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Foptimize-your-vitepress-blog-architecture-design",{"branch":3149},"03.define-the-design-of-the-blog-architecture",{"contentId":3151,"title":2974,"description":3152,"path":3153,"part":161,"github":3154,"topics":2881},"4d93a3c5-f3ff-4ff6-a569-5234ef805850","Learn to create a list of blog articles using VitePress, a crucial feature for any content-centric website. Utilize data loaders to load articles.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fimplementing-blog-index-with-vitepress-and-tailwind-css",{"branch":3155},"04.comprehensive-guide-to-listing-blog-articles",{"contentId":3157,"title":2987,"description":3158,"path":3159,"part":167,"github":3160,"topics":2881},"15b9a49c-b9fb-4d76-a08d-2acaf55ff205","Enhance your VitePress blog with Tailwind Typography. Learn to render markdown beautifully with syntax highlights.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fsingle-blog-rendering-in-vitepress-with-tailwind-typography",{"branch":3161},"05.read-a-single-blog-article",{"contentId":3163,"title":3164,"description":3165,"path":3166,"part":177,"github":3167,"topics":2881},"66af9aaf-d6d3-4151-a51b-806835988340","Enhance Website Visibility: SEO Metadata and Sitemap","Enhance website traffic through strategic SEO metadata and sitemaps for improved indexing. Learn how to automate metadata generation for each page.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fenhance-website-visibility-seo-metadata-and-sitemap",{"branch":3168},"06.seo-metadata-and-sitemap",{"contentId":3170,"title":3003,"description":3171,"path":3172,"part":184,"github":3173,"topics":2881},"a4a933b8-07a5-4587-ad54-c3f9e30cbf45","Enhance your VitePress blog with GitHub projects. Learn API data retrieval and how to display your projects on your blog.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fshowcase-your-github-projects-on-your-vitepress-blog",{"branch":3174},"07.showcase-your-github-projects",{"contentId":3176,"title":3013,"description":3177,"path":3178,"part":194,"github":3179,"topics":2881},"c76a349e-a495-4890-ab05-3e8b6bb90add","Learn how to dynamically generate Open Graph images for each blog post, enhancing the visual appeal when sharing content on social media.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fcreating-open-graph-images-automatically-for-each-blog-post",{"branch":3180},"08.automatically-generated-open-graph-images",{"contentId":3182,"title":2993,"description":3183,"path":3184,"part":203,"github":3185,"topics":2881},"c05ae463-c5ae-4c43-872d-bb05263c7f74","Deploy the blog to Cloudflare Pages for global accessibility. Discover how to deploy the blog to Cloudflare Pages and share it worldwide with ease.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fdeploy-vitepress-blog-globally-with-cloudflare-pages",{"branch":3186},"09.share-the-blog-globally",{"contentId":3188,"title":3035,"description":3189,"path":3190,"part":209,"github":3191,"topics":2881},"aa5392e0-6287-4673-9365-34313f0af1fa","Enhance web development with Playwright-induced automated testing. Elevate blog quality through comprehensive end-to-end and SEO tests.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fensure-blog-quality-with-playwright-automated-testing",{"branch":3192},"10.automate-testing",{"contentId":2875,"title":5,"description":2877,"path":2883,"part":220,"github":3194,"topics":2881},{"branch":2880},{"contentId":3196,"title":3058,"description":3197,"path":3198,"part":226,"github":3199,"topics":2881},"3499bbd1-20a6-43f0-9bb7-be1da2bb6eac","A step-by-step guide on upgrading our VitePress blog to Tailwind CSS 4.0 to leverage its latest features and improvements.","\u002Fseries\u002Fcreate-a-blog-with-vitepress-and-vue-js-from-scratch\u002Fmigrating-our-vitepress-blog-to-tailwind-css-version-4",{"branch":3200},"12.migration-to-tailwind-css-4",1795016692977]