Skip to content

Commit

Permalink
git pull upstream v4 -> merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thelulzy committed Jun 16, 2024
2 parents f43901b + 3e14b2b commit 8d79f92
Show file tree
Hide file tree
Showing 33 changed files with 956 additions and 110 deletions.
540 changes: 469 additions & 71 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"url": "https://github.com/jackyzha0/quartz.git"
},
"scripts": {
"quartz": "./quartz/bootstrap-cli.mjs",
"docs": "npx quartz build --serve -d docs",
"check": "tsc --noEmit && npx prettier . --check",
"format": "npx prettier . --write",
Expand All @@ -35,19 +36,19 @@
},
"dependencies": {
"@clack/prompts": "^0.7.0",
"@floating-ui/dom": "^1.6.3",
"@floating-ui/dom": "^1.6.5",
"@napi-rs/simple-git": "0.1.16",
"async-mutex": "^0.5.0",
"chalk": "^5.3.0",
"chokidar": "^3.6.0",
"cli-spinner": "^0.2.10",
"d3": "^7.8.5",
"d3": "^7.9.0",
"esbuild-sass-plugin": "^2.16.1",
"flexsearch": "0.7.43",
"github-slugger": "^2.0.0",
"globby": "^14.0.1",
"gray-matter": "^4.0.3",
"hast-util-to-html": "^9.0.0",
"hast-util-to-html": "^9.0.1",
"hast-util-to-jsx-runtime": "^2.3.0",
"hast-util-to-string": "^3.0.0",
"is-absolute-url": "^4.0.1",
Expand All @@ -57,16 +58,16 @@
"mdast-util-to-hast": "^13.1.0",
"mdast-util-to-string": "^4.0.0",
"micromorph": "^0.4.5",
"preact": "^10.19.6",
"preact-render-to-string": "^6.4.0",
"preact": "^10.22.0",
"preact-render-to-string": "^6.5.4",
"pretty-bytes": "^6.1.1",
"pretty-time": "^1.1.0",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.0.0",
"rehype-katex": "^7.0.0",
"rehype-mathjax": "^6.0.0",
"rehype-pretty-code": "^0.13.0",
"rehype-pretty-code": "^0.13.2",
"rehype-raw": "^7.0.0",
"rehype-slug": "^6.0.0",
"remark": "^15.0.1",
Expand All @@ -78,32 +79,32 @@
"remark-rehype": "^11.1.0",
"remark-smartypants": "^2.1.0",
"rfdc": "^1.3.1",
"rimraf": "^5.0.5",
"rimraf": "^5.0.7",
"serve-handler": "^6.1.5",
"shiki": "^1.2.0",
"shiki": "^1.6.0",
"source-map-support": "^0.5.21",
"to-vfile": "^8.0.0",
"toml": "^3.0.0",
"unified": "^11.0.4",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.1",
"workerpool": "^9.1.0",
"ws": "^8.15.1",
"workerpool": "^9.1.1",
"ws": "^8.17.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/cli-spinner": "^0.2.3",
"@types/d3": "^7.4.3",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.11.29",
"@types/node": "^20.12.5",
"@types/pretty-time": "^1.1.5",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.5.10",
"@types/yargs": "^17.0.32",
"esbuild": "^0.19.9",
"prettier": "^3.2.4",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
"tsx": "^4.11.2",
"typescript": "^5.4.5"
}
}
8 changes: 8 additions & 0 deletions quartz.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ const config: QuartzConfig = {
Plugin.CreatedModifiedDate({
priority: ["frontmatter", "filesystem"], // you can add 'git' here for last modified from Git but this makes the build slower
}),
Plugin.SyntaxHighlighting({
theme: {
light: "github-light",
dark: "github-dark",
},
keepBackground: false,
}),
Plugin.SyntaxHighlighting(),
Plugin.ObsidianFlavoredMarkdown({ enableInHtmlEmbed: false }),
Plugin.GitHubFlavoredMarkdown(),
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
Plugin.Latex({ renderEngine: "katex" }),
Plugin.Description(),
Plugin.Latex({ renderEngine: "katex" }),
],
filters: [Plugin.RemoveDrafts()],
emitters: [
Expand Down
9 changes: 9 additions & 0 deletions quartz/cfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export type Analytics =
host?: string
scriptSrc?: string
}
| {
provider: "posthog"
apiKey: string
host?: string
}
| {
provider: "tinylytics"
siteId: string
}

export interface GlobalConfiguration {
pageTitle: string
Expand Down
28 changes: 16 additions & 12 deletions quartz/components/RecentNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ interface Options {
title?: string
limit: number
linkToMore: SimpleSlug | false
showTags: boolean
filter: (f: QuartzPluginData) => boolean
sort: (f1: QuartzPluginData, f2: QuartzPluginData) => number
}

const defaultOptions = (cfg: GlobalConfiguration): Options => ({
limit: 3,
linkToMore: false,
showTags: true,
filter: () => true,
sort: byDateAndAlphabetical(cfg),
})
Expand Down Expand Up @@ -56,18 +58,20 @@ export default ((userOpts?: Partial<Options>) => {
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
</p>
)}
<ul class="tags">
{tags.map((tag) => (
<li>
<a
class="internal tag-link"
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
>
{tag}
</a>
</li>
))}
</ul>
{opts.showTags && (
<ul class="tags">
{tags.map((tag) => (
<li>
<a
class="internal tag-link"
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
>
{tag}
</a>
</li>
))}
</ul>
)}
</div>
</li>
)
Expand Down
5 changes: 5 additions & 0 deletions quartz/components/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import { i18n } from "../../i18n"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"

const NotFound: QuartzComponent = ({ cfg }: QuartzComponentProps) => {
// If baseUrl contains a pathname after the domain, use this as the home link
const url = new URL(`https://${cfg.baseUrl ?? "example.com"}`)
const baseDir = url.pathname

return (
<article class="popover-hint">
<h1>404</h1>
<p>{i18n(cfg.locale).pages.error.notFound}</p>
<a href={baseDir}>{i18n(cfg.locale).pages.error.home}</a>
</article>
)
}
Expand Down
4 changes: 1 addition & 3 deletions quartz/components/pages/FolderContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export default ((opts?: Partial<FolderContentOptions>) => {

return (
<div class={classes}>
<article>
<p>{content}</p>
</article>
<article>{content}</article>
<div class="page-listing">
{options.showFolderCount && (
<p>
Expand Down
27 changes: 26 additions & 1 deletion quartz/components/scripts/graph.inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
.transition()
.duration(200)
.style("opacity", 0.2)

d3.selectAll<HTMLElement, NodeData>(".node")
.filter((d) => !connectedNodes.includes(d.id))
.nodes()
.map((it) => d3.select(it.parentNode as HTMLElement).select("text"))
.forEach((it) => {
let opacity = parseFloat(it.style("opacity"))
it.transition()
.duration(200)
.attr("opacityOld", opacity)
.style("opacity", Math.min(opacity, 0.2))
})
}

// highlight links
Expand All @@ -245,6 +257,12 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
if (focusOnHover) {
d3.selectAll<HTMLElement, NodeData>(".link").transition().duration(200).style("opacity", 1)
d3.selectAll<HTMLElement, NodeData>(".node").transition().duration(200).style("opacity", 1)

d3.selectAll<HTMLElement, NodeData>(".node")
.filter((d) => !connectedNodes.includes(d.id))
.nodes()
.map((it) => d3.select(it.parentNode as HTMLElement).select("text"))
.forEach((it) => it.transition().duration(200).style("opacity", it.attr("opacityOld")))
}
const currentId = d.id
const linkNodes = d3
Expand All @@ -264,6 +282,13 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
// @ts-ignore
.call(drag(simulation))

// make tags hollow circles
node
.filter((d) => d.id.startsWith("tags/"))
.attr("stroke", color)
.attr("stroke-width", 2)
.attr("fill", "var(--light)")

// draw labels
const labels = graphNode
.append("text")
Expand Down Expand Up @@ -336,7 +361,7 @@ function renderGlobalGraph() {

document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
const slug = e.detail.url
addToVisited(slug)
addToVisited(simplifySlug(slug))
await renderGraph("graph-container", slug)

const containerIcon = document.getElementById("global-graph-icon")
Expand Down
8 changes: 8 additions & 0 deletions quartz/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import ru from "./locales/ru-RU"
import ko from "./locales/ko-KR"
import zh from "./locales/zh-CN"
import vi from "./locales/vi-VN"
import pt from "./locales/pt-BR"
import hu from "./locales/hu-HU"
import fa from "./locales/fa-IR"
import pl from "./locales/pl-PL"

export const TRANSLATIONS = {
"en-US": en,
Expand Down Expand Up @@ -50,6 +54,10 @@ export const TRANSLATIONS = {
"ko-KR": ko,
"zh-CN": zh,
"vi-VN": vi,
"pt-BR": pt,
"hu-HU": hu,
"fa-IR": fa,
"pl-PL": pl,
} as const

export const defaultTranslation = "en-US"
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/ar-SA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
error: {
title: "غير موجود",
notFound: "إما أن هذه الصفحة خاصة أو غير موجودة.",
home: "العوده للصفحة الرئيسية",
},
folderContent: {
folder: "مجلد",
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/de-DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
error: {
title: "Nicht gefunden",
notFound: "Diese Seite ist entweder nicht öffentlich oder existiert nicht.",
home: "Return to Homepage",
},
folderContent: {
folder: "Ordner",
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface Translation {
error: {
title: string
notFound: string
home: string
}
folderContent: {
folder: string
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
error: {
title: "Not Found",
notFound: "Either this page is private or doesn't exist.",
home: "Return to Homepage",
},
folderContent: {
folder: "Folder",
Expand Down
1 change: 1 addition & 0 deletions quartz/i18n/locales/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
error: {
title: "No se encontró.",
notFound: "Esta página es privada o no existe.",
home: "Regresar a la página principal",
},
folderContent: {
folder: "Carpeta",
Expand Down
Loading

0 comments on commit 8d79f92

Please sign in to comment.