Skip to content

Commit

Permalink
Merge branch 'v4' of https://github.com/jackyzha0/quartz into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Darakuu committed Feb 20, 2024
2 parents 85722f8 + fc5fa48 commit a680cdb
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 28 deletions.
22 changes: 22 additions & 0 deletions docs/hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,25 @@ pages:
When `.gitlab-ci.yaml` is committed, GitLab will build and deploy the website as a GitLab Page. You can find the url under `Deploy > Pages` in the sidebar.

By default, the page is private and only visible when logged in to a GitLab account with access to the repository but can be opened in the settings under `Deploy` -> `Pages`.

## Self-Hosting

Copy the `public` directory to your web server and configure it to serve the files. You can use any web server to host your site. Since Quartz generates links that do not include the `.html` extension, you need to let your web server know how to deal with it.

### Using Nginx

Here's an example of how to do this with Nginx:

```nginx title="nginx.conf"
server {
listen 80;
server_name example.com;
root /path/to/quartz/public;
index index.html;
error_page 404 /404.html;
location / {
try_files $uri $uri.html $uri/ =404;
}
}
```
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"esbuild-sass-plugin": "^2.16.1",
"flexsearch": "0.7.43",
"github-slugger": "^2.0.0",
"globby": "^14.0.0",
"globby": "^14.0.1",
"gray-matter": "^4.0.3",
"hast-util-to-html": "^9.0.0",
"hast-util-to-jsx-runtime": "^2.3.0",
Expand All @@ -57,7 +57,7 @@
"mdast-util-to-hast": "^13.1.0",
"mdast-util-to-string": "^4.0.0",
"micromorph": "^0.4.5",
"preact": "^10.19.4",
"preact": "^10.19.5",
"preact-render-to-string": "^6.3.1",
"pretty-bytes": "^6.1.1",
"pretty-time": "^1.1.0",
Expand Down Expand Up @@ -95,7 +95,7 @@
"@types/d3": "^7.4.3",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.11.16",
"@types/node": "^20.11.19",
"@types/pretty-time": "^1.1.5",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.5.10",
Expand Down
4 changes: 2 additions & 2 deletions quartz/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {

const release = await mut.acquire()
perf.addEvent("clean")
await rimraf(output)
await rimraf(path.join(output, "*"), { glob: true })
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)

perf.addEvent("glob")
Expand Down Expand Up @@ -375,7 +375,7 @@ async function rebuildFromEntrypoint(

// TODO: we can probably traverse the link graph to figure out what's safe to delete here
// instead of just deleting everything
await rimraf(argv.output)
await rimraf(path.join(argv.output, ".*"), { glob: true })
await emitContent(ctx, filteredContent)
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
} catch (err) {
Expand Down
4 changes: 4 additions & 0 deletions quartz/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Translation, CalloutTranslation } from "./locales/definition"
import en from "./locales/en-US"
import fr from "./locales/fr-FR"
import it from "./locales/it-IT"
import ja from "./locales/ja-JP"
import de from "./locales/de-DE"
import nl from "./locales/nl-NL"
Expand All @@ -10,10 +11,12 @@ import ar from "./locales/ar-SA"
import uk from "./locales/uk-UA"
import ru from "./locales/ru-RU"
import ko from "./locales/ko-KR"
import zh from "./locales/zh-CN"

export const TRANSLATIONS = {
"en-US": en,
"fr-FR": fr,
"it-IT": it,
"ja-JP": ja,
"de-DE": de,
"nl-NL": nl,
Expand Down Expand Up @@ -44,6 +47,7 @@ export const TRANSLATIONS = {
"uk-UA": uk,
"ru-RU": ru,
"ko-KR": ko,
"zh-CN": zh,
} as const

export const defaultTranslation = "en-US"
Expand Down
83 changes: 83 additions & 0 deletions quartz/i18n/locales/it-IT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Translation } from "./definition"

export default {
propertyDefaults: {
title: "Senza titolo",
description: "Nessuna descrizione",
},
components: {
callout: {
note: "Nota",
abstract: "Astratto",
info: "Info",
todo: "Da fare",
tip: "Consiglio",
success: "Completato",
question: "Domanda",
warning: "Attenzione",
failure: "Errore",
danger: "Pericolo",
bug: "Bug",
example: "Esempio",
quote: "Citazione",
},
backlinks: {
title: "Link entranti",
noBacklinksFound: "Nessun link entrante",
},
themeToggle: {
lightMode: "Tema chiaro",
darkMode: "Tema scuro",
},
explorer: {
title: "Esplora",
},
footer: {
createdWith: "Creato con",
},
graph: {
title: "Vista grafico",
},
recentNotes: {
title: "Note recenti",
seeRemainingMore: ({ remaining }) => `Vedi ${remaining} altro →`,
},
transcludes: {
transcludeOf: ({ targetSlug }) => `Transclusione di ${targetSlug}`,
linkToOriginal: "Link all'originale",
},
search: {
title: "Cerca",
searchBarPlaceholder: "Cerca qualcosa",
},
tableOfContents: {
title: "Tabella dei contenuti",
},
contentMeta: {
readingTime: ({ minutes }) => `${minutes} minuti`,
},
},
pages: {
rss: {
recentNotes: "Note recenti",
lastFewNotes: ({ count }) => `Ultime ${count} note`,
},
error: {
title: "Non trovato",
notFound: "Questa pagina è privata o non esiste.",
},
folderContent: {
folder: "Cartella",
itemsUnderFolder: ({ count }) =>
count === 1 ? "1 oggetto in questa cartella" : `${count} oggetti in questa cartella.`,
},
tagContent: {
tag: "Etichetta",
tagIndex: "Indice etichette",
itemsUnderTag: ({ count }) =>
count === 1 ? "1 oggetto con questa etichetta" : `${count} oggetti con questa etichetta.`,
showingFirst: ({ count }) => `Prime ${count} etichette.`,
totalTags: ({ count }) => `Trovate ${count} etichette totali.`,
},
},
} as const satisfies Translation
4 changes: 2 additions & 2 deletions quartz/i18n/locales/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ export default {
},
folderContent: {
folder: "폴더",
itemsUnderFolder: ({ count }) => `${count}건의 페이지`,
itemsUnderFolder: ({ count }) => `${count}건의 항목`,
},
tagContent: {
tag: "태그",
tagIndex: "태그 목록",
itemsUnderTag: ({ count }) => `${count}건의 페이지`,
itemsUnderTag: ({ count }) => `${count}건의 항목`,
showingFirst: ({ count }) => `처음 ${count}개의 태그`,
totalTags: ({ count }) => `총 ${count}개의 태그를 찾았습니다.`,
},
Expand Down
81 changes: 81 additions & 0 deletions quartz/i18n/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Translation } from "./definition"

export default {
propertyDefaults: {
title: "无题",
description: "无描述",
},
components: {
callout: {
note: "笔记",
abstract: "摘要",
info: "提示",
todo: "待办",
tip: "提示",
success: "成功",
question: "问题",
warning: "警告",
failure: "失败",
danger: "危险",
bug: "错误",
example: "示例",
quote: "引用",
},
backlinks: {
title: "反向链接",
noBacklinksFound: "无法找到反向链接",
},
themeToggle: {
lightMode: "亮色模式",
darkMode: "暗色模式",
},
explorer: {
title: "探索",
},
footer: {
createdWith: "Created with",
},
graph: {
title: "关系图谱",
},
recentNotes: {
title: "最近的笔记",
seeRemainingMore: ({ remaining }) => `查看更多${remaining}篇笔记 →`,
},
transcludes: {
transcludeOf: ({ targetSlug }) => `包含${targetSlug}`,
linkToOriginal: "指向原始笔记的链接",
},
search: {
title: "搜索",
searchBarPlaceholder: "搜索些什么",
},
tableOfContents: {
title: "目录",
},
contentMeta: {
readingTime: ({ minutes }) => `${minutes}分钟阅读`,
},
},
pages: {
rss: {
recentNotes: "最近的笔记",
lastFewNotes: ({ count }) => `最近的${count}条笔记`,
},
error: {
title: "无法找到",
notFound: "私有笔记或笔记不存在。",
},
folderContent: {
folder: "文件夹",
itemsUnderFolder: ({ count }) => `此文件夹下有${count}条笔记。`,
},
tagContent: {
tag: "标签",
tagIndex: "标签索引",
itemsUnderTag: ({ count }) => `此标签下有${count}条笔记。`,
showingFirst: ({ count }) => `显示前${count}个标签。`,
totalTags: ({ count }) => `总共有${count}个标签。`,
},
},
} as const satisfies Translation
23 changes: 20 additions & 3 deletions quartz/plugins/emitters/tagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,26 @@ export const TagPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOpts)
getQuartzComponents() {
return [Head, Header, Body, ...header, ...beforeBody, pageBody, ...left, ...right, Footer]
},
async getDependencyGraph(ctx, _content, _resources) {
// TODO implement
return new DepGraph<FilePath>()
async getDependencyGraph(ctx, content, _resources) {
const graph = new DepGraph<FilePath>()

for (const [_tree, file] of content) {
const sourcePath = file.data.filePath!
const tags = (file.data.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes)
// if the file has at least one tag, it is used in the tag index page
if (tags.length > 0) {
tags.push("index")
}

for (const tag of tags) {
graph.addEdge(
sourcePath,
joinSegments(ctx.argv.output, "tags", tag + ".html") as FilePath,
)
}
}

return graph
},
async emit(ctx, content, resources): Promise<FilePath[]> {
const fps: FilePath[] = []
Expand Down
Loading

0 comments on commit a680cdb

Please sign in to comment.