Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
cu1ch3n committed Apr 3, 2024
1 parent d2dfd7f commit aaf5d96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 53 deletions.
52 changes: 21 additions & 31 deletions lib/caidan.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]

Expand Down Expand Up @@ -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
Expand All @@ -164,29 +156,27 @@
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]日") ]
linebreak()
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]
}
42 changes: 20 additions & 22 deletions main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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]

0 comments on commit aaf5d96

Please sign in to comment.