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