From aaf5d96baed975717ea5eef4c09acf32589b2c73 Mon Sep 17 00:00:00 2001 From: Cui Chen Date: Wed, 3 Apr 2024 15:23:39 +0800 Subject: [PATCH] refactor code --- lib/caidan.typ | 52 ++++++++++++++++++++------------------------------ main.typ | 42 +++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 53 deletions(-) diff --git a/lib/caidan.typ b/lib/caidan.typ index b72ff6a..378c7e8 100644 --- a/lib/caidan.typ +++ b/lib/caidan.typ @@ -21,14 +21,8 @@ #v(.3em) ] -#let item_counter = counter("item") - -#let item(name_zh, name_en, emoji: none) = box[ - #item_counter.step() - #zh_text(14pt)[ - #name_zh #h(1fr) - // #emoji - ] \ +#let item(name_zh, name_en) = box[ + #zh_text(14pt)[#name_zh #h(1fr)] \ #v(-.7em)#h(.14em)#en_text(10pt)[#name_en]#v(.3em) ] @@ -136,24 +130,22 @@ bottom + left, dx: offset_xl + 0.5 * column_width, dy: -frame.dy - 1em, - context ( - [ - #let num = (counter(page).get().at(0) - 1) * 3 + i - #if num != 0 { - en_text(10pt, style: "normal")[#numbering("I", num)] - } - ] - ), + context { + let num = (counter(page).get().at(0) - 1) * 3 + i + if num != 0 { + en_text(10pt, style: "normal")[#numbering("I", num)] + } + }, ) } ], ) - let title_page = context [ - #set align(center) - #let title_content = [ - #title - #if cover_image != none { + let title_page = context { + set align(center) + let title_content = { + title + if cover_image != none { v(3em) let img_width = measure(cover_image).width let max_img_width = column_width - 2 * frame.dx - 6em @@ -164,7 +156,7 @@ cover_image } } - #if update_date != none { + if update_date != none { v(5em) zh_text(10pt)[ 更新于:#update_date.display("[year]年[month padding:none]月[day padding:none]日") ] @@ -172,21 +164,19 @@ en_text(8pt)[ Updated on #update_date.display("[month repr:long] [day], [year]")] } - ] - #let text_dy = (page_height - measure(title_content).height) / 2 - frame.dy - 2em - #if title != none or cover_image != none or update_date != none { + } + let text_dy = ( + page_height - measure(title_content).height + ) / 2 - frame.dy - 2em + if title != none or cover_image != none or update_date != none { v(text_dy) title_content } - ] - - let end_page = [ - #colbreak(weak: true) - ] + } set list(marker: [#v(.7em)#en_text(16pt, fill: nord3)[☐]]) columns( num_columns, gutter: frame.dx * 2 + 4em, - )[#title_page #colbreak(weak: true) #body #colbreak(weak: true) #end_page] + )[#title_page #colbreak(weak: true) #body] } diff --git a/main.typ b/main.typ index 23185aa..e1aaae4 100644 --- a/main.typ +++ b/main.typ @@ -9,8 +9,6 @@ num_columns: 3, ) -#let peper(n: 1) = [#emoji.pepper.hot] * n - #cuisine[鲁菜][Shandong Cuisine] - #item[葱烧海参][Braised Sea Cucumber w/ Scallions] - #item[葱爆牛肉][Scallion Beef Stir-Fry] @@ -23,9 +21,9 @@ - #item[猪肉白菜炖粉条][Braised Pork Belly w/ Vermicelli Noodles & Napa Cabbage] #cuisine[川菜][Sichuan Cuisine] -- #item(emoji: peper())[宫保鸡丁][Gong Bao Chicken] -- #item(emoji: peper())[回锅肉][Twice-cooked pork] -- #item(emoji: peper())[麻婆豆腐][Mapo Tofu] +- #item[宫保鸡丁][Gong Bao Chicken] +- #item[回锅肉][Twice-cooked pork] +- #item[麻婆豆腐][Mapo Tofu] #cuisine[粤菜][Cantonese Cuisine] - #item[腊味煲仔饭][Sausage Claypot Rice] @@ -36,9 +34,9 @@ #cuisine[家常菜 (荤)][Home-style Cuisine (Meaty)] - #item[蒜香鸡翅][Garlic Chicken Wings] - #item[酱香鸭翅][Braised Duck Wings] -- #item(emoji: peper())[爆炒鸡胗][Chicken Gizzard Stir-Fry] -- #item(emoji: peper())[香辣红烧鸡爪][Spicy Chicken Feet] -- #item(emoji: peper())[黄焖鸡米饭][Braised Chicken and Rice] +- #item[爆炒鸡胗][Chicken Gizzard Stir-Fry] +- #item[香辣红烧鸡爪][Spicy Chicken Feet] +- #item[黄焖鸡米饭][Braised Chicken and Rice] - #item[马齿菜红烧肉][Braised Pork w/ Portulaca] - #item[板栗烧排骨][Braised Pork Ribs w/ Chestnuts] - #item[笋干烧排骨][Pork Ribs w/ Dried Bamboo Shoots] @@ -53,18 +51,18 @@ #cuisine[家常菜][Home-style Cuisine] - #item[豆腐脑][Douhua] - #item[蒜蓉秋葵][Galic Okra] -- #item(emoji: peper())[手撕包菜][Hand-Torn Cabbage] +- #item[手撕包菜][Hand-Torn Cabbage] - #item[炒紫甘蓝][Purple Cabbage Stir-Fry] - #item[清炒菠菜][Spinach Stir-Fry w/ Garlic] - #item[清炒四季豆][Stir Fry French Beans] -- #item(emoji: peper())[酸辣土豆丝][Hot & Sour Shredded Potato] +- #item[酸辣土豆丝][Hot & Sour Shredded Potato] - #item[香椿炒蛋][Toon Scrambled Eggs] - #item[蒜苔炒蛋][Scrambled Eggs w/ Garlic Moss] - #item[韭黄炒蛋][Scrambled Eggs w/ Hotbed Chives] - #item[韭菜炒蛋][Scrambled Eggs w/ Chinese Chives] - #item[西红柿炒蛋][Tomato & Egg Stir-Fry] - #item[豆豉鲮鱼油麦菜][Stir Fry Indian lettuce w/ Fried Dace w/ Salted Black Beans] -- #item(emoji: peper())[青椒肉末][Sautéed Minced Pork w/ Green Pepper ] +- #item[青椒肉末][Sautéed Minced Pork w/ Green Pepper ] - #item[豆角肉末][Long Beans Stir-Fry w/ Minced Pork] - #item[肉末毛豆][Edamame & Pork Mince Stir-Fry] - #item[油焖春笋][Braised Spring Bamboo Shoots] @@ -95,16 +93,16 @@ - #item[蒜蓉炒大虾][Shrimp Stir-Fry w/ Garlic] - #item[油焖大虾][Braised Shrimps] - #item[清蒸蟹][Steamed Crab] -- #item(emoji: peper())[香辣蟹][Sautéed Crab in Hot Spicy Sauce] -- #item(emoji: peper())[爆炒鱿鱼须][Spicy Squid Stir Fry] -- #item(emoji: peper())[香辣小鱿鱼][Spicy Baby Squid] +- #item[香辣蟹][Sautéed Crab in Hot Spicy Sauce] +- #item[爆炒鱿鱼须][Spicy Squid Stir Fry] +- #item[香辣小鱿鱼][Spicy Baby Squid] - #item[蜜汁烤肋排][Honey BBQ Ribs] - #item[蜜汁烤鸡胸][Honey BBQ Chicken] - #item[奥尔良烤鸡腿][Orleans Style BBQ Chicken Legs] - #item[空气炸锅鸡丝][Roasted Shredded Chicken] -- #item(emoji: peper())[烤茄子][Roasted Eggplant] -- #item(emoji: peper())[蒜蓉粉丝生蚝][Steamed Oysters w/ Garlic Vermicelli] -- #item(emoji: peper())[蒜蓉粉丝蛏子][Steamed Razor Clam w/ Garlic Vermicelli] +- #item[烤茄子][Roasted Eggplant] +- #item[蒜蓉粉丝生蚝][Steamed Oysters w/ Garlic Vermicelli] +- #item[蒜蓉粉丝蛏子][Steamed Razor Clam w/ Garlic Vermicelli] #cuisine[日韩料理][Japanese & Korean Cuisine] - #item[韩式拌饭][Bibimbap] @@ -116,7 +114,7 @@ - #item[泰式咖喱蟹][Thai Crab Curry] - #item[泰式柠檬虾][Thai Lemon Shrimp] - #item[泰式青柠檬蒸鱼][Thai Steamed Fish w/ Lime] -- #item(emoji: peper())[泰式酸辣鸡爪][Thai Cold Chicken Feet Salad] +- #item[泰式酸辣鸡爪][Thai Cold Chicken Feet Salad] - #item[蒜蓉通心菜][Water Spinach Stir-Fry w/ Garlic] - #item[柠檬鸡胸肉 (融合菜)][Lemon Chicken Breast (Fusion Cuisine)] - #item[冬阴功][Tom Yum Goong] @@ -127,9 +125,9 @@ #cuisine[凉菜][Cold Dishes] - #item[老醋花生][Pickled Peanuts w/ Vinegar & Onion] -- #item(emoji: peper())[凉拌鸡丝][Shredded Chicken Salad] +- #item[凉拌鸡丝][Shredded Chicken Salad] - #item[凉拌苦瓜][Bitter Melon Salad] -- #item(emoji: peper())[呛毛肚][Cold Spicy Beef Omasum Tripe] +- #item[呛毛肚][Cold Spicy Beef Omasum Tripe] - #item[凉拌苦菊][Endive Salad] - #item[凉拌黄瓜][Shredded Cucumber w/ Sauce] - #item[皮蛋豆腐][Chilled Tofu w/ Century Egg] @@ -159,5 +157,5 @@ #cuisine[饮品][Drinks] - #item[港式冻柠茶][Hong Kong Style Iced Lemon Tea] -- #item(emoji: [🍸])[莫吉托][Mojito] -- #item(emoji: [🍸])[猕猴桃莫吉托][Kiwi Mojito] +- #item[莫吉托][Mojito] +- #item[猕猴桃莫吉托][Kiwi Mojito]