diff --git a/quartz.config.ts b/quartz.config.ts
index d1fe18418..5868449e6 100644
--- a/quartz.config.ts
+++ b/quartz.config.ts
@@ -58,7 +58,7 @@ const config: QuartzConfig = {
Plugin.ContentPage({
head: Component.Head(),
header: [Component.PageTitle(), Component.Spacer(), Component.Darkmode()],
- body: [Component.ArticleTitle(), Component.ReadingTime(), Component.TableOfContents(), Component.Content()]
+ body: [Component.ArticleTitle(), Component.ReadingTime(), Component.TagList(), Component.TableOfContents(), Component.Content()]
})
]
},
diff --git a/quartz/components/Head.tsx b/quartz/components/Head.tsx
index 16125da38..cc9dd77db 100644
--- a/quartz/components/Head.tsx
+++ b/quartz/components/Head.tsx
@@ -1,4 +1,5 @@
import { resolveToRoot } from "../path"
+import { JSResourceToScriptElement } from "../resources"
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
function Head({ fileData, externalResources }: QuartzComponentProps) {
@@ -25,7 +26,7 @@ function Head({ fileData, externalResources }: QuartzComponentProps) {
{css.map(href => )}
- {js.filter(resource => resource.loadTime === "beforeDOMReady").map(resource => )}
+ {js.filter(resource => resource.loadTime === "beforeDOMReady").map(res => JSResourceToScriptElement(res, true))}
}
diff --git a/quartz/components/TableOfContents.tsx b/quartz/components/TableOfContents.tsx
index 531c61de1..19f26ef47 100644
--- a/quartz/components/TableOfContents.tsx
+++ b/quartz/components/TableOfContents.tsx
@@ -1,21 +1,38 @@
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
import style from "./styles/toc.scss"
-function TableOfContents({ fileData }: QuartzComponentProps) {
- if (!fileData.toc) {
- return null
- }
- return
- Table of Contents
-
-
+interface Options {
+ layout: 'modern' | 'quartz-3'
}
-TableOfContents.css = style
+const defaultOptions: Options = {
+ layout: 'quartz-3'
+}
-export default (() => TableOfContents) satisfies QuartzComponentConstructor
+export default ((opts?: Partial) => {
+ const layout = opts?.layout ?? defaultOptions.layout
+ if (layout === "modern") {
+ return function() {
+ return null // TODO (make this look like nextra)
+ }
+ } else {
+ function TableOfContents({ fileData }: QuartzComponentProps) {
+ if (!fileData.toc) {
+ return null
+ }
+
+ return
+ Table of Contents
+
+
+ }
+
+ TableOfContents.css = style
+ return TableOfContents
+ }
+}) satisfies QuartzComponentConstructor
diff --git a/quartz/components/TagList.tsx b/quartz/components/TagList.tsx
new file mode 100644
index 000000000..a462e95af
--- /dev/null
+++ b/quartz/components/TagList.tsx
@@ -0,0 +1,42 @@
+import { resolveToRoot } from "../path"
+import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
+import { slug as slugAnchor } from 'github-slugger'
+
+function TagList({ fileData }: QuartzComponentProps) {
+ const tags = fileData.frontmatter?.tags
+ const slug = fileData.slug!
+ const baseDir = resolveToRoot(slug)
+ if (tags) {
+ return
+ } else {
+ return null
+ }
+}
+
+TagList.css = `
+.tags {
+ list-style: none;
+ display: flex;
+ padding-left: 0;
+ gap: 0.4rem;
+
+ & > li {
+ display: inline-block;
+ margin: 0;
+
+ & > a {
+ border-radius: 8px;
+ border: var(--lightgray) 1px solid;
+ padding: 0.2rem 0.5rem;
+ }
+ }
+}
+`
+
+export default (() => TagList) satisfies QuartzComponentConstructor
diff --git a/quartz/components/index.ts b/quartz/components/index.ts
index 5fde7c3e3..72350fea1 100644
--- a/quartz/components/index.ts
+++ b/quartz/components/index.ts
@@ -6,6 +6,7 @@ import PageTitle from "./PageTitle"
import ReadingTime from "./ReadingTime"
import Spacer from "./Spacer"
import TableOfContents from "./TableOfContents"
+import TagList from "./TagList"
export {
ArticleTitle,
@@ -15,5 +16,6 @@ export {
PageTitle,
ReadingTime,
Spacer,
- TableOfContents
+ TableOfContents,
+ TagList
}
diff --git a/quartz/path.ts b/quartz/path.ts
index bece77048..87f1a9d63 100644
--- a/quartz/path.ts
+++ b/quartz/path.ts
@@ -1,7 +1,5 @@
import path from 'path'
-import SlugAnchor from 'github-slugger'
-
-export const slugAnchor = new SlugAnchor()
+import { slug as slugAnchor } from 'github-slugger'
function slugSegment(s: string): string {
return s.replace(/\s/g, '-')
@@ -9,7 +7,7 @@ function slugSegment(s: string): string {
export function slugify(s: string): string {
const [fp, anchor] = s.split("#", 2)
- const sluggedAnchor = anchor === undefined ? "" : "#" + slugAnchor.slug(anchor)
+ const sluggedAnchor = anchor === undefined ? "" : "#" + slugAnchor(anchor)
const withoutFileExt = fp.replace(new RegExp(path.extname(fp) + '$'), '')
const rawSlugSegments = withoutFileExt.split(path.sep)
const slugParts: string = rawSlugSegments
diff --git a/quartz/plugins/emitters/contentPage.tsx b/quartz/plugins/emitters/contentPage.tsx
index 9b789eff7..039b5ccc8 100644
--- a/quartz/plugins/emitters/contentPage.tsx
+++ b/quartz/plugins/emitters/contentPage.tsx
@@ -1,4 +1,4 @@
-import { StaticResources } from "../../resources"
+import { JSResourceToScriptElement, StaticResources } from "../../resources"
import { EmitCallback, QuartzEmitterPlugin } from "../types"
import { ProcessedContent } from "../vfile"
import { render } from "preact-render-to-string"
@@ -37,9 +37,9 @@ export const ContentPage: QuartzEmitterPlugin = (opts) => {
const pageResources: StaticResources = {
css: [baseDir + "/index.css", ...resources.css],
js: [
- { src: baseDir + "/prescript.js", loadTime: "beforeDOMReady" },
+ { src: baseDir + "/prescript.js", loadTime: "beforeDOMReady", contentType: "external" },
...resources.js,
- { src: baseDir + "/postscript.js", loadTime: "afterDOMReady", type: 'module' }
+ { src: baseDir + "/postscript.js", loadTime: "afterDOMReady", moduleType: 'module', contentType: "external" }
]
}
@@ -63,7 +63,7 @@ export const ContentPage: QuartzEmitterPlugin = (opts) => {