Skip to content

Commit

Permalink
chore: upgrade template
Browse files Browse the repository at this point in the history
  • Loading branch information
Enter-tainer committed Dec 20, 2024
1 parent 4527343 commit 6c8cde0
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 290 deletions.
13 changes: 11 additions & 2 deletions oi-wiki-export-typst/constants.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@
#let RAW_EM = 1.125em

// Page dimensions minus margin
#let VISIBLE_WIDTH = 21cm - 1in
#let VISIBLE_HEIGHT = 29.7cm - 1.5in
#let serif-font = (
"New Computer Modern",
"Noto Serif CJK SC",
"Source Han Serif SC",
)
#let sans-font = (
"New Computer Modern",
"Noto Sans CJK SC",
"Source Han Sans SC",
)
#let emph-font = ("New Computer Modern", "LXGW Wenkai")
91 changes: 43 additions & 48 deletions oi-wiki-export-typst/oi-wiki-export.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#import "constants.typ": *
#import "oi-wiki.typ": page-header
/* END imports */
#show ref: it => {
if query(it.target).len() == 0 {
return text(fill: red, "<未找到引用" + str(it.target) + ">")
}
it
}

/* BEGIN meta */
#set text(
Expand All @@ -16,27 +22,33 @@
#set page(
header: none,
paper: "a4",
margin: (top: .8in, inside: .4in, bottom: .7in, outside: .6in),
header-ascent: .3in,
fill: luma(95%),
)

#align(center + horizon)[
// OI-Wiki logo
#image.decode("<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 3 1 9l11 6 9-4.91V17h2V9M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82Z\"></path></svg>", height: 4cm)
#image.decode(
"<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 3 1 9l11 6 9-4.91V17h2V9M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82Z\"></path></svg>",
height: 4cm,
)
#text(
25pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
weight: 700,
)[OI Wiki (Beta)]
#v(4cm)
#text(
18pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
)[
OI Wiki 项目组

#datetime.today().display("[year] 年 [month padding:none] 月 [day padding:none] 日")
#(
datetime
.today()
.display("[year] 年 [month padding:none] 月 [day padding:none] 日")
)
]
]

Expand All @@ -56,7 +68,7 @@

#set text(
ROOT_EM,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
)

#set par(
Expand All @@ -66,13 +78,16 @@
// issues: https://github.com/typst/typst/issues/311
// https://github.com/typst/typst/issues/1410
// first-line-indent: 2em,
linebreaks: "optimized",
justify: true,
)
#show raw.where(block: true): set par(justify: false)

#set block(spacing: .8em)

#set strong(delta: 0)
#show strong: set text(
font: ("New Computer Modern", "Noto Sans CJK SC"),
font: sans-font,
// New Computer Modern: 400 |----->700
// Noto Sans CJK: 400 500<-| 700
// DejaVu Sans Mono: 400 |----->700
Expand All @@ -82,75 +97,56 @@
)

#set heading(numbering: "1.1")
#show heading: set block(spacing: 0em)
#show heading: set text(
font: ("New Computer Modern", "Noto Sans CJK SC"),
font: sans-font,
weight: 551,
)
#show heading.where(level: 1): set text(25pt)
#show heading.where(level: 2): set text(20pt)
#show heading.where(level: 3): set text(17pt)
#show heading.where(level: 4): set text(14pt)
#show heading.where(level: 5): set text(12pt)
#show heading.where(level: 6): set text(10pt)
#show heading: it => {
// NOTE: dynamic spacing?
// v(1fr, weak: true)
v(1.4em)
it
v(.2em)
}
#show heading.where(level: 1): set text(18pt)
#show heading.where(level: 2): it => {
v(2em)
align(center)[#it]
v(2em)
set text(16pt)
align(center, it)
}
#show heading.where(level: 3): set text(14pt)
#show heading.where(level: 4): set text(12pt)
#show heading.where(level: 5): set text(11pt)
#show heading.where(level: 6): set text(10pt)

#show emph: set text(
font: ("New Computer Modern", "LXGW Wenkai")
)
#show emph: set text(font: emph-font)

#show math.equation: set text(
font: ("New Computer Modern Math", "LXGW Wenkai")
)
#show math.equation: set text(font: ("New Computer Modern Math", "LXGW Wenkai"))

#show raw: set text(
RAW_EM,
font: ("DejaVu Sans Mono", "LXGW Wenkai"),
)

#show raw.where(block: false): it => highlight(
fill: luma(95%),
it
it,
)
/* END article formatting */

/* BEGIN outline */
#show outline.entry.where(
level: 1
): it => {
v(20pt, weak: true)
text(14pt)[#strong(it)]
#show outline.entry.where(level: 1): it => {
v(2em, weak: true)
text(12pt, font: sans-font, it)
}

#outline(indent: auto)
#outline(indent: 2em)
/* END outline */

/* BEGIN main */
#set page(
header: page-header
)
#set page(header: page-header)

#counter(page).update(1)

#show heading.where(level: 1): it => {
set text(
25pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
weight: 700,
)
set par(
first-line-indent: 0em,
)
set par(first-line-indent: 0em)

align(horizon)[
#counter(heading).display("一")章
Expand All @@ -176,7 +172,7 @@
#show list: set block(width: 100%)
#set enum(
indent: 1em,
body-indent: -.5em -.278em + 1em,
body-indent: -.5em - .278em + 1em,
)
#show enum: set block(width: 100%)

Expand All @@ -185,7 +181,6 @@

#show footnote.entry: it => {
set text(9pt)
show parbreak: none
it
}

Expand All @@ -202,6 +197,6 @@

#align(
center + horizon,
text(17pt)[https://oi-wiki.org]
text(17pt)[https://oi-wiki.org],
)
/* END back cover */
Loading

0 comments on commit 6c8cde0

Please sign in to comment.