Compare commits
1 Commits
v4
...
feat/previ
Author | SHA1 | Date | |
---|---|---|---|
|
a86c981e05 |
33
.github/workflows/ci.yaml
vendored
33
.github/workflows/ci.yaml
vendored
@ -7,7 +7,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v4
|
- v4
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
@ -19,17 +18,17 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 18
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.npm
|
path: ~/.npm
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
@ -47,26 +46,8 @@ jobs:
|
|||||||
- name: Ensure Quartz builds, check bundle info
|
- name: Ensure Quartz builds, check bundle info
|
||||||
run: npx quartz build --bundleInfo
|
run: npx quartz build --bundleInfo
|
||||||
|
|
||||||
publish-tag:
|
|
||||||
if: ${{ github.repository == 'jackyzha0/quartz' && github.ref == 'refs/heads/v4' }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Setup Node
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
- name: Get package version
|
|
||||||
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
|
||||||
- name: Create release tag
|
- name: Create release tag
|
||||||
uses: pkgdeps/git-tag-action@v3
|
uses: Klemensas/action-autotag@stable
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
github_repo: ${{ github.repository }}
|
tag_prefix: "v"
|
||||||
version: ${{ env.PACKAGE_VERSION }}
|
|
||||||
git_commit_sha: ${{ github.sha }}
|
|
||||||
git_tag_prefix: "v"
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
v20.9.0
|
|
@ -129,11 +129,11 @@ export default (() => {
|
|||||||
return <button id="btn">Click me</button>
|
return <button id="btn">Click me</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
YourComponent.beforeDOMLoaded = `
|
YourComponent.beforeDOM = `
|
||||||
console.log("hello from before the page loads!")
|
console.log("hello from before the page loads!")
|
||||||
`
|
`
|
||||||
|
|
||||||
YourComponent.afterDOMLoaded = `
|
YourComponent.afterDOM = `
|
||||||
document.getElementById('btn').onclick = () => {
|
document.getElementById('btn').onclick = () => {
|
||||||
alert('button clicked!')
|
alert('button clicked!')
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ export default (() => {
|
|||||||
return <button id="btn">Click me</button>
|
return <button id="btn">Click me</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
YourComponent.afterDOMLoaded = script
|
YourComponent.afterDOM = script
|
||||||
return YourComponent
|
return YourComponent
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
```
|
```
|
||||||
|
@ -53,12 +53,12 @@ All transformer plugins must define at least a `name` field to register the plug
|
|||||||
|
|
||||||
Normally for both `remark` and `rehype`, you can find existing plugins that you can use to . If you'd like to create your own `remark` or `rehype` plugin, checkout the [guide to creating a plugin](https://unifiedjs.com/learn/guide/create-a-plugin/) using `unified` (the underlying AST parser and transformer library).
|
Normally for both `remark` and `rehype`, you can find existing plugins that you can use to . If you'd like to create your own `remark` or `rehype` plugin, checkout the [guide to creating a plugin](https://unifiedjs.com/learn/guide/create-a-plugin/) using `unified` (the underlying AST parser and transformer library).
|
||||||
|
|
||||||
A good example of a transformer plugin that borrows from the `remark` and `rehype` ecosystems is the [[plugins/Latex|Latex]] plugin:
|
A good example of a transformer plugin that borrows from the `remark` and `rehype` ecosystems is the [[Latex]] plugin:
|
||||||
|
|
||||||
```ts title="quartz/plugins/transformers/latex.ts"
|
```ts title="quartz/plugins/transformers/latex.ts"
|
||||||
import remarkMath from "remark-math"
|
import remarkMath from "remark-math"
|
||||||
import rehypeKatex from "rehype-katex"
|
import rehypeKatex from "rehype-katex"
|
||||||
import rehypeMathjax from "rehype-mathjax/svg"
|
import rehypeMathjax from "rehype-mathjax/svg.js"
|
||||||
import { QuartzTransformerPlugin } from "../types"
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
@ -84,14 +84,10 @@ export const Latex: QuartzTransformerPlugin<Options> = (opts?: Options) => {
|
|||||||
externalResources() {
|
externalResources() {
|
||||||
if (engine === "katex") {
|
if (engine === "katex") {
|
||||||
return {
|
return {
|
||||||
css: [
|
css: ["https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css"],
|
||||||
// base css
|
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css",
|
|
||||||
],
|
|
||||||
js: [
|
js: [
|
||||||
{
|
{
|
||||||
// fix copy behaviour: https://github.com/KaTeX/KaTeX/blob/main/contrib/copy-tex/README.md
|
src: "https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/copy-tex.min.js",
|
||||||
src: "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/copy-tex.min.js",
|
|
||||||
loadTime: "afterDOMReady",
|
loadTime: "afterDOMReady",
|
||||||
contentType: "external",
|
contentType: "external",
|
||||||
},
|
},
|
||||||
@ -260,11 +256,11 @@ export const ContentPage: QuartzEmitterPlugin = () => {
|
|||||||
...defaultContentPageLayout,
|
...defaultContentPageLayout,
|
||||||
pageBody: Content(),
|
pageBody: Content(),
|
||||||
}
|
}
|
||||||
const { head, header, beforeBody, pageBody, afterBody, left, right, footer } = layout
|
const { head, header, beforeBody, pageBody, left, right, footer } = layout
|
||||||
return {
|
return {
|
||||||
name: "ContentPage",
|
name: "ContentPage",
|
||||||
getQuartzComponents() {
|
getQuartzComponents() {
|
||||||
return [head, ...header, ...beforeBody, pageBody, ...afterBody, ...left, ...right, footer]
|
return [head, ...header, ...beforeBody, pageBody, ...left, ...right, footer]
|
||||||
},
|
},
|
||||||
async emit(ctx, content, resources, emit): Promise<FilePath[]> {
|
async emit(ctx, content, resources, emit): Promise<FilePath[]> {
|
||||||
const cfg = ctx.cfg.configuration
|
const cfg = ctx.cfg.configuration
|
||||||
|
@ -48,4 +48,4 @@ Here are the main types of slugs with a rough description of each type of path:
|
|||||||
- `SimpleSlug`: cannot be relative and shouldn't have `/index` as an ending or a file extension. It _can_ however have a trailing slash to indicate a folder path.
|
- `SimpleSlug`: cannot be relative and shouldn't have `/index` as an ending or a file extension. It _can_ however have a trailing slash to indicate a folder path.
|
||||||
- `RelativeURL`: must start with `.` or `..` to indicate it's a relative URL. Shouldn't have `/index` as an ending or a file extension but can contain a trailing slash.
|
- `RelativeURL`: must start with `.` or `..` to indicate it's a relative URL. Shouldn't have `/index` as an ending or a file extension but can contain a trailing slash.
|
||||||
|
|
||||||
To get a clearer picture of how these relate to each other, take a look at the path tests in `quartz/util/path.test.ts`.
|
To get a clearer picture of how these relate to each other, take a look at the path tests in `quartz/path.test.ts`.
|
||||||
|
@ -29,7 +29,6 @@ Some common frontmatter fields that are natively supported by Quartz:
|
|||||||
|
|
||||||
- `title`: Title of the page. If it isn't provided, Quartz will use the name of the file as the title.
|
- `title`: Title of the page. If it isn't provided, Quartz will use the name of the file as the title.
|
||||||
- `description`: Description of the page used for link previews.
|
- `description`: Description of the page used for link previews.
|
||||||
- `permalink`: A custom URL for the page that will remain constant even if the path to the file changes.
|
|
||||||
- `aliases`: Other names for this note. This is a list of strings.
|
- `aliases`: Other names for this note. This is a list of strings.
|
||||||
- `tags`: Tags for this note.
|
- `tags`: Tags for this note.
|
||||||
- `draft`: Whether to publish the page or not. This is one way to make [[private pages|pages private]] in Quartz.
|
- `draft`: Whether to publish the page or not. This is one way to make [[private pages|pages private]] in Quartz.
|
||||||
@ -39,7 +38,3 @@ Some common frontmatter fields that are natively supported by Quartz:
|
|||||||
|
|
||||||
When your Quartz is at a point you're happy with, you can save your changes to GitHub.
|
When your Quartz is at a point you're happy with, you can save your changes to GitHub.
|
||||||
First, make sure you've [[setting up your GitHub repository|already setup your GitHub repository]] and then do `npx quartz sync`.
|
First, make sure you've [[setting up your GitHub repository|already setup your GitHub repository]] and then do `npx quartz sync`.
|
||||||
|
|
||||||
## Customization
|
|
||||||
|
|
||||||
Frontmatter parsing for `title`, `tags`, `aliases` and `cssclasses` is a functionality of the [[Frontmatter]] plugin, `date` is handled by the [[CreatedModifiedDate]] plugin and `description` by the [[Description]] plugin. See the plugin pages for customization options.
|
|
||||||
|
@ -25,21 +25,16 @@ This part of the configuration concerns anything that can affect the whole site.
|
|||||||
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
||||||
- `analytics`: what to use for analytics on your site. Values can be
|
- `analytics`: what to use for analytics on your site. Values can be
|
||||||
- `null`: don't use analytics;
|
- `null`: don't use analytics;
|
||||||
- `{ provider: 'google', tagId: '<your-google-tag>' }`: use Google Analytics;
|
- `{ provider: 'plausible' }`: use [Plausible](https://plausible.io/), a privacy-friendly alternative to Google Analytics; or
|
||||||
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: '<your-plausible-host>' }` (self-hosted): use [Plausible](https://plausible.io/);
|
- `{ provider: 'google', tagId: <your-google-tag> }`: use Google Analytics
|
||||||
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>' }`: use [Umami](https://umami.is/);
|
|
||||||
- `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id' }` (managed) or `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id', host: 'my-goatcounter-domain.com', scriptSrc: 'https://my-url.to/counter.js' }` (self-hosted) use [GoatCounter](https://goatcounter.com);
|
|
||||||
- `{ provider: 'posthog', apiKey: '<your-posthog-project-apiKey>', host: '<your-posthog-host>' }`: use [Posthog](https://posthog.com/);
|
|
||||||
- `{ provider: 'tinylytics', siteId: '<your-site-id>' }`: use [Tinylytics](https://tinylytics.app/);
|
|
||||||
- `{ provider: 'cabin' }` or `{ provider: 'cabin', host: 'https://cabin.example.com' }` (custom domain): use [Cabin](https://withcabin.com);
|
|
||||||
- `locale`: used for [[i18n]] and date formatting
|
- `locale`: used for [[i18n]] and date formatting
|
||||||
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
||||||
- This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`.
|
- This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`
|
||||||
- Note that Quartz 4 will avoid using this as much as possible and use relative URLs whenever it can to make sure your site works no matter _where_ you end up actually deploying it.
|
- Note that Quartz 4 will avoid using this as much as possible and use relative URLs whenever it can to make sure your site works no matter _where_ you end up actually deploying it.
|
||||||
- `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details.
|
- `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details.
|
||||||
- `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings.
|
- `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings.
|
||||||
- `theme`: configure how the site looks.
|
- `theme`: configure how the site looks.
|
||||||
- `cdnCaching`: If `true` (default), use Google CDN to cache the fonts. This will generally will be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained.
|
- `cdnCaching`: Whether to use Google CDN to cache the fonts (generally will be faster). Disable this if you want Quartz to be self-contained. Default to `true`
|
||||||
- `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here.
|
- `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here.
|
||||||
- `header`: Font to use for headers
|
- `header`: Font to use for headers
|
||||||
- `code`: Font for inline and block quotes.
|
- `code`: Font for inline and block quotes.
|
||||||
@ -53,7 +48,6 @@ This part of the configuration concerns anything that can affect the whole site.
|
|||||||
- `secondary`: link colour, current [[graph view|graph]] node
|
- `secondary`: link colour, current [[graph view|graph]] node
|
||||||
- `tertiary`: hover states and visited [[graph view|graph]] nodes
|
- `tertiary`: hover states and visited [[graph view|graph]] nodes
|
||||||
- `highlight`: internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
|
- `highlight`: internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
|
||||||
- `textHighlight`: markdown highlighted text background
|
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
@ -61,7 +55,7 @@ You can think of Quartz plugins as a series of transformations over content.
|
|||||||
|
|
||||||
![[quartz transform pipeline.png]]
|
![[quartz transform pipeline.png]]
|
||||||
|
|
||||||
```ts title="quartz.config.ts"
|
```ts
|
||||||
plugins: {
|
plugins: {
|
||||||
transformers: [...],
|
transformers: [...],
|
||||||
filters: [...],
|
filters: [...],
|
||||||
@ -69,40 +63,22 @@ plugins: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- [[tags/plugin/transformer|Transformers]] **map** over content (e.g. parsing frontmatter, generating a description)
|
- [[making plugins#Transformers|Transformers]] **map** over content (e.g. parsing frontmatter, generating a description)
|
||||||
- [[tags/plugin/filter|Filters]] **filter** content (e.g. filtering out drafts)
|
- [[making plugins#Filters|Filters]] **filter** content (e.g. filtering out drafts)
|
||||||
- [[tags/plugin/emitter|Emitters]] **reduce** over content (e.g. creating an RSS feed or pages that list all files with a specific tag)
|
- [[making plugins#Emitters|Emitters]] **reduce** over content (e.g. creating an RSS feed or pages that list all files with a specific tag)
|
||||||
|
|
||||||
You can customize the behaviour of Quartz by adding, removing and reordering plugins in the `transformers`, `filters` and `emitters` fields.
|
By adding, removing, and reordering plugins from the `tranformers`, `filters`, and `emitters` fields, you can customize the behaviour of Quartz.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> Each node is modified by every transformer _in order_. Some transformers are position sensitive, so you may need to pay particular attention to whether they need to come before or after certain other plugins.
|
> Each node is modified by every transformer _in order_. Some transformers are position-sensitive so you may need to take special note of whether it needs come before or after any other particular plugins.
|
||||||
|
|
||||||
You should take care to add the plugin to the right entry corresponding to its plugin type. For example, to add the [[ExplicitPublish]] plugin (a [[tags/plugin/filter|Filter]]), you would add the following line:
|
Additionally, plugins may also have their own configuration settings that you can pass in. For example, the [[Latex]] plugin allows you to pass in a field specifying the `renderEngine` to choose between Katex and MathJax.
|
||||||
|
|
||||||
```ts title="quartz.config.ts"
|
```ts
|
||||||
filters: [
|
|
||||||
...
|
|
||||||
Plugin.ExplicitPublish(),
|
|
||||||
...
|
|
||||||
],
|
|
||||||
```
|
|
||||||
|
|
||||||
To remove a plugin, you should remove all occurrences of it in the `quartz.config.ts`.
|
|
||||||
|
|
||||||
To customize plugins further, some plugins may also have their own configuration settings that you can pass in. If you do not pass in a configuration, the plugin will use its default settings.
|
|
||||||
|
|
||||||
For example, the [[plugins/Latex|Latex]] plugin allows you to pass in a field specifying the `renderEngine` to choose between Katex and MathJax.
|
|
||||||
|
|
||||||
```ts title="quartz.config.ts"
|
|
||||||
transformers: [
|
transformers: [
|
||||||
Plugin.FrontMatter(), // use default options
|
Plugin.FrontMatter(), // uses default options
|
||||||
Plugin.Latex({ renderEngine: "katex" }), // set some custom options
|
Plugin.Latex({ renderEngine: "katex" }), // specify some options
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
Some plugins are included by default in the[ `quartz.config.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz.config.ts), but there are more available.
|
If you'd like to make your own plugins, read the guide on [[making plugins]] for more information.
|
||||||
|
|
||||||
You can see a list of all plugins and their configuration options [[tags/plugin|here]].
|
|
||||||
|
|
||||||
If you'd like to make your own plugins, see the [[making plugins|making custom plugins]] guide.
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: LaTeX
|
|
||||||
tags:
|
tags:
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time.
|
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time.
|
||||||
@ -39,20 +38,6 @@ a & b & c
|
|||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
$$
|
|
||||||
\begin{array}{rll}
|
|
||||||
E \psi &= H\psi & \text{Expanding the Hamiltonian Operator} \\
|
|
||||||
&= -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} \psi + \frac{1}{2}m\omega x^2 \psi & \text{Using the ansatz $\psi(x) = e^{-kx^2}f(x)$, hoping to cancel the $x^2$ term} \\
|
|
||||||
&= -\frac{\hbar^2}{2m} [4k^2x^2f(x)+2(-2kx)f'(x) + f''(x)]e^{-kx^2} + \frac{1}{2}m\omega x^2 f(x)e^{-kx^2} &\text{Removing the $e^{-kx^2}$ term from both sides} \\
|
|
||||||
& \Downarrow \\
|
|
||||||
Ef(x) &= -\frac{\hbar^2}{2m} [4k^2x^2f(x)-4kxf'(x) + f''(x)] + \frac{1}{2}m\omega x^2 f(x) & \text{Choosing $k=\frac{im}{2}\sqrt{\frac{\omega}{\hbar}}$ to cancel the $x^2$ term, via $-\frac{\hbar^2}{2m}4k^2=\frac{1}{2}m \omega$} \\
|
|
||||||
&= -\frac{\hbar^2}{2m} [-4kxf'(x) + f''(x)] \\
|
|
||||||
\end{array}
|
|
||||||
$$
|
|
||||||
|
|
||||||
> [!warn]
|
|
||||||
> Due to limitations in the [underlying parsing library](https://github.com/remarkjs/remark-math), block math in Quartz requires the `$$` delimiters to be on newlines like above.
|
|
||||||
|
|
||||||
### Inline Math
|
### Inline Math
|
||||||
|
|
||||||
Similarly, inline math can be rendered by delimiting math expression with a single `$`. For example, `$e^{i\pi} = -1$` produces $e^{i\pi} = -1$
|
Similarly, inline math can be rendered by delimiting math expression with a single `$`. For example, `$e^{i\pi} = -1$` produces $e^{i\pi} = -1$
|
||||||
@ -68,15 +53,11 @@ For example:
|
|||||||
- Incorrect: `I have $1 and you have $2` produces I have $1 and you have $2
|
- Incorrect: `I have $1 and you have $2` produces I have $1 and you have $2
|
||||||
- Correct: `I have \$1 and you have \$2` produces I have \$1 and you have \$2
|
- Correct: `I have \$1 and you have \$2` produces I have \$1 and you have \$2
|
||||||
|
|
||||||
### Using mhchem
|
## MathJax
|
||||||
|
|
||||||
Add the following import to the top of `quartz/plugins/transformers/latex.ts` (before all the other
|
In `quartz.config.ts`, you can configure Quartz to use [MathJax SVG rendering](https://docs.mathjax.org/en/latest/output/svg.html) by replacing `Plugin.Latex({ renderEngine: 'katex' })` with `Plugin.Latex({ renderEngine: 'mathjax' })`
|
||||||
imports):
|
|
||||||
|
|
||||||
```ts title="quartz/plugins/transformers/latex.ts"
|
|
||||||
import "katex/contrib/mhchem"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
Latex parsing is a functionality of the [[plugins/Latex|Latex]] plugin. See the plugin page for customization options.
|
- Removing Latex support: remove all instances of `Plugin.Latex()` from `quartz.config.ts`.
|
||||||
|
- Plugin: `quartz/plugins/transformers/latex.ts`
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
---
|
|
||||||
title: "Mermaid Diagrams"
|
|
||||||
tags:
|
|
||||||
- feature/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
Quartz supports Mermaid which allows you to add diagrams and charts to your notes. Mermaid supports a range of diagrams, such as [flow charts](https://mermaid.js.org/syntax/flowchart.html), [sequence diagrams](https://mermaid.js.org/syntax/sequenceDiagram.html), and [timelines](https://mermaid.js.org/syntax/timeline.html). This is enabled as a part of [[Obsidian compatibility]] and can be configured and enabled/disabled from that plugin.
|
Quartz supports Mermaid which allows you to add diagrams and charts to your notes. Mermaid supports a range of diagrams, such as [flow charts](https://mermaid.js.org/syntax/flowchart.html), [sequence diagrams](https://mermaid.js.org/syntax/sequenceDiagram.html), and [timelines](https://mermaid.js.org/syntax/timeline.html). This is enabled as a part of [[Obsidian compatibility]] and can be configured and enabled/disabled from that plugin.
|
||||||
|
|
||||||
By default, Quartz will render Mermaid diagrams to match the site theme.
|
By default, Quartz will render Mermaid diagrams to match the site theme.
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> Wondering why Mermaid diagrams may not be showing up even if you have them enabled? You may need to reorder your plugins so that [[ObsidianFlavoredMarkdown]] is _after_ [[SyntaxHighlighting]].
|
> Wondering why Mermaid diagrams may not be showing up even if you have them enabled? You may need to reorder your plugins so that `Plugin.ObsidianFlavoredMarkdown()` is _after_ `Plugin.SyntaxHighlighting()`.
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
|
@ -1,17 +1,33 @@
|
|||||||
---
|
---
|
||||||
title: "Obsidian Compatibility"
|
|
||||||
tags:
|
tags:
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
Quartz was originally designed as a tool to publish Obsidian vaults as websites. Even as the scope of Quartz has widened over time, it hasn't lost the ability to seamlessly interoperate with Obsidian.
|
Quartz was originally designed as a tool to publish Obsidian vaults as websites. Even as the scope of Quartz has widened over time, it hasn't lost the ability to seamlessly interoperate with Obsidian.
|
||||||
|
|
||||||
By default, Quartz ships with the [[ObsidianFlavoredMarkdown]] plugin, which is a transformer plugin that adds support for [Obsidian Flavored Markdown](https://help.obsidian.md/Editing+and+formatting/Obsidian+Flavored+Markdown). This includes support for features like [[wikilinks]] and [[Mermaid diagrams]].
|
By default, Quartz ships with `Plugin.ObsidianFlavoredMarkdown` which is a transformer plugin that adds support for [Obsidian Flavored Markdown](https://help.obsidian.md/Editing+and+formatting/Obsidian+Flavored+Markdown). This includes support for features like [[wikilinks]] and [[Mermaid diagrams]].
|
||||||
|
|
||||||
It also ships with support for [frontmatter parsing](https://help.obsidian.md/Editing+and+formatting/Properties) with the same fields that Obsidian uses through the [[Frontmatter]] transformer plugin.
|
It also ships with support for [frontmatter parsing](https://help.obsidian.md/Editing+and+formatting/Properties) with the same fields that Obsidian uses through the `Plugin.FrontMatter` transformer plugin.
|
||||||
|
|
||||||
Finally, Quartz also provides [[CrawlLinks]] plugin, which allows you to customize Quartz's link resolution behaviour to match Obsidian.
|
Finally, Quartz also provides `Plugin.CrawlLinks` which allows you to customize Quartz's link resolution behaviour to match Obsidian.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
This functionality is provided by the [[ObsidianFlavoredMarkdown]], [[Frontmatter]] and [[CrawlLinks]] plugins. See the plugin pages for customization options.
|
- Frontmatter parsing:
|
||||||
|
- Disabling: remove all instances of `Plugin.FrontMatter()` from `quartz.config.ts`.
|
||||||
|
- Customize default values for frontmatter: edit `quartz/plugins/transformers/frontmatter.ts`
|
||||||
|
- Obsidian Flavored Markdown:
|
||||||
|
- Disabling: remove all instances of `Plugin.ObsidianFlavoredMarkdown()` from `quartz.config.ts`
|
||||||
|
- Customizing features: `Plugin.ObsidianFlavoredMarkdown` has several other options to toggle on and off:
|
||||||
|
- `comments`: whether to enable `%%` style Obsidian comments. Defaults to `true`
|
||||||
|
- `highlight`: whether to enable `==` style highlights. Defaults to `true`
|
||||||
|
- `wikilinks`: whether to enable turning [[wikilinks]] into regular links. Defaults to `true`
|
||||||
|
- `callouts`: whether to enable [[callouts]]. Defaults to `true`
|
||||||
|
- `mermaid`: whether to enable [[Mermaid diagrams]]. Defaults to `true`
|
||||||
|
- `parseTags`: whether to try and parse tags in the content body. Defaults to `true`
|
||||||
|
- `parseArrows`: whether to try and parse arrows in the content body. Defaults to `true`.
|
||||||
|
- `enableInHtmlEmbed`: whether to try and parse Obsidian flavoured markdown in raw HTML. Defaults to `false`
|
||||||
|
- `enableYouTubeEmbed`: whether to enable embedded YouTube videos using external image Markdown syntax. Defaults to `false`
|
||||||
|
- Link resolution behaviour:
|
||||||
|
- Disabling: remove all instances of `Plugin.CrawlLinks()` from `quartz.config.ts`
|
||||||
|
- Changing link resolution preference: set `markdownLinkResolution` to one of `absolute`, `relative` or `shortest`
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
---
|
---
|
||||||
title: "OxHugo Compatibility"
|
|
||||||
tags:
|
tags:
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
[org-roam](https://www.orgroam.com/) is a plain-text personal knowledge management system for [emacs](https://en.wikipedia.org/wiki/Emacs). [ox-hugo](https://github.com/kaushalmodi/ox-hugo) is org exporter backend that exports `org-mode` files to [Hugo](https://gohugo.io/) compatible Markdown.
|
[org-roam](https://www.orgroam.com/) is a plain-text personal knowledge management system for [emacs](https://en.wikipedia.org/wiki/Emacs). [ox-hugo](https://github.com/kaushalmodi/ox-hugo) is org exporter backend that exports `org-mode` files to [Hugo](https://gohugo.io/) compatible Markdown.
|
||||||
|
|
||||||
Because the Markdown generated by ox-hugo is not pure Markdown but Hugo specific, we need to transform it to fit into Quartz. This is done by the [[OxHugoFlavoredMarkdown]] plugin. Even though this plugin was written with `ox-hugo` in mind, it should work for any Hugo specific Markdown.
|
Because the Markdown generated by ox-hugo is not pure Markdown but Hugo specific, we need to transform it to fit into Quartz. This is done by `Plugin.OxHugoFlavouredMarkdown`. Even though this [[making plugins|plugin]] was written with `ox-hugo` in mind, it should work for any Hugo specific Markdown.
|
||||||
|
|
||||||
```typescript title="quartz.config.ts"
|
```typescript title="quartz.config.ts"
|
||||||
plugins: {
|
plugins: {
|
||||||
@ -26,4 +25,15 @@ Quartz by default doesn't understand `org-roam` files as they aren't Markdown. Y
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
This functionality is provided by the [[OxHugoFlavoredMarkdown]] plugin. See the plugin page for customization options.
|
- Link resolution
|
||||||
|
- `wikilinks`: Whether to replace `{{ relref }}` with Quartz [[wikilinks]]
|
||||||
|
- `removePredefinedAnchor`: Whether to remove [pre-defined anchor set by ox-hugo](https://ox-hugo.scripter.co/doc/anchors/).
|
||||||
|
- Image handling
|
||||||
|
- `replaceFigureWithMdImg`: Whether to replace `<figure/>` with `![]()`
|
||||||
|
- Formatting
|
||||||
|
- `removeHugoShortcode`: Whether to remove hugo shortcode syntax (`{{}}`)
|
||||||
|
- `replaceOrgLatex`: Whether to replace org-mode formatting for latex fragments with what `Plugin.Latex` supports.
|
||||||
|
|
||||||
|
> [!warning]
|
||||||
|
>
|
||||||
|
> While you can use `Plugin.OxHugoFlavoredMarkdown` and `Plugin.ObsidianFlavoredMarkdown` together, it's not recommended because it might mutate the file in unexpected ways. Use with caution.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
Quartz emits an RSS feed for all the content on your site by generating an `index.xml` file that RSS readers can subscribe to. Because of the RSS spec, this requires the `baseUrl` property in your [[configuration]] to be set properly for RSS readers to pick it up properly.
|
Quartz creates an RSS feed for all the content on your site by generating an `index.xml` file that RSS readers can subscribe to. Because of the RSS spec, this requires the `baseUrl` property in your [[configuration]] to be set properly for RSS readers to pick it up properly.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
This functionality is provided by the [[ContentIndex]] plugin. See the plugin page for customization options.
|
- Remove RSS feed: set the `enableRSS` field of `Plugin.ContentIndex` in `quartz.config.ts` to be `false`.
|
||||||
|
- Change number of entries: set the `rssLimit` field of `Plugin.ContentIndex` to be the desired value. It defaults to latest 10 items.
|
||||||
|
- Use rich HTML output in RSS: set `rssFullHtml` field of `Plugin.ContentIndex` to be `true`.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Callouts
|
title: Callouts
|
||||||
tags:
|
tags:
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
Quartz supports the same Admonition-callout syntax as Obsidian.
|
Quartz supports the same Admonition-callout syntax as Obsidian.
|
||||||
@ -19,13 +19,12 @@ This includes
|
|||||||
See [documentation on supported types and syntax here](https://help.obsidian.md/Editing+and+formatting/Callouts).
|
See [documentation on supported types and syntax here](https://help.obsidian.md/Editing+and+formatting/Callouts).
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> Wondering why callouts may not be showing up even if you have them enabled? You may need to reorder your plugins so that [[ObsidianFlavoredMarkdown]] is _after_ [[SyntaxHighlighting]].
|
> Wondering why callouts may not be showing up even if you have them enabled? You may need to reorder your plugins so that `Plugin.ObsidianFlavoredMarkdown()` is _after_ `Plugin.SyntaxHighlighting()`.
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
The callouts are a functionality of the [[ObsidianFlavoredMarkdown]] plugin. See the plugin page for how to enable or disable them.
|
- Disable callouts: simply pass `callouts: false` to the plugin: `Plugin.ObsidianFlavoredMarkdown({ callouts: false })`
|
||||||
|
- Editing icons: `quartz/styles/callouts.scss`
|
||||||
You can edit the icons by customizing `quartz/styles/callouts.scss`.
|
|
||||||
|
|
||||||
### Add custom callouts
|
### Add custom callouts
|
||||||
|
|
||||||
@ -56,41 +55,50 @@ By default, custom callouts are handled by applying the `note` style. To make fa
|
|||||||
> >
|
> >
|
||||||
> > > [!example] You can even use multiple layers of nesting.
|
> > > [!example] You can even use multiple layers of nesting.
|
||||||
|
|
||||||
> [!note]
|
> [!EXAMPLE] Examples
|
||||||
> Aliases: "note"
|
>
|
||||||
|
> Aliases: example
|
||||||
|
|
||||||
> [!abstract]
|
> [!note] Notes
|
||||||
> Aliases: "abstract", "summary", "tldr"
|
>
|
||||||
|
> Aliases: note
|
||||||
|
|
||||||
> [!info]
|
> [!abstract] Summaries
|
||||||
> Aliases: "info"
|
>
|
||||||
|
> Aliases: abstract, summary, tldr
|
||||||
|
|
||||||
> [!todo]
|
> [!info] Info
|
||||||
> Aliases: "todo"
|
>
|
||||||
|
> Aliases: info, todo
|
||||||
|
|
||||||
> [!tip]
|
> [!tip] Hint
|
||||||
> Aliases: "tip", "hint", "important"
|
>
|
||||||
|
> Aliases: tip, hint, important
|
||||||
|
|
||||||
> [!success]
|
> [!success] Success
|
||||||
> Aliases: "success", "check", "done"
|
>
|
||||||
|
> Aliases: success, check, done
|
||||||
|
|
||||||
> [!question]
|
> [!question] Question
|
||||||
> Aliases: "question", "help", "faq"
|
>
|
||||||
|
> Aliases: question, help, faq
|
||||||
|
|
||||||
> [!warning]
|
> [!warning] Warning
|
||||||
> Aliases: "warning", "attention", "caution"
|
>
|
||||||
|
> Aliases: warning, caution, attention
|
||||||
|
|
||||||
> [!failure]
|
> [!failure] Failure
|
||||||
> Aliases: "failure", "missing", "fail"
|
>
|
||||||
|
> Aliases: failure, fail, missing
|
||||||
|
|
||||||
> [!danger]
|
> [!danger] Error
|
||||||
> Aliases: "danger", "error"
|
>
|
||||||
|
> Aliases: danger, error
|
||||||
|
|
||||||
> [!bug]
|
> [!bug] Bug
|
||||||
> Aliases: "bug"
|
>
|
||||||
|
> Aliases: bug
|
||||||
|
|
||||||
> [!example]
|
> [!quote] Quote
|
||||||
> Aliases: "example"
|
>
|
||||||
|
> Aliases: quote, cite
|
||||||
> [!quote]
|
|
||||||
> Aliases: "quote", "cite"
|
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
---
|
|
||||||
title: Comments
|
|
||||||
tags:
|
|
||||||
- component
|
|
||||||
---
|
|
||||||
|
|
||||||
Quartz also has the ability to hook into various providers to enable readers to leave comments on your site.
|
|
||||||
|
|
||||||
![[giscus-example.png]]
|
|
||||||
|
|
||||||
As of today, only [Giscus](https://giscus.app/) is supported out of the box but PRs to support other providers are welcome!
|
|
||||||
|
|
||||||
## Providers
|
|
||||||
|
|
||||||
### Giscus
|
|
||||||
|
|
||||||
First, make sure that the [[setting up your GitHub repository|GitHub]] repository you are using for your Quartz meets the following requirements:
|
|
||||||
|
|
||||||
1. The **repository is [public](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/setting-repository-visibility#making-a-repository-public)**, otherwise visitors will not be able to view the discussion.
|
|
||||||
2. The **[giscus](https://github.com/apps/giscus) app is installed**, otherwise visitors will not be able to comment and react.
|
|
||||||
3. The **Discussions feature is turned on** by [enabling it for your repository](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository).
|
|
||||||
|
|
||||||
Then, use the [Giscus site](https://giscus.app/#repository) to figure out what your `repoId` and `categoryId` should be. Make sure you select `Announcements` for the Discussion category.
|
|
||||||
|
|
||||||
![[giscus-repo.png]]
|
|
||||||
|
|
||||||
![[giscus-discussion.png]]
|
|
||||||
|
|
||||||
After entering both your repository and selecting the discussion category, Giscus will compute some IDs that you'll need to provide back to Quartz. You won't need to manually add the script yourself as Quartz will handle that part for you but will need these values in the next step!
|
|
||||||
|
|
||||||
![[giscus-results.png]]
|
|
||||||
|
|
||||||
Finally, in `quartz.layout.ts`, edit the `afterBody` field of `sharedPageComponents` to include the following options but with the values you got from above:
|
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
|
||||||
afterBody: [
|
|
||||||
Component.Comments({
|
|
||||||
provider: 'giscus',
|
|
||||||
options: {
|
|
||||||
// from data-repo
|
|
||||||
repo: 'jackyzha0/quartz',
|
|
||||||
// from data-repo-id
|
|
||||||
repoId: 'MDEwOlJlcG9zaXRvcnkzODcyMTMyMDg',
|
|
||||||
// from data-category
|
|
||||||
category: 'Announcements',
|
|
||||||
// from data-category-id
|
|
||||||
categoryId: 'DIC_kwDOFxRnmM4B-Xg6',
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customization
|
|
||||||
|
|
||||||
Quartz also exposes a few of the other Giscus options as well and you can provide them the same way `repo`, `repoId`, `category`, and `categoryId` are provided.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type Options = {
|
|
||||||
provider: "giscus"
|
|
||||||
options: {
|
|
||||||
repo: `${string}/${string}`
|
|
||||||
repoId: string
|
|
||||||
category: string
|
|
||||||
categoryId: string
|
|
||||||
|
|
||||||
// how to map pages -> discussions
|
|
||||||
// defaults to 'url'
|
|
||||||
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
|
|
||||||
|
|
||||||
// use strict title matching
|
|
||||||
// defaults to true
|
|
||||||
strict?: boolean
|
|
||||||
|
|
||||||
// whether to enable reactions for the main post
|
|
||||||
// defaults to true
|
|
||||||
reactionsEnabled?: boolean
|
|
||||||
|
|
||||||
// where to put the comment input box relative to the comments
|
|
||||||
// defaults to 'bottom'
|
|
||||||
inputPosition?: "top" | "bottom"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
@ -42,7 +42,7 @@ When passing in your own options, you can omit any or all of these fields if you
|
|||||||
|
|
||||||
Want to customize it even more?
|
Want to customize it even more?
|
||||||
|
|
||||||
- Removing explorer: remove `Component.Explorer()` from `quartz.layout.ts`
|
- Removing table of contents: remove `Component.Explorer()` from `quartz.layout.ts`
|
||||||
- (optional): After removing the explorer component, you can move the [[table of contents | Table of Contents]] component back to the `left` part of the layout
|
- (optional): After removing the explorer component, you can move the [[table of contents | Table of Contents]] component back to the `left` part of the layout
|
||||||
- Changing `sort`, `filter` and `map` behavior: explained in [[#Advanced customization]]
|
- Changing `sort`, `filter` and `map` behavior: explained in [[#Advanced customization]]
|
||||||
- Component:
|
- Component:
|
||||||
@ -61,7 +61,7 @@ export class FileNode {
|
|||||||
children: FileNode[] // children of current node
|
children: FileNode[] // children of current node
|
||||||
name: string // last part of slug
|
name: string // last part of slug
|
||||||
displayName: string // what actually should be displayed in the explorer
|
displayName: string // what actually should be displayed in the explorer
|
||||||
file: QuartzPluginData | null // if node is a file, this is the file's metadata. See `QuartzPluginData` for more detail
|
file: QuartzPluginData | null // set if node is a file, see `QuartzPluginData` for more detail
|
||||||
depth: number // depth of current node
|
depth: number // depth of current node
|
||||||
|
|
||||||
... // rest of implementation
|
... // rest of implementation
|
||||||
@ -167,19 +167,6 @@ Component.Explorer({
|
|||||||
|
|
||||||
You can customize this by changing the entries of the `omit` set. Simply add all folder or file names you want to remove.
|
You can customize this by changing the entries of the `omit` set. Simply add all folder or file names you want to remove.
|
||||||
|
|
||||||
### Remove files by tag
|
|
||||||
|
|
||||||
You can access the frontmatter of a file by `node.file?.frontmatter?`. This allows you to filter out files based on their frontmatter, for example by their tags.
|
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
|
||||||
Component.Explorer({
|
|
||||||
filterFn: (node) => {
|
|
||||||
// exclude files with the tag "explorerexclude"
|
|
||||||
return node.file?.frontmatter?.tags?.includes("explorerexclude") !== true
|
|
||||||
},
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### Show every element in explorer
|
### Show every element in explorer
|
||||||
|
|
||||||
To override the default filter function that removes the `tags` folder from the explorer, you can set the filter function to `undefined`.
|
To override the default filter function that removes the `tags` folder from the explorer, you can set the filter function to `undefined`.
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
---
|
---
|
||||||
title: Folder and Tag Listings
|
title: Folder and Tag Listings
|
||||||
tags:
|
tags:
|
||||||
- feature/emitter
|
- plugin/emitter
|
||||||
---
|
---
|
||||||
|
|
||||||
Quartz emits listing pages for any folders and tags you have.
|
Quartz creates listing pages for any folders and tags you have.
|
||||||
|
|
||||||
## Folder Listings
|
## Folder Listings
|
||||||
|
|
||||||
Quartz will generate an index page for all the pages under that folder. This includes any content that is multiple levels deep.
|
Quartz will generate an index page for all the pages under that folder. This includes any content that is multiple levels deep.
|
||||||
|
|
||||||
Additionally, Quartz will also generate pages for subfolders. Say you have a note in a nested folder `content/abc/def/note.md`. Then Quartz would generate a page for all the notes under `abc` _and_ a page for all the notes under `abc/def`.
|
Additionally, Quartz will also generate pages for subfolders. Say you have a note in a nested folder `content/abc/def/note.md`. Then, Quartz would generate a page for all the notes under `abc` _and_ a page for all the notes under `abc/def`.
|
||||||
|
|
||||||
You can link to the folder listing by referencing its name, plus a trailing slash, like this: `[[advanced/]]` (results in [[advanced/]]).
|
By default, Quartz will title the page `Folder: <name of folder>` and no description. You can override this by creating an `index.md` file in the folder with the `title` [[authoring content#Syntax|frontmatter]] field. Any content you write in this file will also be used in the description of the folder.
|
||||||
|
|
||||||
By default, Quartz will title the page `Folder: <folder name>` and no description. You can override this by creating an `index.md` file in the folder with the `title` [[authoring content#Syntax|frontmatter]] field. Any content you write in this file will also be used in the folder description.
|
|
||||||
|
|
||||||
For example, for the folder `content/posts`, you can add another file `content/posts/index.md` to add a specific description for it.
|
For example, for the folder `content/posts`, you can add another file `content/posts/index.md` to add a specific description for it.
|
||||||
|
|
||||||
@ -22,12 +20,13 @@ For example, for the folder `content/posts`, you can add another file `content/p
|
|||||||
|
|
||||||
Quartz will also create an index page for each unique tag in your vault and render a list of all notes with that tag.
|
Quartz will also create an index page for each unique tag in your vault and render a list of all notes with that tag.
|
||||||
|
|
||||||
Quartz also supports tag hierarchies as well (e.g. `plugin/emitter`) and will also render a separate tag page for each level of the tag hierarchy. It will also create a default global tag index page at `/tags` that displays a list of all the tags in your Quartz.
|
Quartz also supports tag hierarchies as well (e.g. `plugin/emitter`) and will also render a separate tag page for each layer of the tag hierarchy. It will also create a default global tag index page at `/tags` that displays a list of all the tags in your Quartz.
|
||||||
|
|
||||||
You can link to the tag listing by referencing its name with a `tag/` prefix, like this: `[[tags/plugin]]` (results in [[tags/plugin]]).
|
Like folder listings, you can also provide a description and title for a tag page by creating a file for each tag. For example, if you wanted to create a custom description for the #component tag, you would create a file at `content/tags/component.md` with a title and description.
|
||||||
|
|
||||||
As with folder listings, you can also provide a description and title for a tag page by creating a file for each tag. For example, if you wanted to create a custom description for the #component tag, you would create a file at `content/tags/component.md` with a title and description.
|
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
Quartz allows you to define a custom sort ordering for content on both page types. The folder listings are a functionality of the [[FolderPage]] plugin, the tag listings of the [[TagPage]] plugin. See the plugin pages for customization options.
|
The layout for both the folder and content pages can be customized. By default, they use the `defaultListPageLayout` in `quartz.layouts.ts`. If you'd like to make more involved changes to the layout and don't mind editing some [[creating components|Quartz components]], you can take a look at `quartz/components/pages/FolderContent.tsx` and `quartz/components/pages/TagContent.tsx` respectively.
|
||||||
|
|
||||||
|
- Removing folder listings: remove `Plugin.FolderPage()` from `emitters` in `quartz.config.ts`
|
||||||
|
- Removing tag listings: remove `Plugin.TagPage()` from `emitters` in `quartz.config.ts`
|
||||||
|
@ -8,8 +8,6 @@ By default, Quartz only fetches previews for pages inside your vault due to [COR
|
|||||||
|
|
||||||
When [[creating components|creating your own components]], you can include this `popover-hint` class to also include it in the popover.
|
When [[creating components|creating your own components]], you can include this `popover-hint` class to also include it in the popover.
|
||||||
|
|
||||||
Similar to Obsidian, [[quartz layout.png|images referenced using wikilinks]] can also be viewed as popups.
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
- Remove popovers: set the `enablePopovers` field in `quartz.config.ts` to be `false`.
|
- Remove popovers: set the `enablePopovers` field in `quartz.config.ts` to be `false`.
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
---
|
---
|
||||||
title: Private Pages
|
title: Private Pages
|
||||||
tags:
|
tags:
|
||||||
- feature/filter
|
- plugin/filter
|
||||||
---
|
---
|
||||||
|
|
||||||
There may be some notes you want to avoid publishing as a website. Quartz supports this through two mechanisms which can be used in conjunction:
|
There may be some notes you want to avoid publishing as a website. Quartz supports this through two mechanisms which can be used in conjunction:
|
||||||
|
|
||||||
## Filter Plugins
|
## Filter Plugins
|
||||||
|
|
||||||
[[making plugins#Filters|Filter plugins]] are plugins that filter out content based off of certain criteria. By default, Quartz uses the [[RemoveDrafts]] plugin which filters out any note that has `draft: true` in the frontmatter.
|
[[making plugins#Filters|Filter plugins]] are plugins that filter out content based off of certain criteria. By default, Quartz uses the `Plugin.RemoveDrafts` plugin which filters out any note that has `draft: true` in the frontmatter.
|
||||||
|
|
||||||
If you'd like to only publish a select number of notes, you can instead use [[ExplicitPublish]] which will filter out all notes except for any that have `publish: true` in the frontmatter.
|
If you'd like to only publish a select number of notes, you can instead use `Plugin.ExplicitPublish` which will filter out all notes except for any that have `publish: true` in the frontmatter.
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> Regardless of the filter plugin used, **all non-markdown files will be emitted and available publically in the final build.** This includes files such as images, voice recordings, PDFs, etc. One way to prevent this and still be able to embed local images is to create a folder specifically for public media and add the following two patterns to the ignorePatterns array.
|
> Regardless of the filter plugin used, **all non-markdown files will be emitted and available publically in the final build.** This includes files such as images, voice recordings, PDFs, etc. One way to prevent this and still be able to embed local images is to create a folder specifically for public media and add the following two patterns to the ignorePatterns array.
|
||||||
|
@ -9,7 +9,6 @@ Quartz can generate a list of recent notes based on some filtering and sorting c
|
|||||||
|
|
||||||
- Changing the title from "Recent notes": pass in an additional parameter to `Component.RecentNotes({ title: "Recent writing" })`
|
- Changing the title from "Recent notes": pass in an additional parameter to `Component.RecentNotes({ title: "Recent writing" })`
|
||||||
- Changing the number of recent notes: pass in an additional parameter to `Component.RecentNotes({ limit: 5 })`
|
- Changing the number of recent notes: pass in an additional parameter to `Component.RecentNotes({ limit: 5 })`
|
||||||
- Display the note's tags (defaults to true): `Component.RecentNotes({ showTags: false })`
|
|
||||||
- Show a 'see more' link: pass in an additional parameter to `Component.RecentNotes({ linkToMore: "tags/components" })`. This field should be a full slug to a page that exists.
|
- Show a 'see more' link: pass in an additional parameter to `Component.RecentNotes({ linkToMore: "tags/components" })`. This field should be a full slug to a page that exists.
|
||||||
- Customize filtering: pass in an additional parameter to `Component.RecentNotes({ filter: someFilterFunction })`. The filter function should be a function that has the signature `(f: QuartzPluginData) => boolean`.
|
- Customize filtering: pass in an additional parameter to `Component.RecentNotes({ filter: someFilterFunction })`. The filter function should be a function that has the signature `(f: QuartzPluginData) => boolean`.
|
||||||
- Customize sorting: pass in an additional parameter to `Component.RecentNotes({ sort: someSortFunction })`. By default, Quartz will sort by date and then tie break lexographically. The sort function should be a function that has the signature `(f1: QuartzPluginData, f2: QuartzPluginData) => number`. See `byDateAndAlphabetical` in `quartz/components/PageList.tsx` for an example.
|
- Customize sorting: pass in an additional parameter to `Component.RecentNotes({ sort: someSortFunction })`. By default, Quartz will sort by date and then tie break lexographically. The sort function should be a function that has the signature `(f1: QuartzPluginData, f2: QuartzPluginData) => number`. See `byDateAndAlphabetical` in `quartz/components/PageList.tsx` for an example.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Syntax Highlighting
|
title: Syntax Highlighting
|
||||||
tags:
|
tags:
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
Syntax highlighting in Quartz is completely done at build-time. This means that Quartz only ships pre-calculated CSS to highlight the right words so there is no heavy client-side bundle that does the syntax highlighting.
|
Syntax highlighting in Quartz is completely done at build-time. This means that Quartz only ships pre-calculated CSS to highlight the right words so there is no heavy client-side bundle that does the syntax highlighting.
|
||||||
@ -95,16 +95,6 @@ const [age, setAge] = useState(50)
|
|||||||
const [name, setName] = useState("Taylor")
|
const [name, setName] = useState("Taylor")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Inline Highlighting
|
|
||||||
|
|
||||||
Append {:lang} to the end of inline code to highlight it like a regular code block.
|
|
||||||
|
|
||||||
```
|
|
||||||
This is an array `[1, 2, 3]{:js}` of numbers 1 through 3.
|
|
||||||
```
|
|
||||||
|
|
||||||
This is an array `[1, 2, 3]{:js}` of numbers 1 through 3.
|
|
||||||
|
|
||||||
### Line numbers
|
### Line numbers
|
||||||
|
|
||||||
Syntax highlighting has line numbers configured automatically. If you want to start line numbers at a specific number, use `showLineNumbers{number}`:
|
Syntax highlighting has line numbers configured automatically. If you want to start line numbers at a specific number, use `showLineNumbers{number}`:
|
||||||
@ -140,4 +130,6 @@ const [name, setName] = useState('Taylor');
|
|||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
Syntax highlighting is a functionality of the [[SyntaxHighlighting]] plugin. See the plugin page for customization options.
|
- Removing syntax highlighting: delete all usages of `Plugin.SyntaxHighlighting()` from `quartz.config.ts`.
|
||||||
|
- Style: By default, Quartz uses derivatives of the GitHub light and dark themes. You can customize the colours in the `quartz/styles/syntax.scss` file.
|
||||||
|
- Plugin: `quartz/plugins/transformers/syntax.ts`
|
||||||
|
@ -2,17 +2,25 @@
|
|||||||
title: "Table of Contents"
|
title: "Table of Contents"
|
||||||
tags:
|
tags:
|
||||||
- component
|
- component
|
||||||
- feature/transformer
|
- plugin/transformer
|
||||||
---
|
---
|
||||||
|
|
||||||
Quartz can automatically generate a table of contents (TOC) from a list of headings on each page. It will also show you your current scrolling position on the page by highlighting headings you've scrolled through with a different color.
|
Quartz can automatically generate a table of contents from a list of headings on each page. It will also show you your current scroll position on the site by marking headings you've scrolled through with a different colour.
|
||||||
|
|
||||||
You can hide the TOC on a page by adding `enableToc: false` to the frontmatter for that page.
|
By default, it will show all headers from H1 (`# Title`) all the way to H3 (`### Title`) and will only show the table of contents if there is more than 1 header on the page.
|
||||||
|
You can also hide the table of contents on a page by adding `enableToc: false` to the frontmatter for that page.
|
||||||
|
|
||||||
By default, the TOC shows all headings from H1 (`# Title`) to H3 (`### Title`) and is only displayed if there is more than one heading on the page.
|
> [!info]
|
||||||
|
> This feature requires both `Plugin.TableOfContents` in your `quartz.config.ts` and `Component.TableOfContents` in your `quartz.layout.ts` to function correctly.
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
The table of contents is a functionality of the [[TableOfContents]] plugin. See the plugin page for more customization options.
|
- Removing table of contents: remove all instances of `Plugin.TableOfContents()` from `quartz.config.ts`. and `Component.TableOfContents()` from `quartz.layout.ts`
|
||||||
|
- Changing the max depth: pass in a parameter to `Plugin.TableOfContents({ maxDepth: 4 })`
|
||||||
It also needs the `TableOfContents` component, which is displayed in the right sidebar by default. You can change this by customizing the [[layout]]. The TOC component can be configured with the `layout` parameter, which can either be `modern` (default) or `legacy`.
|
- Changing the minimum number of entries in the Table of Contents before it renders: pass in a parameter to `Plugin.TableOfContents({ minEntries: 3 })`
|
||||||
|
- Collapse the table of content by default: pass in a parameter to `Plugin.TableOfContents({ collapseByDefault: true })`
|
||||||
|
- Component: `quartz/components/TableOfContents.tsx`
|
||||||
|
- Style:
|
||||||
|
- Modern (default): `quartz/components/styles/toc.scss`
|
||||||
|
- Legacy Quartz 3 style: `quartz/components/styles/legacyToc.scss`
|
||||||
|
- Script: `quartz/components/scripts/toc.inline.ts`
|
||||||
|
@ -2,11 +2,22 @@
|
|||||||
draft: true
|
draft: true
|
||||||
---
|
---
|
||||||
|
|
||||||
## misc backlog
|
## high priority backlog
|
||||||
|
|
||||||
- static dead link detection
|
- static dead link detection
|
||||||
|
- block links: https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note
|
||||||
|
- note/header/block transcludes: https://help.obsidian.md/Linking+notes+and+files/Embedding+files
|
||||||
|
- docker support
|
||||||
|
|
||||||
|
## misc backlog
|
||||||
|
|
||||||
|
- breadcrumbs component
|
||||||
- cursor chat extension
|
- cursor chat extension
|
||||||
|
- https://giscus.app/ extension
|
||||||
- sidenotes? https://github.com/capnfabs/paperesque
|
- sidenotes? https://github.com/capnfabs/paperesque
|
||||||
- direct match in search using double quotes
|
- direct match in search using double quotes
|
||||||
- https://help.obsidian.md/Advanced+topics/Using+Obsidian+URI
|
- https://help.obsidian.md/Advanced+topics/Using+Obsidian+URI
|
||||||
|
- audio/video embed styling
|
||||||
- Canvas
|
- Canvas
|
||||||
|
- parse all images in page: use this for page lists if applicable?
|
||||||
|
- CV mode? with print stylesheet
|
||||||
|
@ -4,7 +4,7 @@ title: Wikilinks
|
|||||||
|
|
||||||
Wikilinks were pioneered by earlier internet wikis to make it easier to write links across pages without needing to write Markdown or HTML links each time.
|
Wikilinks were pioneered by earlier internet wikis to make it easier to write links across pages without needing to write Markdown or HTML links each time.
|
||||||
|
|
||||||
Quartz supports Wikilinks by default and these links are resolved by Quartz using the [[CrawlLinks]] plugin. See the [Obsidian Help page on Internal Links](https://help.obsidian.md/Linking+notes+and+files/Internal+links) for more information on Wikilink syntax.
|
Quartz supports Wikilinks by default and these links are resolved by Quartz using `Plugin.CrawlLinks`. See the [Obsidian Help page on Internal Links](https://help.obsidian.md/Linking+notes+and+files/Internal+links) for more information on Wikilink syntax.
|
||||||
|
|
||||||
This is enabled as a part of [[Obsidian compatibility]] and can be configured and enabled/disabled from that plugin.
|
This is enabled as a part of [[Obsidian compatibility]] and can be configured and enabled/disabled from that plugin.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ Press "Save and deploy" and Cloudflare should have a deployed version of your si
|
|||||||
To add a custom domain, check out [Cloudflare's documentation](https://developers.cloudflare.com/pages/platform/custom-domains/).
|
To add a custom domain, check out [Cloudflare's documentation](https://developers.cloudflare.com/pages/platform/custom-domains/).
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> Cloudflare Pages performs a shallow clone by default, so if you rely on `git` for timestamps, it is recommended that you add `git fetch --unshallow &&` to the beginning of the build command (e.g., `git fetch --unshallow && npx quartz build`).
|
> Cloudflare Pages only allows shallow `git` clones so if you rely on `git` for timestamps, it is recommended you either add dates to your frontmatter (see [[authoring content#Syntax]]) or use another hosting provider.
|
||||||
|
|
||||||
## GitHub Pages
|
## GitHub Pages
|
||||||
|
|
||||||
@ -57,18 +57,18 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for git info
|
fetch-depth: 0 # Fetch all history for git info
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 18.14
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Build Quartz
|
- name: Build Quartz
|
||||||
run: npx quartz build
|
run: npx quartz build
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: public
|
path: public
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v4
|
uses: actions/deploy-pages@v2
|
||||||
```
|
```
|
||||||
|
|
||||||
Then:
|
Then:
|
||||||
@ -182,33 +182,37 @@ Using `docs.example.com` is an example of a subdomain. They're a simple way of c
|
|||||||
|
|
||||||
## GitLab Pages
|
## GitLab Pages
|
||||||
|
|
||||||
In your local Quartz, create a new file `.gitlab-ci.yml`.
|
In your local Quartz, create a new file `.gitlab-ci.yaml`.
|
||||||
|
|
||||||
```yaml title=".gitlab-ci.yml"
|
```yaml title=".gitlab-ci.yaml"
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
image: node:20
|
variables:
|
||||||
cache: # Cache modules in between jobs
|
NODE_VERSION: "18.14"
|
||||||
key: $CI_COMMIT_REF_SLUG
|
|
||||||
paths:
|
|
||||||
- .npm/
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_REF_NAME == "v4"'
|
- if: '$CI_COMMIT_REF_NAME == "v4"'
|
||||||
before_script:
|
before_script:
|
||||||
|
- apt-get update -q && apt-get install -y nodejs npm
|
||||||
|
- npm install -g n
|
||||||
|
- n $NODE_VERSION
|
||||||
- hash -r
|
- hash -r
|
||||||
- npm ci --cache .npm --prefer-offline
|
- npm ci
|
||||||
script:
|
script:
|
||||||
- npx quartz build
|
- npx quartz build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- ~/.npm/
|
||||||
|
key: "${CI_COMMIT_REF_SLUG}-node-${CI_COMMIT_REF_NAME}"
|
||||||
tags:
|
tags:
|
||||||
- gitlab-org-docker
|
- docker
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
@ -224,43 +228,3 @@ 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.
|
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`.
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using Caddy
|
|
||||||
|
|
||||||
Here's and example of how to do this with Caddy:
|
|
||||||
|
|
||||||
```caddy title="Caddyfile"
|
|
||||||
example.com {
|
|
||||||
root * /path/to/quartz/public
|
|
||||||
try_files {path} {path}.html {path}/ =404
|
|
||||||
file_server
|
|
||||||
encode gzip
|
|
||||||
|
|
||||||
handle_errors {
|
|
||||||
rewrite * /{err.status_code}.html
|
|
||||||
file_server
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 88 KiB |
Binary file not shown.
Before Width: | Height: | Size: 572 KiB |
Binary file not shown.
Before Width: | Height: | Size: 108 KiB |
Binary file not shown.
Before Width: | Height: | Size: 171 KiB |
Binary file not shown.
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 55 KiB |
@ -6,7 +6,7 @@ Quartz is a fast, batteries-included static-site generator that transforms Markd
|
|||||||
|
|
||||||
## 🪴 Get Started
|
## 🪴 Get Started
|
||||||
|
|
||||||
Quartz requires **at least [Node](https://nodejs.org/) v20** and `npm` v9.3.1 to function correctly. Ensure you have this installed on your machine before continuing.
|
Quartz requires **at least [Node](https://nodejs.org/) v18.14** and `npm` v9.3.1 to function correctly. Ensure you have this installed on your machine before continuing.
|
||||||
|
|
||||||
Then, in your terminal of choice, enter the following commands line by line:
|
Then, in your terminal of choice, enter the following commands line by line:
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ If you prefer instructions in a video format you can try following Nicole van de
|
|||||||
|
|
||||||
## 🔧 Features
|
## 🔧 Features
|
||||||
|
|
||||||
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]], [[comments]] and [many more](./features) right out of the box
|
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]] and [many more](./features) right out of the box
|
||||||
- Hot-reload for both configuration and content
|
- Hot-reload for both configuration and content
|
||||||
- Simple JSX layouts and [[creating components|page components]]
|
- Simple JSX layouts and [[creating components|page components]]
|
||||||
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
||||||
|
@ -12,7 +12,6 @@ export interface FullPageLayout {
|
|||||||
header: QuartzComponent[] // laid out horizontally
|
header: QuartzComponent[] // laid out horizontally
|
||||||
beforeBody: QuartzComponent[] // laid out vertically
|
beforeBody: QuartzComponent[] // laid out vertically
|
||||||
pageBody: QuartzComponent // single component
|
pageBody: QuartzComponent // single component
|
||||||
afterBody: QuartzComponent[] // laid out vertically
|
|
||||||
left: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
left: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
||||||
right: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
right: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
||||||
footer: QuartzComponent // single component
|
footer: QuartzComponent // single component
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
title: AliasRedirects
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits HTML redirect pages for aliases and permalinks defined in the frontmatter of content files.
|
|
||||||
|
|
||||||
For example, A `foo.md` has the following frontmatter
|
|
||||||
|
|
||||||
```md title="foo.md"
|
|
||||||
---
|
|
||||||
title: "Foo"
|
|
||||||
alias:
|
|
||||||
- "bar"
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
The target `host.me/bar` will be redirected to `host.me/foo`
|
|
||||||
|
|
||||||
Note that these are permanent redirect.
|
|
||||||
|
|
||||||
The emitter supports the following aliases:
|
|
||||||
|
|
||||||
- `aliases`
|
|
||||||
- `alias`
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.AliasRedirects()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/aliases.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/aliases.ts).
|
|
@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
title: Assets
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits all non-Markdown static assets in your content folder (like images, videos, HTML, etc). The plugin respects the `ignorePatterns` in the global [[configuration]].
|
|
||||||
|
|
||||||
Note that all static assets will then be accessible through its path on your generated site, i.e: `host.me/path/to/static.pdf`
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.Assets()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/assets.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/assets.ts).
|
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
title: CNAME
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits a `CNAME` record that points your subdomain to the default domain of your site.
|
|
||||||
|
|
||||||
If you want to use a custom domain name like `quartz.example.com` for the site, then this is needed.
|
|
||||||
|
|
||||||
See [[hosting|Hosting]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.CNAME()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/cname.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/cname.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: ComponentResources
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin manages and emits the static resources required for the Quartz framework. This includes CSS stylesheets and JavaScript scripts that enhance the functionality and aesthetics of the generated site. See also the `cdnCaching` option in the `theme` section of the [[configuration]].
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.ComponentResources()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/componentResources.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/componentResources.ts).
|
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
title: ContentIndex
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits both RSS and an XML sitemap for your site. The [[RSS Feed]] allows users to subscribe to content on your site and the sitemap allows search engines to better index your site. The plugin also emits a `contentIndex.json` file which is used by dynamic frontend components like search and graph.
|
|
||||||
|
|
||||||
This plugin emits a comprehensive index of the site's content, generating additional resources such as a sitemap, an RSS feed, and a
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `enableSiteMap`: If `true` (default), generates a sitemap XML file (`sitemap.xml`) listing all site URLs for search engines in content discovery.
|
|
||||||
- `enableRSS`: If `true` (default), produces an RSS feed (`index.xml`) with recent content updates.
|
|
||||||
- `rssLimit`: Defines the maximum number of entries to include in the RSS feed, helping to focus on the most recent or relevant content. Defaults to `10`.
|
|
||||||
- `rssFullHtml`: If `true`, the RSS feed includes full HTML content. Otherwise it includes just summaries.
|
|
||||||
- `includeEmptyFiles`: If `true` (default), content files with no body text are included in the generated index and resources.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.ContentIndex()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/contentIndex.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/contentIndex.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: ContentPage
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin is a core component of the Quartz framework. It generates the HTML pages for each piece of Markdown content. It emits the full-page [[layout]], including headers, footers, and body content, among others.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.ContentPage()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/contentPage.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/contentPage.tsx).
|
|
@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
title: CrawlLinks
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin parses links and processes them to point to the right places. It is also needed for embedded links (like images). See [[Obsidian compatibility]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `markdownLinkResolution`: Sets the strategy for resolving Markdown paths, can be `"absolute"` (default), `"relative"` or `"shortest"`. You should use the same setting here as in [[Obsidian compatibility|Obsidian]].
|
|
||||||
- `absolute`: Path relative to the root of the content folder.
|
|
||||||
- `relative`: Path relative to the file you are linking from.
|
|
||||||
- `shortest`: Name of the file. If this isn't enough to identify the file, use the full absolute path.
|
|
||||||
- `prettyLinks`: If `true` (default), simplifies links by removing folder paths, making them more user friendly (e.g. `folder/deeply/nested/note` becomes `note`).
|
|
||||||
- `openLinksInNewTab`: If `true`, configures external links to open in a new tab. Defaults to `false`.
|
|
||||||
- `lazyLoad`: If `true`, adds lazy loading to resource elements (`img`, `video`, etc.) to improve page load performance. Defaults to `false`.
|
|
||||||
- `externalLinkIcon`: Adds an icon next to external links when `true` (default) to visually distinguishing them from internal links.
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> Removing this plugin is _not_ recommended and will likely break the page.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.CrawlLinks()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/links.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/links.ts).
|
|
@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
title: "CreatedModifiedDate"
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin determines the created, modified, and published dates for a document using three potential data sources: frontmatter metadata, Git history, and the filesystem. See [[authoring content#Syntax]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `priority`: The data sources to consult for date information. Highest priority first. Possible values are `"frontmatter"`, `"git"`, and `"filesystem"`. Defaults to `["frontmatter", "git", "filesystem"]`.
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> If you rely on `git` for dates, make sure `defaultDateType` is set to `modified` in `quartz.config.ts`.
|
|
||||||
>
|
|
||||||
> Depending on how you [[hosting|host]] your Quartz, the `filesystem` dates of your local files may not match the final dates. In these cases, it may be better to use `git` or `frontmatter` to guarantee correct dates.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.CreatedModifiedDate()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/lastmod.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/lastmod.ts).
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
title: Description
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin generates descriptions that are used as metadata for the HTML `head`, the [[RSS Feed]] and in [[folder and tag listings]] if there is no main body content, the description is used as the text between the title and the listing.
|
|
||||||
|
|
||||||
If the frontmatter contains a `description` property, it is used (see [[authoring content#Syntax]]). Otherwise, the plugin will do its best to use the first few sentences of the content to reach the target description length.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `descriptionLength`: the maximum length of the generated description. Default is 150 characters. The cut off happens after the first _sentence_ that ends after the given length.
|
|
||||||
- `replaceExternalLinks`: If `true` (default), replace external links with their domain and path in the description (e.g. `https://domain.tld/some_page/another_page?query=hello&target=world` is replaced with `domain.tld/some_page/another_page`).
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.Description()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/description.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/description.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: ExplicitPublish
|
|
||||||
tags:
|
|
||||||
- plugin/filter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin filters content based on an explicit `publish` flag in the frontmatter, allowing only content that is explicitly marked for publication to pass through. It's the opt-in version of [[RemoveDrafts]]. See [[private pages]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Filter
|
|
||||||
- Function name: `Plugin.ExplicitPublish()`.
|
|
||||||
- Source: [`quartz/plugins/filters/explicit.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/filters/explicit.ts).
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
title: FolderPage
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin generates index pages for folders, creating a listing page for each folder that contains multiple content files. See [[folder and tag listings]] for more information.
|
|
||||||
|
|
||||||
Example: [[advanced/|Advanced]]
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `FolderContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/FolderContent.tsx`).
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.FolderPage()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/folderPage.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/folderPage.tsx).
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Frontmatter"
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin parses the frontmatter of the page using the [gray-matter](https://github.com/jonschlinkert/gray-matter) library. See [[authoring content#Syntax]], [[Obsidian compatibility]] and [[OxHugo compatibility]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `delimiters`: the delimiters to use for the frontmatter. Can have one value (e.g. `"---"`) or separate values for opening and closing delimiters (e.g. `["---", "~~~"]`). Defaults to `"---"`.
|
|
||||||
- `language`: the language to use for parsing the frontmatter. Can be `yaml` (default) or `toml`.
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> This plugin must not be removed, otherwise Quartz will break.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.Frontmatter()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/frontmatter.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/frontmatter.ts).
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
title: GitHubFlavoredMarkdown
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin enhances Markdown processing to support GitHub Flavored Markdown (GFM) which adds features like autolink literals, footnotes, strikethrough, tables and tasklists.
|
|
||||||
|
|
||||||
In addition, this plugin adds optional features for typographic refinement (such as converting straight quotes to curly quotes, dashes to en-dashes/em-dashes, and ellipses) and automatic heading links as a symbol that appears next to the heading on hover.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `enableSmartyPants`: When true, enables typographic enhancements. Default is true.
|
|
||||||
- `linkHeadings`: When true, automatically adds links to headings. Default is true.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.GitHubFlavoredMarkdown()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/gfm.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/gfm.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: HardLineBreaks
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin automatically converts single line breaks in Markdown text into hard line breaks in the HTML output. This plugin is not enabled by default as this doesn't follow the semantics of actual Markdown but you may enable it if you'd like parity with [[Obsidian compatibility|Obsidian]].
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.HardLineBreaks()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/linebreaks.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/linebreaks.ts).
|
|
@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Latex"
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin adds LaTeX support to Quartz. See [[features/Latex|Latex]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `renderEngine`: the engine to use to render LaTeX equations. Can be `"katex"` for [KaTeX](https://katex.org/) or `"mathjax"` for [MathJax](https://www.mathjax.org/) [SVG rendering](https://docs.mathjax.org/en/latest/output/svg.html). Defaults to KaTeX.
|
|
||||||
- `customMacros`: custom macros for all LaTeX blocks. It takes the form of a key-value pair where the key is a new command name and the value is the expansion of the macro. For example: `{"\\R": "\\mathbb{R}"}`
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.Latex()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/latex.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/latex.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: NotFoundPage
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits a 404 (Not Found) page for broken or non-existent URLs.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.NotFoundPage()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/404.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/404.tsx).
|
|
@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
title: ObsidianFlavoredMarkdown
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin provides support for [[Obsidian compatibility]].
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `comments`: If `true` (default), enables parsing of `%%` style Obsidian comment blocks.
|
|
||||||
- `highlight`: If `true` (default), enables parsing of `==` style highlights within content.
|
|
||||||
- `wikilinks`:If `true` (default), turns [[wikilinks]] into regular links.
|
|
||||||
- `callouts`: If `true` (default), adds support for [[callouts|callout]] blocks for emphasizing content.
|
|
||||||
- `mermaid`: If `true` (default), enables [[Mermaid diagrams|Mermaid diagram]] rendering within Markdown files.
|
|
||||||
- `parseTags`: If `true` (default), parses and links tags within the content.
|
|
||||||
- `parseArrows`: If `true` (default), transforms arrow symbols into their HTML character equivalents.
|
|
||||||
- `parseBlockReferences`: If `true` (default), handles block references, linking to specific content blocks.
|
|
||||||
- `enableInHtmlEmbed`: If `true`, allows embedding of content directly within HTML. Defaults to `false`.
|
|
||||||
- `enableYouTubeEmbed`: If `true` (default), enables the embedding of YouTube videos and playlists using external image Markdown syntax.
|
|
||||||
- `enableVideoEmbed`: If `true` (default), enables the embedding of video files.
|
|
||||||
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content. Defaults to `false`.
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> Don't remove this plugin if you're using [[Obsidian compatibility|Obsidian]] to author the content!
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.ObsidianFlavoredMarkdown()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/toc.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/toc.ts).
|
|
@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
title: OxHugoFlavoredMarkdown
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin provides support for [ox-hugo](https://github.com/kaushalmodi/ox-hugo) compatibility. See [[OxHugo compatibility]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `wikilinks`: If `true` (default), converts Hugo `{{ relref }}` shortcodes to Quartz [[wikilinks]].
|
|
||||||
- `removePredefinedAnchor`: If `true` (default), strips predefined anchors from headings.
|
|
||||||
- `removeHugoShortcode`: If `true` (default), removes Hugo shortcode syntax (`{{}}`) from the content.
|
|
||||||
- `replaceFigureWithMdImg`: If `true` (default), replaces `<figure/>` with `![]()`.
|
|
||||||
- `replaceOrgLatex`: If `true` (default), converts Org-mode [[features/Latex|Latex]] fragments to Quartz-compatible LaTeX wrapped in `$` (for inline) and `$$` (for block equations).
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> While you can use this together with [[ObsidianFlavoredMarkdown]], it's not recommended because it might mutate the file in unexpected ways. Use with caution.
|
|
||||||
>
|
|
||||||
> If you use `toml` frontmatter, make sure to configure the [[Frontmatter]] plugin accordingly. See [[OxHugo compatibility]] for an example.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.OxHugoFlavoredMarkdown()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/oxhugofm.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/oxhugofm.ts).
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: RemoveDrafts
|
|
||||||
tags:
|
|
||||||
- plugin/filter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin filters out content from your vault, so that only finalized content is made available. This prevents [[private pages]] from being published. By default, it filters out all pages with `draft: true` in the frontmatter and leaves all other pages intact.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Filter
|
|
||||||
- Function name: `Plugin.RemoveDrafts()`.
|
|
||||||
- Source: [`quartz/plugins/filters/draft.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/filters/draft.ts).
|
|
@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
title: Static
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits all static resources needed by Quartz. This is used, for example, for fonts and images that need a stable position, such as banners and icons. The plugin respects the `ignorePatterns` in the global [[configuration]].
|
|
||||||
|
|
||||||
> [!important]
|
|
||||||
> This is different from [[Assets]]. The resources from the [[Static]] plugin are located under `quartz/static`, whereas [[Assets]] renders all static resources under `content` and is used for images, videos, audio, etc. that are directly referenced by your markdown content.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.Static()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/static.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/static.ts).
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
title: "SyntaxHighlighting"
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin is used to add syntax highlighting to code blocks in Quartz. See [[syntax highlighting]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `theme`: a separate id of one of the [themes bundled with Shikiji](https://shikiji.netlify.app/themes). One for light mode and one for dark mode. Defaults to `theme: { light: "github-light", dark: "github-dark" }`.
|
|
||||||
- `keepBackground`: If set to `true`, the background of the Shikiji theme will be used. With `false` (default) the Quartz theme color for background will be used instead.
|
|
||||||
|
|
||||||
In addition, you can further override the colours in the `quartz/styles/syntax.scss` file.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.SyntaxHighlighting()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/syntax.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/syntax.ts).
|
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
title: TableOfContents
|
|
||||||
tags:
|
|
||||||
- plugin/transformer
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin generates a table of contents (TOC) for Markdown documents. See [[table of contents]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `maxDepth`: Limits the depth of headings included in the TOC, ranging from `1` (top level headings only) to `6` (all heading levels). Default is `3`.
|
|
||||||
- `minEntries`: The minimum number of heading entries required for the TOC to be displayed. Default is `1`.
|
|
||||||
- `showByDefault`: If `true` (default), the TOC should be displayed by default. Can be overridden by frontmatter settings.
|
|
||||||
- `collapseByDefault`: If `true`, the TOC will start in a collapsed state. Default is `false`.
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> This plugin needs the `Component.TableOfContents` component in `quartz.layout.ts` to determine where to display the TOC. Without it, nothing will be displayed. They should always be added or removed together.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Transformer
|
|
||||||
- Function name: `Plugin.TableOfContents()`.
|
|
||||||
- Source: [`quartz/plugins/transformers/toc.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/toc.ts).
|
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
title: TagPage
|
|
||||||
tags:
|
|
||||||
- plugin/emitter
|
|
||||||
---
|
|
||||||
|
|
||||||
This plugin emits dedicated pages for each tag used in the content. See [[folder and tag listings]] for more information.
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
|
||||||
|
|
||||||
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `TagContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/TagContent.tsx`).
|
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
|
||||||
|
|
||||||
- `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order.
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
- Category: Emitter
|
|
||||||
- Function name: `Plugin.TagPage()`.
|
|
||||||
- Source: [`quartz/plugins/emitters/tagPage.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/tagPage.tsx).
|
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Plugins
|
|
||||||
---
|
|
@ -7,26 +7,23 @@ Want to see what Quartz can do? Here are some cool community gardens:
|
|||||||
- [Quartz Documentation (this site!)](https://quartz.jzhao.xyz/)
|
- [Quartz Documentation (this site!)](https://quartz.jzhao.xyz/)
|
||||||
- [Jacky Zhao's Garden](https://jzhao.xyz/)
|
- [Jacky Zhao's Garden](https://jzhao.xyz/)
|
||||||
- [Socratica Toolbox](https://toolbox.socratica.info/)
|
- [Socratica Toolbox](https://toolbox.socratica.info/)
|
||||||
- [Morrowind Modding Wiki](https://morrowind-modding.github.io/)
|
|
||||||
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
|
||||||
- [Pelayo Arbues' Notes](https://pelayoarbues.com/)
|
|
||||||
- [Stanford CME 302 Numerical Linear Algebra](https://ericdarve.github.io/NLA/)
|
|
||||||
- [A Pattern Language - Christopher Alexander (Architecture)](https://patternlanguage.cc/)
|
|
||||||
- [oldwinter の数字花园](https://garden.oldwinter.top/)
|
- [oldwinter の数字花园](https://garden.oldwinter.top/)
|
||||||
- [Eilleen's Everything Notebook](https://quartz.eilleeenz.com/)
|
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
||||||
|
- [The Quantum Garden](https://quantumgardener.blog/)
|
||||||
|
- [Abhijeet's Math Wiki](https://abhmul.github.io/quartz/Math-Wiki/)
|
||||||
|
- [Matt Dunn's Second Brain](https://mattdunn.info/)
|
||||||
|
- [Pelayo Arbues' Notes](https://pelayoarbues.github.io/)
|
||||||
|
- [Vince Imbat's Talahardin](https://vinceimbat.com/)
|
||||||
- [🧠🌳 Chad's Mind Garden](https://www.chadly.net/)
|
- [🧠🌳 Chad's Mind Garden](https://www.chadly.net/)
|
||||||
- [Pedro MC Fernandes's Topo da Mente](https://www.pmcf.xyz/topo-da-mente/)
|
- [Pedro MC Fernandes's Topo da Mente](https://www.pmcf.xyz/topo-da-mente/)
|
||||||
- [Mau Camargo's Notkesto](https://notes.camargomau.com/)
|
- [Mau Camargo's Notkesto](https://notes.camargomau.com/)
|
||||||
|
- [Caicai's Novels](https://imoko.cc/blog/caicai/)
|
||||||
|
- [🌊 Collapsed Wave](https://collapsedwave.com/)
|
||||||
- [Sideny's 3D Artist's Handbook](https://sidney-eliot.github.io/3d-artists-handbook/)
|
- [Sideny's 3D Artist's Handbook](https://sidney-eliot.github.io/3d-artists-handbook/)
|
||||||
|
- [Mike's AI Garden 🤖🪴](https://mwalton.me/)
|
||||||
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
||||||
- [Scaling Synthesis - A hypertext research notebook](https://scalingsynthesis.com/)
|
- [Scaling Synthesis - A hypertext research notebook](https://scalingsynthesis.com/)
|
||||||
- [Data Dictionary 🧠](https://glossary.airbyte.com/)
|
- [Data Dictionary 🧠](https://glossary.airbyte.com/)
|
||||||
- [sspaeti.com's Second Brain](https://brain.sspaeti.com/)
|
- [sspaeti.com's Second Brain](https://brain.sspaeti.com/)
|
||||||
- [🪴Aster's notebook](https://notes.asterhu.com)
|
|
||||||
- [Gatekeeper Wiki](https://www.gatekeeper.wiki)
|
|
||||||
- [Ellie's Notes](https://ellie.wtf)
|
|
||||||
- [🥷🏻🌳🍃 Computer Science & Thinkering Garden](https://notes.yxy.ninja)
|
|
||||||
- [Eledah's Crystalline](https://blog.eledah.ir/)
|
|
||||||
- [🌓 Projects & Privacy - FOSS, tech, law](https://be-far.com)
|
|
||||||
|
|
||||||
If you want to see your own on here, submit a [Pull Request adding yourself to this file](https://github.com/jackyzha0/quartz/blob/v4/docs/showcase.md)!
|
If you want to see your own on here, submit a [Pull Request adding yourself to this file](https://github.com/jackyzha0/quartz/blob/v4/docs/showcase.md)!
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Plugins
|
|
||||||
---
|
|
4
globals.d.ts
vendored
4
globals.d.ts
vendored
@ -4,10 +4,6 @@ export declare global {
|
|||||||
type: K,
|
type: K,
|
||||||
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
||||||
): void
|
): void
|
||||||
removeEventListener<K extends keyof CustomEventMap>(
|
|
||||||
type: K,
|
|
||||||
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
|
||||||
): void
|
|
||||||
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void
|
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void
|
||||||
}
|
}
|
||||||
interface Window {
|
interface Window {
|
||||||
|
1746
package-lock.json
generated
1746
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
64
package.json
64
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "@jackyzha0/quartz",
|
"name": "@jackyzha0/quartz",
|
||||||
"description": "🌱 publish your digital garden and notes as a website",
|
"description": "🌱 publish your digital garden and notes as a website",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "4.3.1",
|
"version": "4.2.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -12,7 +12,6 @@
|
|||||||
"url": "https://github.com/jackyzha0/quartz.git"
|
"url": "https://github.com/jackyzha0/quartz.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"quartz": "./quartz/bootstrap-cli.mjs",
|
|
||||||
"docs": "npx quartz build --serve -d docs",
|
"docs": "npx quartz build --serve -d docs",
|
||||||
"check": "tsc --noEmit && npx prettier . --check",
|
"check": "tsc --noEmit && npx prettier . --check",
|
||||||
"format": "npx prettier . --write",
|
"format": "npx prettier . --write",
|
||||||
@ -21,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"npm": ">=9.3.1",
|
"npm": ">=9.3.1",
|
||||||
"node": "20 || >=22"
|
"node": ">=18.14"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"site generator",
|
"site generator",
|
||||||
@ -36,40 +35,37 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.7.0",
|
"@clack/prompts": "^0.7.0",
|
||||||
"@floating-ui/dom": "^1.6.10",
|
"@floating-ui/dom": "^1.6.1",
|
||||||
"@napi-rs/simple-git": "0.1.19",
|
"@napi-rs/simple-git": "0.1.16",
|
||||||
"@tweenjs/tween.js": "^25.0.0",
|
"async-mutex": "^0.4.1",
|
||||||
"async-mutex": "^0.5.0",
|
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"chokidar": "^3.6.0",
|
"chokidar": "^3.5.3",
|
||||||
"cli-spinner": "^0.2.10",
|
"cli-spinner": "^0.2.10",
|
||||||
"d3": "^7.9.0",
|
"d3": "^7.8.5",
|
||||||
"esbuild-sass-plugin": "^2.16.1",
|
"esbuild-sass-plugin": "^2.16.0",
|
||||||
"flexsearch": "0.7.43",
|
"flexsearch": "0.7.43",
|
||||||
"github-slugger": "^2.0.0",
|
"github-slugger": "^2.0.0",
|
||||||
"globby": "^14.0.2",
|
"globby": "^14.0.0",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"hast-util-to-html": "^9.0.1",
|
"hast-util-to-html": "^9.0.0",
|
||||||
"hast-util-to-jsx-runtime": "^2.3.0",
|
"hast-util-to-jsx-runtime": "^2.3.0",
|
||||||
"hast-util-to-string": "^3.0.0",
|
"hast-util-to-string": "^3.0.0",
|
||||||
"is-absolute-url": "^4.0.1",
|
"is-absolute-url": "^4.0.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lightningcss": "^1.26.0",
|
"lightningcss": "^1.23.0",
|
||||||
"mdast-util-find-and-replace": "^3.0.1",
|
"mdast-util-find-and-replace": "^3.0.1",
|
||||||
"mdast-util-to-hast": "^13.2.0",
|
"mdast-util-to-hast": "^13.1.0",
|
||||||
"mdast-util-to-string": "^4.0.0",
|
"mdast-util-to-string": "^4.0.0",
|
||||||
"micromorph": "^0.4.5",
|
"micromorph": "^0.4.5",
|
||||||
"pixi.js": "^8.3.3",
|
"preact": "^10.19.3",
|
||||||
"preact": "^10.23.2",
|
"preact-render-to-string": "^6.3.1",
|
||||||
"preact-render-to-string": "^6.5.9",
|
|
||||||
"pretty-bytes": "^6.1.1",
|
"pretty-bytes": "^6.1.1",
|
||||||
"pretty-time": "^1.1.0",
|
"pretty-time": "^1.1.0",
|
||||||
"reading-time": "^1.5.0",
|
"reading-time": "^1.5.0",
|
||||||
"rehype-autolink-headings": "^7.1.0",
|
"rehype-autolink-headings": "^7.1.0",
|
||||||
"rehype-citation": "^2.1.1",
|
"rehype-katex": "^7.0.0",
|
||||||
"rehype-katex": "^7.0.1",
|
|
||||||
"rehype-mathjax": "^6.0.0",
|
"rehype-mathjax": "^6.0.0",
|
||||||
"rehype-pretty-code": "^0.13.2",
|
"rehype-pretty-code": "^0.12.6",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"rehype-slug": "^6.0.0",
|
"rehype-slug": "^6.0.0",
|
||||||
"remark": "^15.0.1",
|
"remark": "^15.0.1",
|
||||||
@ -79,19 +75,19 @@
|
|||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"remark-parse": "^11.0.0",
|
"remark-parse": "^11.0.0",
|
||||||
"remark-rehype": "^11.1.0",
|
"remark-rehype": "^11.1.0",
|
||||||
"remark-smartypants": "^3.0.2",
|
"remark-smartypants": "^2.0.0",
|
||||||
"rfdc": "^1.4.1",
|
"rfdc": "^1.3.1",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^5.0.5",
|
||||||
"serve-handler": "^6.1.5",
|
"serve-handler": "^6.1.5",
|
||||||
"shiki": "^1.12.1",
|
"shikiji": "^0.10.2",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"to-vfile": "^8.0.0",
|
"to-vfile": "^8.0.0",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.4",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
"vfile": "^6.0.2",
|
"vfile": "^6.0.1",
|
||||||
"workerpool": "^9.1.3",
|
"workerpool": "^9.1.0",
|
||||||
"ws": "^8.18.0",
|
"ws": "^8.15.1",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -99,14 +95,14 @@
|
|||||||
"@types/d3": "^7.4.3",
|
"@types/d3": "^7.4.3",
|
||||||
"@types/hast": "^3.0.4",
|
"@types/hast": "^3.0.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/node": "^22.5.0",
|
"@types/node": "^20.11.16",
|
||||||
"@types/pretty-time": "^1.1.5",
|
"@types/pretty-time": "^1.1.5",
|
||||||
"@types/source-map-support": "^0.5.10",
|
"@types/source-map-support": "^0.5.10",
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.5.10",
|
||||||
"@types/yargs": "^17.0.33",
|
"@types/yargs": "^17.0.32",
|
||||||
"esbuild": "^0.19.9",
|
"esbuild": "^0.19.9",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.2.4",
|
||||||
"tsx": "^4.18.0",
|
"tsx": "^4.7.0",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import { QuartzConfig } from "./quartz/cfg"
|
import { QuartzConfig } from "./quartz/cfg"
|
||||||
import * as Plugin from "./quartz/plugins"
|
import * as Plugin from "./quartz/plugins"
|
||||||
|
|
||||||
/**
|
|
||||||
* Quartz 4.0 Configuration
|
|
||||||
*
|
|
||||||
* See https://quartz.jzhao.xyz/configuration for more information.
|
|
||||||
*/
|
|
||||||
const config: QuartzConfig = {
|
const config: QuartzConfig = {
|
||||||
configuration: {
|
configuration: {
|
||||||
pageTitle: "🪴 Quartz 4.0",
|
pageTitle: "🪴 Quartz 4.0",
|
||||||
@ -19,7 +14,6 @@ const config: QuartzConfig = {
|
|||||||
ignorePatterns: ["private", "templates", ".obsidian"],
|
ignorePatterns: ["private", "templates", ".obsidian"],
|
||||||
defaultDateType: "created",
|
defaultDateType: "created",
|
||||||
theme: {
|
theme: {
|
||||||
fontOrigin: "googleFonts",
|
|
||||||
cdnCaching: true,
|
cdnCaching: true,
|
||||||
typography: {
|
typography: {
|
||||||
header: "Schibsted Grotesk",
|
header: "Schibsted Grotesk",
|
||||||
@ -36,7 +30,6 @@ const config: QuartzConfig = {
|
|||||||
secondary: "#284b63",
|
secondary: "#284b63",
|
||||||
tertiary: "#84a59d",
|
tertiary: "#84a59d",
|
||||||
highlight: "rgba(143, 159, 169, 0.15)",
|
highlight: "rgba(143, 159, 169, 0.15)",
|
||||||
textHighlight: "#fff23688",
|
|
||||||
},
|
},
|
||||||
darkMode: {
|
darkMode: {
|
||||||
light: "#161618",
|
light: "#161618",
|
||||||
@ -47,7 +40,6 @@ const config: QuartzConfig = {
|
|||||||
secondary: "#7b97aa",
|
secondary: "#7b97aa",
|
||||||
tertiary: "#84a59d",
|
tertiary: "#84a59d",
|
||||||
highlight: "rgba(143, 159, 169, 0.15)",
|
highlight: "rgba(143, 159, 169, 0.15)",
|
||||||
textHighlight: "#b3aa0288",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -56,26 +48,22 @@ const config: QuartzConfig = {
|
|||||||
transformers: [
|
transformers: [
|
||||||
Plugin.FrontMatter(),
|
Plugin.FrontMatter(),
|
||||||
Plugin.CreatedModifiedDate({
|
Plugin.CreatedModifiedDate({
|
||||||
|
// you can add 'git' here for last modified from Git
|
||||||
|
// if you do rely on git for dates, ensure defaultDateType is 'modified'
|
||||||
priority: ["frontmatter", "filesystem"],
|
priority: ["frontmatter", "filesystem"],
|
||||||
}),
|
}),
|
||||||
Plugin.SyntaxHighlighting({
|
Plugin.Latex({ renderEngine: "katex" }),
|
||||||
theme: {
|
Plugin.SyntaxHighlighting(),
|
||||||
light: "github-light",
|
|
||||||
dark: "github-dark",
|
|
||||||
},
|
|
||||||
keepBackground: false,
|
|
||||||
}),
|
|
||||||
Plugin.ObsidianFlavoredMarkdown({ enableInHtmlEmbed: false }),
|
Plugin.ObsidianFlavoredMarkdown({ enableInHtmlEmbed: false }),
|
||||||
Plugin.GitHubFlavoredMarkdown(),
|
Plugin.GitHubFlavoredMarkdown(),
|
||||||
Plugin.TableOfContents(),
|
Plugin.TableOfContents(),
|
||||||
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
||||||
Plugin.Description(),
|
Plugin.Description(),
|
||||||
Plugin.Latex({ renderEngine: "katex" }),
|
|
||||||
],
|
],
|
||||||
filters: [Plugin.RemoveDrafts()],
|
filters: [Plugin.RemoveDrafts()],
|
||||||
emitters: [
|
emitters: [
|
||||||
Plugin.AliasRedirects(),
|
Plugin.AliasRedirects(),
|
||||||
Plugin.ComponentResources(),
|
Plugin.ComponentResources({ fontOrigin: "googleFonts" }),
|
||||||
Plugin.ContentPage(),
|
Plugin.ContentPage(),
|
||||||
Plugin.FolderPage(),
|
Plugin.FolderPage(),
|
||||||
Plugin.TagPage(),
|
Plugin.TagPage(),
|
||||||
|
@ -5,7 +5,6 @@ import * as Component from "./quartz/components"
|
|||||||
export const sharedPageComponents: SharedLayout = {
|
export const sharedPageComponents: SharedLayout = {
|
||||||
head: Component.Head(),
|
head: Component.Head(),
|
||||||
header: [],
|
header: [],
|
||||||
afterBody: [],
|
|
||||||
footer: Component.Footer({
|
footer: Component.Footer({
|
||||||
links: {
|
links: {
|
||||||
GitHub: "https://github.com/jackyzha0/quartz",
|
GitHub: "https://github.com/jackyzha0/quartz",
|
||||||
|
@ -38,13 +38,8 @@ type BuildData = {
|
|||||||
|
|
||||||
type FileEvent = "add" | "change" | "delete"
|
type FileEvent = "add" | "change" | "delete"
|
||||||
|
|
||||||
function newBuildId() {
|
|
||||||
return new Date().toISOString()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
||||||
const ctx: BuildCtx = {
|
const ctx: BuildCtx = {
|
||||||
buildId: newBuildId(),
|
|
||||||
argv,
|
argv,
|
||||||
cfg,
|
cfg,
|
||||||
allSlugs: [],
|
allSlugs: [],
|
||||||
@ -65,7 +60,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
|||||||
|
|
||||||
const release = await mut.acquire()
|
const release = await mut.acquire()
|
||||||
perf.addEvent("clean")
|
perf.addEvent("clean")
|
||||||
await rimraf(path.join(output, "*"), { glob: true })
|
await rimraf(output)
|
||||||
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
|
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
|
||||||
|
|
||||||
perf.addEvent("glob")
|
perf.addEvent("glob")
|
||||||
@ -172,7 +167,6 @@ async function partialRebuildFromEntrypoint(
|
|||||||
|
|
||||||
const perf = new PerfTimer()
|
const perf = new PerfTimer()
|
||||||
console.log(chalk.yellow("Detected change, rebuilding..."))
|
console.log(chalk.yellow("Detected change, rebuilding..."))
|
||||||
ctx.buildId = newBuildId()
|
|
||||||
|
|
||||||
// UPDATE DEP GRAPH
|
// UPDATE DEP GRAPH
|
||||||
const fp = joinSegments(argv.directory, toPosixPath(filepath)) as FilePath
|
const fp = joinSegments(argv.directory, toPosixPath(filepath)) as FilePath
|
||||||
@ -191,14 +185,9 @@ async function partialRebuildFromEntrypoint(
|
|||||||
const emitterGraph =
|
const emitterGraph =
|
||||||
(await emitter.getDependencyGraph?.(ctx, processedFiles, staticResources)) ?? null
|
(await emitter.getDependencyGraph?.(ctx, processedFiles, staticResources)) ?? null
|
||||||
|
|
||||||
|
// emmiter may not define a dependency graph. nothing to update if so
|
||||||
if (emitterGraph) {
|
if (emitterGraph) {
|
||||||
const existingGraph = dependencies[emitter.name]
|
dependencies[emitter.name]?.updateIncomingEdgesForNode(emitterGraph, fp)
|
||||||
if (existingGraph !== null) {
|
|
||||||
existingGraph.mergeGraph(emitterGraph)
|
|
||||||
} else {
|
|
||||||
// might be the first time we're adding a mardown file
|
|
||||||
dependencies[emitter.name] = emitterGraph
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -214,9 +203,8 @@ async function partialRebuildFromEntrypoint(
|
|||||||
const emitterGraph =
|
const emitterGraph =
|
||||||
(await emitter.getDependencyGraph?.(ctx, processedFiles, staticResources)) ?? null
|
(await emitter.getDependencyGraph?.(ctx, processedFiles, staticResources)) ?? null
|
||||||
|
|
||||||
// only update the graph if the emitter plugin uses the changed file
|
// emmiter may not define a dependency graph. nothing to update if so
|
||||||
// eg. Assets plugin ignores md files, so we skip updating the graph
|
if (emitterGraph) {
|
||||||
if (emitterGraph?.hasNode(fp)) {
|
|
||||||
// merge the new dependencies into the dep graph
|
// merge the new dependencies into the dep graph
|
||||||
dependencies[emitter.name]?.updateIncomingEdgesForNode(emitterGraph, fp)
|
dependencies[emitter.name]?.updateIncomingEdgesForNode(emitterGraph, fp)
|
||||||
}
|
}
|
||||||
@ -235,6 +223,7 @@ async function partialRebuildFromEntrypoint(
|
|||||||
// EMIT
|
// EMIT
|
||||||
perf.addEvent("rebuild")
|
perf.addEvent("rebuild")
|
||||||
let emittedFiles = 0
|
let emittedFiles = 0
|
||||||
|
const destinationsToDelete = new Set<FilePath>()
|
||||||
|
|
||||||
for (const emitter of cfg.plugins.emitters) {
|
for (const emitter of cfg.plugins.emitters) {
|
||||||
const depGraph = dependencies[emitter.name]
|
const depGraph = dependencies[emitter.name]
|
||||||
@ -274,6 +263,11 @@ async function partialRebuildFromEntrypoint(
|
|||||||
// and supply [a.md, b.md] to the emitter
|
// and supply [a.md, b.md] to the emitter
|
||||||
const upstreams = [...depGraph.getLeafNodeAncestors(fp)] as FilePath[]
|
const upstreams = [...depGraph.getLeafNodeAncestors(fp)] as FilePath[]
|
||||||
|
|
||||||
|
if (action === "delete" && upstreams.length === 1) {
|
||||||
|
// if there's only one upstream, the destination is solely dependent on this file
|
||||||
|
destinationsToDelete.add(upstreams[0])
|
||||||
|
}
|
||||||
|
|
||||||
const upstreamContent = upstreams
|
const upstreamContent = upstreams
|
||||||
// filter out non-markdown files
|
// filter out non-markdown files
|
||||||
.filter((file) => contentMap.has(file))
|
.filter((file) => contentMap.has(file))
|
||||||
@ -296,26 +290,14 @@ async function partialRebuildFromEntrypoint(
|
|||||||
console.log(`Emitted ${emittedFiles} files to \`${argv.output}\` in ${perf.timeSince("rebuild")}`)
|
console.log(`Emitted ${emittedFiles} files to \`${argv.output}\` in ${perf.timeSince("rebuild")}`)
|
||||||
|
|
||||||
// CLEANUP
|
// CLEANUP
|
||||||
const destinationsToDelete = new Set<FilePath>()
|
// delete files that are solely dependent on this file
|
||||||
|
await rimraf([...destinationsToDelete])
|
||||||
for (const file of toRemove) {
|
for (const file of toRemove) {
|
||||||
// remove from cache
|
// remove from cache
|
||||||
contentMap.delete(file)
|
contentMap.delete(file)
|
||||||
Object.values(dependencies).forEach((depGraph) => {
|
// remove the node from dependency graphs
|
||||||
// remove the node from dependency graphs
|
Object.values(dependencies).forEach((depGraph) => depGraph?.removeNode(file))
|
||||||
depGraph?.removeNode(file)
|
|
||||||
// remove any orphan nodes. eg if a.md is deleted, a.html is orphaned and should be removed
|
|
||||||
const orphanNodes = depGraph?.removeOrphanNodes()
|
|
||||||
orphanNodes?.forEach((node) => {
|
|
||||||
// only delete files that are in the output directory
|
|
||||||
if (node.startsWith(argv.output)) {
|
|
||||||
destinationsToDelete.add(node)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
await rimraf([...destinationsToDelete])
|
|
||||||
|
|
||||||
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
|
|
||||||
|
|
||||||
toRemove.clear()
|
toRemove.clear()
|
||||||
release()
|
release()
|
||||||
@ -369,10 +351,14 @@ async function rebuildFromEntrypoint(
|
|||||||
|
|
||||||
const perf = new PerfTimer()
|
const perf = new PerfTimer()
|
||||||
console.log(chalk.yellow("Detected change, rebuilding..."))
|
console.log(chalk.yellow("Detected change, rebuilding..."))
|
||||||
ctx.buildId = newBuildId()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filesToRebuild = [...toRebuild].filter((fp) => !toRemove.has(fp))
|
const filesToRebuild = [...toRebuild].filter((fp) => !toRemove.has(fp))
|
||||||
|
|
||||||
|
const trackedSlugs = [...new Set([...contentMap.keys(), ...toRebuild, ...trackedAssets])]
|
||||||
|
.filter((fp) => !toRemove.has(fp))
|
||||||
|
.map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath))
|
||||||
|
|
||||||
|
ctx.allSlugs = [...new Set([...initialSlugs, ...trackedSlugs])]
|
||||||
const parsedContent = await parseMarkdown(ctx, filesToRebuild)
|
const parsedContent = await parseMarkdown(ctx, filesToRebuild)
|
||||||
for (const content of parsedContent) {
|
for (const content of parsedContent) {
|
||||||
const [_tree, vfile] = content
|
const [_tree, vfile] = content
|
||||||
@ -386,16 +372,9 @@ async function rebuildFromEntrypoint(
|
|||||||
const parsedFiles = [...contentMap.values()]
|
const parsedFiles = [...contentMap.values()]
|
||||||
const filteredContent = filterContent(ctx, parsedFiles)
|
const filteredContent = filterContent(ctx, parsedFiles)
|
||||||
|
|
||||||
// re-update slugs
|
|
||||||
const trackedSlugs = [...new Set([...contentMap.keys(), ...toRebuild, ...trackedAssets])]
|
|
||||||
.filter((fp) => !toRemove.has(fp))
|
|
||||||
.map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath))
|
|
||||||
|
|
||||||
ctx.allSlugs = [...new Set([...initialSlugs, ...trackedSlugs])]
|
|
||||||
|
|
||||||
// TODO: we can probably traverse the link graph to figure out what's safe to delete here
|
// TODO: we can probably traverse the link graph to figure out what's safe to delete here
|
||||||
// instead of just deleting everything
|
// instead of just deleting everything
|
||||||
await rimraf(path.join(argv.output, ".*"), { glob: true })
|
await rimraf(argv.output)
|
||||||
await emitContent(ctx, filteredContent)
|
await emitContent(ctx, filteredContent)
|
||||||
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
|
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -19,25 +19,6 @@ export type Analytics =
|
|||||||
websiteId: string
|
websiteId: string
|
||||||
host?: string
|
host?: string
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
provider: "goatcounter"
|
|
||||||
websiteId: string
|
|
||||||
host?: string
|
|
||||||
scriptSrc?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
provider: "posthog"
|
|
||||||
apiKey: string
|
|
||||||
host?: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
provider: "tinylytics"
|
|
||||||
siteId: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
provider: "cabin"
|
|
||||||
host?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GlobalConfiguration {
|
export interface GlobalConfiguration {
|
||||||
pageTitle: string
|
pageTitle: string
|
||||||
@ -77,11 +58,10 @@ export interface FullPageLayout {
|
|||||||
header: QuartzComponent[]
|
header: QuartzComponent[]
|
||||||
beforeBody: QuartzComponent[]
|
beforeBody: QuartzComponent[]
|
||||||
pageBody: QuartzComponent
|
pageBody: QuartzComponent
|
||||||
afterBody: QuartzComponent[]
|
|
||||||
left: QuartzComponent[]
|
left: QuartzComponent[]
|
||||||
right: QuartzComponent[]
|
right: QuartzComponent[]
|
||||||
footer: QuartzComponent
|
footer: QuartzComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PageLayout = Pick<FullPageLayout, "beforeBody" | "left" | "right">
|
export type PageLayout = Pick<FullPageLayout, "beforeBody" | "left" | "right">
|
||||||
export type SharedLayout = Pick<FullPageLayout, "head" | "header" | "footer" | "afterBody">
|
export type SharedLayout = Pick<FullPageLayout, "head" | "header" | "footer">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
const ArticleTitle: QuartzComponent = ({ fileData, displayClass }: QuartzComponentProps) => {
|
function ArticleTitle({ fileData, displayClass }: QuartzComponentProps) {
|
||||||
const title = fileData.frontmatter?.title
|
const title = fileData.frontmatter?.title
|
||||||
if (title) {
|
if (title) {
|
||||||
return <h1 class={classNames(displayClass, "article-title")}>{title}</h1>
|
return <h1 class={classNames(displayClass, "article-title")}>{title}</h1>
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import style from "./styles/backlinks.scss"
|
import style from "./styles/backlinks.scss"
|
||||||
import { resolveRelative, simplifySlug } from "../util/path"
|
import { resolveRelative, simplifySlug } from "../util/path"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
const Backlinks: QuartzComponent = ({
|
function Backlinks({ fileData, allFiles, displayClass, cfg }: QuartzComponentProps) {
|
||||||
fileData,
|
|
||||||
allFiles,
|
|
||||||
displayClass,
|
|
||||||
cfg,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
const slug = simplifySlug(fileData.slug!)
|
const slug = simplifySlug(fileData.slug!)
|
||||||
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
|
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
|
||||||
return (
|
return (
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import clipboardScript from "./scripts/clipboard.inline"
|
import clipboardScript from "./scripts/clipboard.inline"
|
||||||
import clipboardStyle from "./styles/clipboard.scss"
|
import clipboardStyle from "./styles/clipboard.scss"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
const Body: QuartzComponent = ({ children }: QuartzComponentProps) => {
|
function Body({ children }: QuartzComponentProps) {
|
||||||
return <div id="quartz-body">{children}</div>
|
return <div id="quartz-body">{children}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import breadcrumbsStyle from "./styles/breadcrumbs.scss"
|
import breadcrumbsStyle from "./styles/breadcrumbs.scss"
|
||||||
import { FullSlug, SimpleSlug, joinSegments, resolveRelative } from "../util/path"
|
import { FullSlug, SimpleSlug, resolveRelative } from "../util/path"
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
@ -54,11 +54,7 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
// computed index of folder name to its associated file data
|
// computed index of folder name to its associated file data
|
||||||
let folderIndex: Map<string, QuartzPluginData> | undefined
|
let folderIndex: Map<string, QuartzPluginData> | undefined
|
||||||
|
|
||||||
const Breadcrumbs: QuartzComponent = ({
|
function Breadcrumbs({ fileData, allFiles, displayClass }: QuartzComponentProps) {
|
||||||
fileData,
|
|
||||||
allFiles,
|
|
||||||
displayClass,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
// Hide crumbs on root if enabled
|
// Hide crumbs on root if enabled
|
||||||
if (options.hideOnRoot && fileData.slug === "index") {
|
if (options.hideOnRoot && fileData.slug === "index") {
|
||||||
return <></>
|
return <></>
|
||||||
@ -72,9 +68,13 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
folderIndex = new Map()
|
folderIndex = new Map()
|
||||||
// construct the index for the first time
|
// construct the index for the first time
|
||||||
for (const file of allFiles) {
|
for (const file of allFiles) {
|
||||||
const folderParts = file.slug?.split("/")
|
if (file.slug?.endsWith("index")) {
|
||||||
if (folderParts?.at(-1) === "index") {
|
const folderParts = file.slug?.split("/")
|
||||||
folderIndex.set(folderParts.slice(0, -1).join("/"), file)
|
// 2nd last to exclude the /index
|
||||||
|
const folderName = folderParts?.at(-2)
|
||||||
|
if (folderName) {
|
||||||
|
folderIndex.set(folderName, file)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,17 +82,13 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
// Split slug into hierarchy/parts
|
// Split slug into hierarchy/parts
|
||||||
const slugParts = fileData.slug?.split("/")
|
const slugParts = fileData.slug?.split("/")
|
||||||
if (slugParts) {
|
if (slugParts) {
|
||||||
// is tag breadcrumb?
|
|
||||||
const isTagPath = slugParts[0] === "tags"
|
|
||||||
|
|
||||||
// full path until current part
|
// full path until current part
|
||||||
let currentPath = ""
|
let currentPath = ""
|
||||||
|
|
||||||
for (let i = 0; i < slugParts.length - 1; i++) {
|
for (let i = 0; i < slugParts.length - 1; i++) {
|
||||||
let curPathSegment = slugParts[i]
|
let curPathSegment = slugParts[i]
|
||||||
|
|
||||||
// Try to resolve frontmatter folder title
|
// Try to resolve frontmatter folder title
|
||||||
const currentFile = folderIndex?.get(slugParts.slice(0, i + 1).join("/"))
|
const currentFile = folderIndex?.get(curPathSegment)
|
||||||
if (currentFile) {
|
if (currentFile) {
|
||||||
const title = currentFile.frontmatter!.title
|
const title = currentFile.frontmatter!.title
|
||||||
if (title !== "index") {
|
if (title !== "index") {
|
||||||
@ -101,15 +97,10 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add current slug to full path
|
// Add current slug to full path
|
||||||
currentPath = joinSegments(currentPath, slugParts[i])
|
currentPath += slugParts[i] + "/"
|
||||||
const includeTrailingSlash = !isTagPath || i < 1
|
|
||||||
|
|
||||||
// Format and add current crumb
|
// Format and add current crumb
|
||||||
const crumb = formatCrumb(
|
const crumb = formatCrumb(curPathSegment, fileData.slug!, currentPath as SimpleSlug)
|
||||||
curPathSegment,
|
|
||||||
fileData.slug!,
|
|
||||||
(currentPath + (includeTrailingSlash ? "/" : "")) as SimpleSlug,
|
|
||||||
)
|
|
||||||
crumbs.push(crumb)
|
crumbs.push(crumb)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +125,5 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Breadcrumbs.css = breadcrumbsStyle
|
Breadcrumbs.css = breadcrumbsStyle
|
||||||
|
|
||||||
return Breadcrumbs
|
return Breadcrumbs
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
|
||||||
import { classNames } from "../util/lang"
|
|
||||||
// @ts-ignore
|
|
||||||
import script from "./scripts/comments.inline"
|
|
||||||
|
|
||||||
type Options = {
|
|
||||||
provider: "giscus"
|
|
||||||
options: {
|
|
||||||
repo: `${string}/${string}`
|
|
||||||
repoId: string
|
|
||||||
category: string
|
|
||||||
categoryId: string
|
|
||||||
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
|
|
||||||
strict?: boolean
|
|
||||||
reactionsEnabled?: boolean
|
|
||||||
inputPosition?: "top" | "bottom"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function boolToStringBool(b: boolean): string {
|
|
||||||
return b ? "1" : "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ((opts: Options) => {
|
|
||||||
const Comments: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
class={classNames(displayClass, "giscus")}
|
|
||||||
data-repo={opts.options.repo}
|
|
||||||
data-repo-id={opts.options.repoId}
|
|
||||||
data-category={opts.options.category}
|
|
||||||
data-category-id={opts.options.categoryId}
|
|
||||||
data-mapping={opts.options.mapping ?? "url"}
|
|
||||||
data-strict={boolToStringBool(opts.options.strict ?? true)}
|
|
||||||
data-reactions-enabled={boolToStringBool(opts.options.reactionsEnabled ?? true)}
|
|
||||||
data-input-position={opts.options.inputPosition ?? "bottom"}
|
|
||||||
></div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Comments.afterDOMLoaded = script
|
|
||||||
|
|
||||||
return Comments
|
|
||||||
}) satisfies QuartzComponentConstructor<Options>
|
|
@ -2,21 +2,16 @@ import { formatDate, getDate } from "./Date"
|
|||||||
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import readingTime from "reading-time"
|
import readingTime from "reading-time"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
import { i18n } from "../i18n"
|
|
||||||
import { JSX } from "preact"
|
|
||||||
import style from "./styles/contentMeta.scss"
|
|
||||||
|
|
||||||
interface ContentMetaOptions {
|
interface ContentMetaOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to display reading time
|
* Whether to display reading time
|
||||||
*/
|
*/
|
||||||
showReadingTime: boolean
|
showReadingTime: boolean
|
||||||
showComma: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: ContentMetaOptions = {
|
const defaultOptions: ContentMetaOptions = {
|
||||||
showReadingTime: true,
|
showReadingTime: true,
|
||||||
showComma: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: Partial<ContentMetaOptions>) => {
|
export default ((opts?: Partial<ContentMetaOptions>) => {
|
||||||
@ -27,7 +22,7 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||||||
const text = fileData.text
|
const text = fileData.text
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
const segments: (string | JSX.Element)[] = []
|
const segments: string[] = []
|
||||||
|
|
||||||
if (fileData.dates) {
|
if (fileData.dates) {
|
||||||
segments.push(formatDate(getDate(cfg, fileData)!, cfg.locale))
|
segments.push(formatDate(getDate(cfg, fileData)!, cfg.locale))
|
||||||
@ -35,26 +30,21 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||||||
|
|
||||||
// Display reading time if enabled
|
// Display reading time if enabled
|
||||||
if (options.showReadingTime) {
|
if (options.showReadingTime) {
|
||||||
const { minutes, words: _words } = readingTime(text)
|
const { text: timeTaken, words: _words } = readingTime(text)
|
||||||
const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({
|
segments.push(timeTaken)
|
||||||
minutes: Math.ceil(minutes),
|
|
||||||
})
|
|
||||||
segments.push(displayedTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const segmentsElements = segments.map((segment) => <span>{segment}</span>)
|
return <p class={classNames(displayClass, "content-meta")}>{segments.join(", ")}</p>
|
||||||
|
|
||||||
return (
|
|
||||||
<p show-comma={options.showComma} class={classNames(displayClass, "content-meta")}>
|
|
||||||
{segmentsElements}
|
|
||||||
</p>
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMetadata.css = style
|
ContentMetadata.css = `
|
||||||
|
.content-meta {
|
||||||
|
margin-top: 0;
|
||||||
|
color: var(--gray);
|
||||||
|
}
|
||||||
|
`
|
||||||
return ContentMetadata
|
return ContentMetadata
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
|
@ -3,44 +3,47 @@
|
|||||||
// see: https://v8.dev/features/modules#defer
|
// see: https://v8.dev/features/modules#defer
|
||||||
import darkmodeScript from "./scripts/darkmode.inline"
|
import darkmodeScript from "./scripts/darkmode.inline"
|
||||||
import styles from "./styles/darkmode.scss"
|
import styles from "./styles/darkmode.scss"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
const Darkmode: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
function Darkmode({ displayClass, cfg }: QuartzComponentProps) {
|
||||||
return (
|
return (
|
||||||
<button class={classNames(displayClass, "darkmode")} id="darkmode">
|
<div class={classNames(displayClass, "darkmode")}>
|
||||||
<svg
|
<input class="toggle" id="darkmode-toggle" type="checkbox" tabIndex={-1} />
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<label id="toggle-label-light" for="darkmode-toggle" tabIndex={-1}>
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
<svg
|
||||||
version="1.1"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
id="dayIcon"
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
x="0px"
|
version="1.1"
|
||||||
y="0px"
|
id="dayIcon"
|
||||||
viewBox="0 0 35 35"
|
x="0px"
|
||||||
style="enable-background:new 0 0 35 35"
|
y="0px"
|
||||||
xmlSpace="preserve"
|
viewBox="0 0 35 35"
|
||||||
aria-label={i18n(cfg.locale).components.themeToggle.darkMode}
|
style="enable-background:new 0 0 35 35"
|
||||||
>
|
xmlSpace="preserve"
|
||||||
<title>{i18n(cfg.locale).components.themeToggle.darkMode}</title>
|
>
|
||||||
<path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path>
|
<title>{i18n(cfg.locale).components.themeToggle.darkMode}</title>
|
||||||
</svg>
|
<path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path>
|
||||||
<svg
|
</svg>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
</label>
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
<label id="toggle-label-dark" for="darkmode-toggle" tabIndex={-1}>
|
||||||
version="1.1"
|
<svg
|
||||||
id="nightIcon"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
x="0px"
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
y="0px"
|
version="1.1"
|
||||||
viewBox="0 0 100 100"
|
id="nightIcon"
|
||||||
style="enable-background:new 0 0 100 100"
|
x="0px"
|
||||||
xmlSpace="preserve"
|
y="0px"
|
||||||
aria-label={i18n(cfg.locale).components.themeToggle.lightMode}
|
viewBox="0 0 100 100"
|
||||||
>
|
style="enable-background:new 0 0 100 100"
|
||||||
<title>{i18n(cfg.locale).components.themeToggle.lightMode}</title>
|
xmlSpace="preserve"
|
||||||
<path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008-14.65,35.369 c0,13.36,5.203,25.921,14.65,35.368s22.008,14.65,35.368,14.65c13.361,0,25.921-5.203,35.369-14.65 c3.872-3.871,7.064-8.328,9.491-13.246C97.826,68.608,97.611,67.309,96.76,66.458z"></path>
|
>
|
||||||
</svg>
|
<title>{i18n(cfg.locale).components.themeToggle.lightMode}</title>
|
||||||
</button>
|
<path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008-14.65,35.369 c0,13.36,5.203,25.921,14.65,35.368s22.008,14.65,35.368,14.65c13.361,0,25.921-5.203,35.369-14.65 c3.872-3.871,7.064-8.328,9.491-13.246C97.826,68.608,97.611,67.309,96.76,66.458z"></path>
|
||||||
|
</svg>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } fro
|
|||||||
export default ((component?: QuartzComponent) => {
|
export default ((component?: QuartzComponent) => {
|
||||||
if (component) {
|
if (component) {
|
||||||
const Component = component
|
const Component = component
|
||||||
const DesktopOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
function DesktopOnly(props: QuartzComponentProps) {
|
||||||
return <Component displayClass="desktop-only" {...props} />
|
return <Component displayClass="desktop-only" {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import explorerStyle from "./styles/explorer.scss"
|
import explorerStyle from "./styles/explorer.scss"
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -44,9 +44,12 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
// memoized
|
// memoized
|
||||||
let fileTree: FileNode
|
let fileTree: FileNode
|
||||||
let jsonTree: string
|
let jsonTree: string
|
||||||
let lastBuildId: string = ""
|
|
||||||
|
|
||||||
function constructFileTree(allFiles: QuartzPluginData[]) {
|
function constructFileTree(allFiles: QuartzPluginData[]) {
|
||||||
|
if (fileTree) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Construct tree from allFiles
|
// Construct tree from allFiles
|
||||||
fileTree = new FileNode("")
|
fileTree = new FileNode("")
|
||||||
allFiles.forEach((file) => fileTree.add(file))
|
allFiles.forEach((file) => fileTree.add(file))
|
||||||
@ -72,18 +75,8 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
jsonTree = JSON.stringify(folders)
|
jsonTree = JSON.stringify(folders)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Explorer: QuartzComponent = ({
|
function Explorer({ cfg, allFiles, displayClass, fileData }: QuartzComponentProps) {
|
||||||
ctx,
|
constructFileTree(allFiles)
|
||||||
cfg,
|
|
||||||
allFiles,
|
|
||||||
displayClass,
|
|
||||||
fileData,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
if (ctx.buildId !== lastBuildId) {
|
|
||||||
lastBuildId = ctx.buildId
|
|
||||||
constructFileTree(allFiles)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "explorer")}>
|
<div class={classNames(displayClass, "explorer")}>
|
||||||
<button
|
<button
|
||||||
@ -93,10 +86,8 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
data-collapsed={opts.folderDefaultState}
|
data-collapsed={opts.folderDefaultState}
|
||||||
data-savestate={opts.useSavedState}
|
data-savestate={opts.useSavedState}
|
||||||
data-tree={jsonTree}
|
data-tree={jsonTree}
|
||||||
aria-controls="explorer-content"
|
|
||||||
aria-expanded={opts.folderDefaultState === "open"}
|
|
||||||
>
|
>
|
||||||
<h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2>
|
<h1>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h1>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="14"
|
width="14"
|
||||||
|
@ -168,8 +168,10 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
|
|||||||
const isDefaultOpen = opts.folderDefaultState === "open"
|
const isDefaultOpen = opts.folderDefaultState === "open"
|
||||||
|
|
||||||
// Calculate current folderPath
|
// Calculate current folderPath
|
||||||
const folderPath = node.name !== "" ? joinSegments(fullPath ?? "", node.name) : ""
|
let folderPath = ""
|
||||||
const href = resolveRelative(fileData.slug!, folderPath as SimpleSlug) + "/"
|
if (node.name !== "") {
|
||||||
|
folderPath = joinSegments(fullPath ?? "", node.name)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -203,7 +205,11 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
|
|||||||
{/* render <a> tag if folderBehavior is "link", otherwise render <button> with collapse click event */}
|
{/* render <a> tag if folderBehavior is "link", otherwise render <button> with collapse click event */}
|
||||||
<div key={node.name} data-folderpath={folderPath}>
|
<div key={node.name} data-folderpath={folderPath}>
|
||||||
{folderBehavior === "link" ? (
|
{folderBehavior === "link" ? (
|
||||||
<a href={href} data-for={node.name} class="folder-title">
|
<a
|
||||||
|
href={resolveRelative(fileData.slug!, folderPath as SimpleSlug)}
|
||||||
|
data-for={node.name}
|
||||||
|
class="folder-title"
|
||||||
|
>
|
||||||
{node.displayName}
|
{node.displayName}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import style from "./styles/footer.scss"
|
import style from "./styles/footer.scss"
|
||||||
import { version } from "../../package.json"
|
import { version } from "../../package.json"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
@ -8,11 +8,12 @@ interface Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: Options) => {
|
export default ((opts?: Options) => {
|
||||||
const Footer: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
function Footer({ displayClass, cfg }: QuartzComponentProps) {
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const links = opts?.links ?? []
|
const links = opts?.links ?? []
|
||||||
return (
|
return (
|
||||||
<footer class={`${displayClass ?? ""}`}>
|
<footer class={`${displayClass ?? ""}`}>
|
||||||
|
<hr />
|
||||||
<p>
|
<p>
|
||||||
{i18n(cfg.locale).components.footer.createdWith}{" "}
|
{i18n(cfg.locale).components.footer.createdWith}{" "}
|
||||||
<a href="https://quartz.jzhao.xyz/">Quartz v{version}</a> © {year}
|
<a href="https://quartz.jzhao.xyz/">Quartz v{version}</a> © {year}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import script from "./scripts/graph.inline"
|
import script from "./scripts/graph.inline"
|
||||||
import style from "./styles/graph.scss"
|
import style from "./styles/graph.scss"
|
||||||
@ -17,7 +17,6 @@ export interface D3Config {
|
|||||||
opacityScale: number
|
opacityScale: number
|
||||||
removeTags: string[]
|
removeTags: string[]
|
||||||
showTags: boolean
|
showTags: boolean
|
||||||
focusOnHover?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GraphOptions {
|
interface GraphOptions {
|
||||||
@ -38,7 +37,6 @@ const defaultOptions: GraphOptions = {
|
|||||||
opacityScale: 1,
|
opacityScale: 1,
|
||||||
showTags: true,
|
showTags: true,
|
||||||
removeTags: [],
|
removeTags: [],
|
||||||
focusOnHover: false,
|
|
||||||
},
|
},
|
||||||
globalGraph: {
|
globalGraph: {
|
||||||
drag: true,
|
drag: true,
|
||||||
@ -52,12 +50,11 @@ const defaultOptions: GraphOptions = {
|
|||||||
opacityScale: 1,
|
opacityScale: 1,
|
||||||
showTags: true,
|
showTags: true,
|
||||||
removeTags: [],
|
removeTags: [],
|
||||||
focusOnHover: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: GraphOptions) => {
|
export default ((opts?: GraphOptions) => {
|
||||||
const Graph: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
function Graph({ displayClass, cfg }: QuartzComponentProps) {
|
||||||
const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph }
|
const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph }
|
||||||
const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph }
|
const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph }
|
||||||
return (
|
return (
|
||||||
@ -65,32 +62,31 @@ export default ((opts?: GraphOptions) => {
|
|||||||
<h3>{i18n(cfg.locale).components.graph.title}</h3>
|
<h3>{i18n(cfg.locale).components.graph.title}</h3>
|
||||||
<div class="graph-outer">
|
<div class="graph-outer">
|
||||||
<div id="graph-container" data-cfg={JSON.stringify(localGraph)}></div>
|
<div id="graph-container" data-cfg={JSON.stringify(localGraph)}></div>
|
||||||
<button id="global-graph-icon" aria-label="Global Graph">
|
<svg
|
||||||
<svg
|
version="1.1"
|
||||||
version="1.1"
|
id="global-graph-icon"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
x="0px"
|
x="0px"
|
||||||
y="0px"
|
y="0px"
|
||||||
viewBox="0 0 55 55"
|
viewBox="0 0 55 55"
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
xmlSpace="preserve"
|
xmlSpace="preserve"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
||||||
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
||||||
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
||||||
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
||||||
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
||||||
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
||||||
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
||||||
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
||||||
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
||||||
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
||||||
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"
|
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="global-graph-outer">
|
<div id="global-graph-outer">
|
||||||
<div id="global-graph-container" data-cfg={JSON.stringify(globalGraph)}></div>
|
<div id="global-graph-container" data-cfg={JSON.stringify(globalGraph)}></div>
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
import { FullSlug, _stripSlashes, joinSegments, pathToRoot } from "../util/path"
|
||||||
import { JSResourceToScriptElement } from "../util/resources"
|
import { JSResourceToScriptElement } from "../util/resources"
|
||||||
import { googleFontHref } from "../util/theme"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
|
||||||
|
|
||||||
export default (() => {
|
export default (() => {
|
||||||
const Head: QuartzComponent = ({ cfg, fileData, externalResources }: QuartzComponentProps) => {
|
function Head({ cfg, fileData, externalResources }: QuartzComponentProps) {
|
||||||
const title = fileData.frontmatter?.title ?? i18n(cfg.locale).propertyDefaults.title
|
const title = fileData.frontmatter?.title ?? i18n(cfg.locale).propertyDefaults.title
|
||||||
const description =
|
const description =
|
||||||
fileData.description?.trim() ?? i18n(cfg.locale).propertyDefaults.description
|
fileData.description?.trim() ?? i18n(cfg.locale).propertyDefaults.description
|
||||||
@ -22,13 +21,6 @@ export default (() => {
|
|||||||
<head>
|
<head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
{cfg.theme.cdnCaching && cfg.theme.fontOrigin === "googleFonts" && (
|
|
||||||
<>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
||||||
<link rel="stylesheet" href={googleFontHref(cfg.theme)} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta property="og:title" content={title} />
|
<meta property="og:title" content={title} />
|
||||||
<meta property="og:description" content={description} />
|
<meta property="og:description" content={description} />
|
||||||
@ -38,6 +30,12 @@ export default (() => {
|
|||||||
<link rel="icon" href={iconPath} />
|
<link rel="icon" href={iconPath} />
|
||||||
<meta name="description" content={description} />
|
<meta name="description" content={description} />
|
||||||
<meta name="generator" content="Quartz" />
|
<meta name="generator" content="Quartz" />
|
||||||
|
{cfg.theme.cdnCaching && (
|
||||||
|
<>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{css.map((href) => (
|
{css.map((href) => (
|
||||||
<link key={href} href={href} rel="stylesheet" type="text/css" spa-preserve />
|
<link key={href} href={href} rel="stylesheet" type="text/css" spa-preserve />
|
||||||
))}
|
))}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
const Header: QuartzComponent = ({ children }: QuartzComponentProps) => {
|
function Header({ children }: QuartzComponentProps) {
|
||||||
return children.length > 0 ? <header>{children}</header> : null
|
return children.length > 0 ? <header>{children}</header> : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } fro
|
|||||||
export default ((component?: QuartzComponent) => {
|
export default ((component?: QuartzComponent) => {
|
||||||
if (component) {
|
if (component) {
|
||||||
const Component = component
|
const Component = component
|
||||||
const MobileOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
function MobileOnly(props: QuartzComponentProps) {
|
||||||
return <Component displayClass="mobile-only" {...props} />
|
return <Component displayClass="mobile-only" {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { FullSlug, resolveRelative } from "../util/path"
|
import { FullSlug, resolveRelative } from "../util/path"
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
import { Date, getDate } from "./Date"
|
import { Date, getDate } from "./Date"
|
||||||
import { QuartzComponent, QuartzComponentProps } from "./types"
|
import { QuartzComponentProps } from "./types"
|
||||||
import { GlobalConfiguration } from "../cfg"
|
import { GlobalConfiguration } from "../cfg"
|
||||||
|
|
||||||
export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
export function byDateAndAlphabetical(
|
||||||
|
cfg: GlobalConfiguration,
|
||||||
export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn {
|
): (f1: QuartzPluginData, f2: QuartzPluginData) => number {
|
||||||
return (f1, f2) => {
|
return (f1, f2) => {
|
||||||
if (f1.dates && f2.dates) {
|
if (f1.dates && f2.dates) {
|
||||||
// sort descending
|
// sort descending
|
||||||
@ -27,12 +27,10 @@ export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
limit?: number
|
limit?: number
|
||||||
sort?: SortFn
|
|
||||||
} & QuartzComponentProps
|
} & QuartzComponentProps
|
||||||
|
|
||||||
export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
|
export function PageList({ cfg, fileData, allFiles, limit }: Props) {
|
||||||
const sorter = sort ?? byDateAndAlphabetical(cfg)
|
let list = allFiles.sort(byDateAndAlphabetical(cfg))
|
||||||
let list = allFiles.sort(sorter)
|
|
||||||
if (limit) {
|
if (limit) {
|
||||||
list = list.slice(0, limit)
|
list = list.slice(0, limit)
|
||||||
}
|
}
|
||||||
@ -46,13 +44,11 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
|
|||||||
return (
|
return (
|
||||||
<li class="section-li">
|
<li class="section-li">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div>
|
{page.dates && (
|
||||||
{page.dates && (
|
<p class="meta">
|
||||||
<p class="meta">
|
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
||||||
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
</p>
|
||||||
</p>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
<h3>
|
<h3>
|
||||||
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
|
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
|
||||||
@ -67,7 +63,7 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
|
|||||||
class="internal tag-link"
|
class="internal tag-link"
|
||||||
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
||||||
>
|
>
|
||||||
{tag}
|
#{tag}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
import { pathToRoot } from "../util/path"
|
import { pathToRoot } from "../util/path"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
|
|
||||||
const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {
|
function PageTitle({ fileData, cfg, displayClass }: QuartzComponentProps) {
|
||||||
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
||||||
const baseDir = pathToRoot(fileData.slug!)
|
const baseDir = pathToRoot(fileData.slug!)
|
||||||
return (
|
return (
|
||||||
<h2 class={classNames(displayClass, "page-title")}>
|
<h1 class={classNames(displayClass, "page-title")}>
|
||||||
<a href={baseDir}>{title}</a>
|
<a href={baseDir}>{title}</a>
|
||||||
</h2>
|
</h1>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
PageTitle.css = `
|
PageTitle.css = `
|
||||||
.page-title {
|
.page-title {
|
||||||
font-size: 1.75rem;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { FullSlug, SimpleSlug, resolveRelative } from "../util/path"
|
import { FullSlug, SimpleSlug, resolveRelative } from "../util/path"
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
import { byDateAndAlphabetical } from "./PageList"
|
import { byDateAndAlphabetical } from "./PageList"
|
||||||
@ -12,7 +12,6 @@ interface Options {
|
|||||||
title?: string
|
title?: string
|
||||||
limit: number
|
limit: number
|
||||||
linkToMore: SimpleSlug | false
|
linkToMore: SimpleSlug | false
|
||||||
showTags: boolean
|
|
||||||
filter: (f: QuartzPluginData) => boolean
|
filter: (f: QuartzPluginData) => boolean
|
||||||
sort: (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
sort: (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
||||||
}
|
}
|
||||||
@ -20,18 +19,12 @@ interface Options {
|
|||||||
const defaultOptions = (cfg: GlobalConfiguration): Options => ({
|
const defaultOptions = (cfg: GlobalConfiguration): Options => ({
|
||||||
limit: 3,
|
limit: 3,
|
||||||
linkToMore: false,
|
linkToMore: false,
|
||||||
showTags: true,
|
|
||||||
filter: () => true,
|
filter: () => true,
|
||||||
sort: byDateAndAlphabetical(cfg),
|
sort: byDateAndAlphabetical(cfg),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default ((userOpts?: Partial<Options>) => {
|
export default ((userOpts?: Partial<Options>) => {
|
||||||
const RecentNotes: QuartzComponent = ({
|
function RecentNotes({ allFiles, fileData, displayClass, cfg }: QuartzComponentProps) {
|
||||||
allFiles,
|
|
||||||
fileData,
|
|
||||||
displayClass,
|
|
||||||
cfg,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
const opts = { ...defaultOptions(cfg), ...userOpts }
|
const opts = { ...defaultOptions(cfg), ...userOpts }
|
||||||
const pages = allFiles.filter(opts.filter).sort(opts.sort)
|
const pages = allFiles.filter(opts.filter).sort(opts.sort)
|
||||||
const remaining = Math.max(0, pages.length - opts.limit)
|
const remaining = Math.max(0, pages.length - opts.limit)
|
||||||
@ -58,20 +51,18 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{opts.showTags && (
|
<ul class="tags">
|
||||||
<ul class="tags">
|
{tags.map((tag) => (
|
||||||
{tags.map((tag) => (
|
<li>
|
||||||
<li>
|
<a
|
||||||
<a
|
class="internal tag-link"
|
||||||
class="internal tag-link"
|
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
||||||
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
>
|
||||||
>
|
#{tag}
|
||||||
{tag}
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
))}
|
||||||
))}
|
</ul>
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import style from "./styles/search.scss"
|
import style from "./styles/search.scss"
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import script from "./scripts/search.inline"
|
import script from "./scripts/search.inline"
|
||||||
@ -14,21 +14,29 @@ const defaultOptions: SearchOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default ((userOpts?: Partial<SearchOptions>) => {
|
export default ((userOpts?: Partial<SearchOptions>) => {
|
||||||
const Search: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
function Search({ displayClass, cfg }: QuartzComponentProps) {
|
||||||
const opts = { ...defaultOptions, ...userOpts }
|
const opts = { ...defaultOptions, ...userOpts }
|
||||||
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder
|
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "search")}>
|
<div class={classNames(displayClass, "search")}>
|
||||||
<button class="search-button" id="search-button">
|
<div id="search-icon">
|
||||||
<p>{i18n(cfg.locale).components.search.title}</p>
|
<p>{i18n(cfg.locale).components.search.title}</p>
|
||||||
<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7">
|
<div></div>
|
||||||
<title>Search</title>
|
<svg
|
||||||
|
tabIndex={0}
|
||||||
|
aria-labelledby="title desc"
|
||||||
|
role="img"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 19.9 19.7"
|
||||||
|
>
|
||||||
|
<title id="title">Search</title>
|
||||||
|
<desc id="desc">Search</desc>
|
||||||
<g class="search-path" fill="none">
|
<g class="search-path" fill="none">
|
||||||
<path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4" />
|
<path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4" />
|
||||||
<circle cx="8" cy="8" r="7" />
|
<circle cx="8" cy="8" r="7" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</div>
|
||||||
<div id="search-container">
|
<div id="search-container">
|
||||||
<div id="search-space">
|
<div id="search-space">
|
||||||
<input
|
<input
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import legacyStyle from "./styles/legacyToc.scss"
|
import legacyStyle from "./styles/legacyToc.scss"
|
||||||
import modernStyle from "./styles/toc.scss"
|
import modernStyle from "./styles/toc.scss"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
@ -15,24 +15,14 @@ const defaultOptions: Options = {
|
|||||||
layout: "modern",
|
layout: "modern",
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableOfContents: QuartzComponent = ({
|
function TableOfContents({ fileData, displayClass, cfg }: QuartzComponentProps) {
|
||||||
fileData,
|
|
||||||
displayClass,
|
|
||||||
cfg,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
if (!fileData.toc) {
|
if (!fileData.toc) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "toc")}>
|
<div class={classNames(displayClass, "toc")}>
|
||||||
<button
|
<button type="button" id="toc" class={fileData.collapseToc ? "collapsed" : ""}>
|
||||||
type="button"
|
|
||||||
id="toc"
|
|
||||||
class={fileData.collapseToc ? "collapsed" : ""}
|
|
||||||
aria-controls="toc-content"
|
|
||||||
aria-expanded={!fileData.collapseToc}
|
|
||||||
>
|
|
||||||
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -49,7 +39,7 @@ const TableOfContents: QuartzComponent = ({
|
|||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div id="toc-content" class={fileData.collapseToc ? "collapsed" : ""}>
|
<div id="toc-content">
|
||||||
<ul class="overflow">
|
<ul class="overflow">
|
||||||
{fileData.toc.map((tocEntry) => (
|
{fileData.toc.map((tocEntry) => (
|
||||||
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
||||||
@ -66,7 +56,7 @@ const TableOfContents: QuartzComponent = ({
|
|||||||
TableOfContents.css = modernStyle
|
TableOfContents.css = modernStyle
|
||||||
TableOfContents.afterDOMLoaded = script
|
TableOfContents.afterDOMLoaded = script
|
||||||
|
|
||||||
const LegacyTableOfContents: QuartzComponent = ({ fileData, cfg }: QuartzComponentProps) => {
|
function LegacyTableOfContents({ fileData, cfg }: QuartzComponentProps) {
|
||||||
if (!fileData.toc) {
|
if (!fileData.toc) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
import { pathToRoot, slugTag } from "../util/path"
|
import { pathToRoot, slugTag } from "../util/path"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
const TagList: QuartzComponent = ({ fileData, displayClass }: QuartzComponentProps) => {
|
function TagList({ fileData, displayClass }: QuartzComponentProps) {
|
||||||
const tags = fileData.frontmatter?.tags
|
const tags = fileData.frontmatter?.tags
|
||||||
const baseDir = pathToRoot(fileData.slug!)
|
const baseDir = pathToRoot(fileData.slug!)
|
||||||
if (tags && tags.length > 0) {
|
if (tags && tags.length > 0) {
|
||||||
return (
|
return (
|
||||||
<ul class={classNames(displayClass, "tags")}>
|
<ul class={classNames(displayClass, "tags")}>
|
||||||
{tags.map((tag) => {
|
{tags.map((tag) => {
|
||||||
|
const display = `#${tag}`
|
||||||
const linkDest = baseDir + `/tags/${slugTag(tag)}`
|
const linkDest = baseDir + `/tags/${slugTag(tag)}`
|
||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<a href={linkDest} class="internal tag-link">
|
<a href={linkDest} class="internal tag-link">
|
||||||
{tag}
|
{display}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,6 @@ import DesktopOnly from "./DesktopOnly"
|
|||||||
import MobileOnly from "./MobileOnly"
|
import MobileOnly from "./MobileOnly"
|
||||||
import RecentNotes from "./RecentNotes"
|
import RecentNotes from "./RecentNotes"
|
||||||
import Breadcrumbs from "./Breadcrumbs"
|
import Breadcrumbs from "./Breadcrumbs"
|
||||||
import Comments from "./Comments"
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ArticleTitle,
|
ArticleTitle,
|
||||||
@ -43,5 +42,4 @@ export {
|
|||||||
RecentNotes,
|
RecentNotes,
|
||||||
NotFound,
|
NotFound,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Comments,
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
import { i18n } from "../../i18n"
|
import { i18n } from "../../i18n"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
import { 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
|
|
||||||
|
|
||||||
|
function NotFound({ cfg }: QuartzComponentProps) {
|
||||||
return (
|
return (
|
||||||
<article class="popover-hint">
|
<article class="popover-hint">
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<p>{i18n(cfg.locale).pages.error.notFound}</p>
|
<p>{i18n(cfg.locale).pages.error.notFound}</p>
|
||||||
<a href={baseDir}>{i18n(cfg.locale).pages.error.home}</a>
|
|
||||||
</article>
|
</article>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { htmlToJsx } from "../../util/jsx"
|
import { htmlToJsx } from "../../util/jsx"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
||||||
|
|
||||||
const Content: QuartzComponent = ({ fileData, tree }: QuartzComponentProps) => {
|
function Content({ fileData, tree }: QuartzComponentProps) {
|
||||||
const content = htmlToJsx(fileData.filePath!, tree)
|
const content = htmlToJsx(fileData.filePath!, tree)
|
||||||
const classes: string[] = fileData.frontmatter?.cssclasses ?? []
|
const classes: string[] = fileData.frontmatter?.cssclasses ?? []
|
||||||
const classString = ["popover-hint", ...classes].join(" ")
|
const classString = ["popover-hint", ...classes].join(" ")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
||||||
import style from "../styles/listPage.scss"
|
import style from "../styles/listPage.scss"
|
||||||
import { PageList, SortFn } from "../PageList"
|
import { PageList } from "../PageList"
|
||||||
import { stripSlashes, simplifySlug } from "../../util/path"
|
import { _stripSlashes, simplifySlug } from "../../util/path"
|
||||||
import { Root } from "hast"
|
import { Root } from "hast"
|
||||||
import { htmlToJsx } from "../../util/jsx"
|
import { htmlToJsx } from "../../util/jsx"
|
||||||
import { i18n } from "../../i18n"
|
import { i18n } from "../../i18n"
|
||||||
@ -13,7 +13,6 @@ interface FolderContentOptions {
|
|||||||
* Whether to display number of folders
|
* Whether to display number of folders
|
||||||
*/
|
*/
|
||||||
showFolderCount: boolean
|
showFolderCount: boolean
|
||||||
sort?: SortFn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: FolderContentOptions = {
|
const defaultOptions: FolderContentOptions = {
|
||||||
@ -23,11 +22,11 @@ const defaultOptions: FolderContentOptions = {
|
|||||||
export default ((opts?: Partial<FolderContentOptions>) => {
|
export default ((opts?: Partial<FolderContentOptions>) => {
|
||||||
const options: FolderContentOptions = { ...defaultOptions, ...opts }
|
const options: FolderContentOptions = { ...defaultOptions, ...opts }
|
||||||
|
|
||||||
const FolderContent: QuartzComponent = (props: QuartzComponentProps) => {
|
function FolderContent(props: QuartzComponentProps) {
|
||||||
const { tree, fileData, allFiles, cfg } = props
|
const { tree, fileData, allFiles, cfg } = props
|
||||||
const folderSlug = stripSlashes(simplifySlug(fileData.slug!))
|
const folderSlug = _stripSlashes(simplifySlug(fileData.slug!))
|
||||||
const allPagesInFolder = allFiles.filter((file) => {
|
const allPagesInFolder = allFiles.filter((file) => {
|
||||||
const fileSlug = stripSlashes(simplifySlug(file.slug!))
|
const fileSlug = _stripSlashes(simplifySlug(file.slug!))
|
||||||
const prefixed = fileSlug.startsWith(folderSlug) && fileSlug !== folderSlug
|
const prefixed = fileSlug.startsWith(folderSlug) && fileSlug !== folderSlug
|
||||||
const folderParts = folderSlug.split(path.posix.sep)
|
const folderParts = folderSlug.split(path.posix.sep)
|
||||||
const fileParts = fileSlug.split(path.posix.sep)
|
const fileParts = fileSlug.split(path.posix.sep)
|
||||||
@ -38,7 +37,6 @@ export default ((opts?: Partial<FolderContentOptions>) => {
|
|||||||
const classes = ["popover-hint", ...cssClasses].join(" ")
|
const classes = ["popover-hint", ...cssClasses].join(" ")
|
||||||
const listProps = {
|
const listProps = {
|
||||||
...props,
|
...props,
|
||||||
sort: options.sort,
|
|
||||||
allFiles: allPagesInFolder,
|
allFiles: allPagesInFolder,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +47,9 @@ export default ((opts?: Partial<FolderContentOptions>) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classes}>
|
<div class={classes}>
|
||||||
<article>{content}</article>
|
<article>
|
||||||
|
<p>{content}</p>
|
||||||
|
</article>
|
||||||
<div class="page-listing">
|
<div class="page-listing">
|
||||||
{options.showFolderCount && (
|
{options.showFolderCount && (
|
||||||
<p>
|
<p>
|
||||||
|
@ -1,127 +1,104 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
||||||
import style from "../styles/listPage.scss"
|
import style from "../styles/listPage.scss"
|
||||||
import { PageList, SortFn } from "../PageList"
|
import { PageList } from "../PageList"
|
||||||
import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path"
|
import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path"
|
||||||
import { QuartzPluginData } from "../../plugins/vfile"
|
import { QuartzPluginData } from "../../plugins/vfile"
|
||||||
import { Root } from "hast"
|
import { Root } from "hast"
|
||||||
import { htmlToJsx } from "../../util/jsx"
|
import { htmlToJsx } from "../../util/jsx"
|
||||||
import { i18n } from "../../i18n"
|
import { i18n } from "../../i18n"
|
||||||
|
|
||||||
interface TagContentOptions {
|
const numPages = 10
|
||||||
sort?: SortFn
|
function TagContent(props: QuartzComponentProps) {
|
||||||
numPages: number
|
const { tree, fileData, allFiles, cfg } = props
|
||||||
}
|
const slug = fileData.slug
|
||||||
|
|
||||||
const defaultOptions: TagContentOptions = {
|
if (!(slug?.startsWith("tags/") || slug === "tags")) {
|
||||||
numPages: 10,
|
throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug}`)
|
||||||
}
|
|
||||||
|
|
||||||
export default ((opts?: Partial<TagContentOptions>) => {
|
|
||||||
const options: TagContentOptions = { ...defaultOptions, ...opts }
|
|
||||||
|
|
||||||
const TagContent: QuartzComponent = (props: QuartzComponentProps) => {
|
|
||||||
const { tree, fileData, allFiles, cfg } = props
|
|
||||||
const slug = fileData.slug
|
|
||||||
|
|
||||||
if (!(slug?.startsWith("tags/") || slug === "tags")) {
|
|
||||||
throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const tag = simplifySlug(slug.slice("tags/".length) as FullSlug)
|
|
||||||
const allPagesWithTag = (tag: string) =>
|
|
||||||
allFiles.filter((file) =>
|
|
||||||
(file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(tag),
|
|
||||||
)
|
|
||||||
|
|
||||||
const content =
|
|
||||||
(tree as Root).children.length === 0
|
|
||||||
? fileData.description
|
|
||||||
: htmlToJsx(fileData.filePath!, tree)
|
|
||||||
const cssClasses: string[] = fileData.frontmatter?.cssclasses ?? []
|
|
||||||
const classes = ["popover-hint", ...cssClasses].join(" ")
|
|
||||||
if (tag === "/") {
|
|
||||||
const tags = [
|
|
||||||
...new Set(
|
|
||||||
allFiles.flatMap((data) => data.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes),
|
|
||||||
),
|
|
||||||
].sort((a, b) => a.localeCompare(b))
|
|
||||||
const tagItemMap: Map<string, QuartzPluginData[]> = new Map()
|
|
||||||
for (const tag of tags) {
|
|
||||||
tagItemMap.set(tag, allPagesWithTag(tag))
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div class={classes}>
|
|
||||||
<article>
|
|
||||||
<p>{content}</p>
|
|
||||||
</article>
|
|
||||||
<p>{i18n(cfg.locale).pages.tagContent.totalTags({ count: tags.length })}</p>
|
|
||||||
<div>
|
|
||||||
{tags.map((tag) => {
|
|
||||||
const pages = tagItemMap.get(tag)!
|
|
||||||
const listProps = {
|
|
||||||
...props,
|
|
||||||
allFiles: pages,
|
|
||||||
}
|
|
||||||
|
|
||||||
const contentPage = allFiles.filter((file) => file.slug === `tags/${tag}`).at(0)
|
|
||||||
|
|
||||||
const root = contentPage?.htmlAst
|
|
||||||
const content =
|
|
||||||
!root || root?.children.length === 0
|
|
||||||
? contentPage?.description
|
|
||||||
: htmlToJsx(contentPage.filePath!, root)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h2>
|
|
||||||
<a class="internal tag-link" href={`../tags/${tag}`}>
|
|
||||||
{tag}
|
|
||||||
</a>
|
|
||||||
</h2>
|
|
||||||
{content && <p>{content}</p>}
|
|
||||||
<div class="page-listing">
|
|
||||||
<p>
|
|
||||||
{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}
|
|
||||||
{pages.length > options.numPages && (
|
|
||||||
<>
|
|
||||||
{" "}
|
|
||||||
<span>
|
|
||||||
{i18n(cfg.locale).pages.tagContent.showingFirst({
|
|
||||||
count: options.numPages,
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
<PageList limit={options.numPages} {...listProps} sort={opts?.sort} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
const pages = allPagesWithTag(tag)
|
|
||||||
const listProps = {
|
|
||||||
...props,
|
|
||||||
allFiles: pages,
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div class={classes}>
|
|
||||||
<article>{content}</article>
|
|
||||||
<div class="page-listing">
|
|
||||||
<p>{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}</p>
|
|
||||||
<div>
|
|
||||||
<PageList {...listProps} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TagContent.css = style + PageList.css
|
const tag = simplifySlug(slug.slice("tags/".length) as FullSlug)
|
||||||
return TagContent
|
const allPagesWithTag = (tag: string) =>
|
||||||
}) satisfies QuartzComponentConstructor
|
allFiles.filter((file) =>
|
||||||
|
(file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(tag),
|
||||||
|
)
|
||||||
|
|
||||||
|
const content =
|
||||||
|
(tree as Root).children.length === 0
|
||||||
|
? fileData.description
|
||||||
|
: htmlToJsx(fileData.filePath!, tree)
|
||||||
|
const cssClasses: string[] = fileData.frontmatter?.cssclasses ?? []
|
||||||
|
const classes = ["popover-hint", ...cssClasses].join(" ")
|
||||||
|
if (tag === "/") {
|
||||||
|
const tags = [
|
||||||
|
...new Set(
|
||||||
|
allFiles.flatMap((data) => data.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes),
|
||||||
|
),
|
||||||
|
].sort((a, b) => a.localeCompare(b))
|
||||||
|
const tagItemMap: Map<string, QuartzPluginData[]> = new Map()
|
||||||
|
for (const tag of tags) {
|
||||||
|
tagItemMap.set(tag, allPagesWithTag(tag))
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div class={classes}>
|
||||||
|
<article>
|
||||||
|
<p>{content}</p>
|
||||||
|
</article>
|
||||||
|
<p>{i18n(cfg.locale).pages.tagContent.totalTags({ count: tags.length })}</p>
|
||||||
|
<div>
|
||||||
|
{tags.map((tag) => {
|
||||||
|
const pages = tagItemMap.get(tag)!
|
||||||
|
const listProps = {
|
||||||
|
...props,
|
||||||
|
allFiles: pages,
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentPage = allFiles.filter((file) => file.slug === `tags/${tag}`)[0]
|
||||||
|
const content = contentPage?.description
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>
|
||||||
|
<a class="internal tag-link" href={`../tags/${tag}`}>
|
||||||
|
#{tag}
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
{content && <p>{content}</p>}
|
||||||
|
<div class="page-listing">
|
||||||
|
<p>
|
||||||
|
{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}
|
||||||
|
{pages.length > numPages && (
|
||||||
|
<span>
|
||||||
|
{i18n(cfg.locale).pages.tagContent.showingFirst({ count: numPages })}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<PageList limit={numPages} {...listProps} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
const pages = allPagesWithTag(tag)
|
||||||
|
const listProps = {
|
||||||
|
...props,
|
||||||
|
allFiles: pages,
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={classes}>
|
||||||
|
<article>{content}</article>
|
||||||
|
<div class="page-listing">
|
||||||
|
<p>{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}</p>
|
||||||
|
<div>
|
||||||
|
<PageList {...listProps} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TagContent.css = style + PageList.css
|
||||||
|
export default (() => TagContent) satisfies QuartzComponentConstructor
|
||||||
|
@ -3,9 +3,10 @@ import { QuartzComponent, QuartzComponentProps } from "./types"
|
|||||||
import HeaderConstructor from "./Header"
|
import HeaderConstructor from "./Header"
|
||||||
import BodyConstructor from "./Body"
|
import BodyConstructor from "./Body"
|
||||||
import { JSResourceToScriptElement, StaticResources } from "../util/resources"
|
import { JSResourceToScriptElement, StaticResources } from "../util/resources"
|
||||||
import { clone, FullSlug, RelativeURL, joinSegments, normalizeHastElement } from "../util/path"
|
import { FullSlug, RelativeURL, joinSegments, normalizeHastElement } from "../util/path"
|
||||||
import { visit } from "unist-util-visit"
|
import { visit } from "unist-util-visit"
|
||||||
import { Root, Element, ElementContent } from "hast"
|
import { Root, Element, ElementContent } from "hast"
|
||||||
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
import { GlobalConfiguration } from "../cfg"
|
import { GlobalConfiguration } from "../cfg"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
|
|
||||||
@ -14,13 +15,11 @@ interface RenderComponents {
|
|||||||
header: QuartzComponent[]
|
header: QuartzComponent[]
|
||||||
beforeBody: QuartzComponent[]
|
beforeBody: QuartzComponent[]
|
||||||
pageBody: QuartzComponent
|
pageBody: QuartzComponent
|
||||||
afterBody: QuartzComponent[]
|
|
||||||
left: QuartzComponent[]
|
left: QuartzComponent[]
|
||||||
right: QuartzComponent[]
|
right: QuartzComponent[]
|
||||||
footer: QuartzComponent
|
footer: QuartzComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerRegex = new RegExp(/h[1-6]/)
|
|
||||||
export function pageResources(
|
export function pageResources(
|
||||||
baseDir: FullSlug | RelativeURL,
|
baseDir: FullSlug | RelativeURL,
|
||||||
staticResources: StaticResources,
|
staticResources: StaticResources,
|
||||||
@ -53,6 +52,18 @@ export function pageResources(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let pageIndex: Map<FullSlug, QuartzPluginData> | undefined = undefined
|
||||||
|
function getOrComputeFileIndex(allFiles: QuartzPluginData[]): Map<FullSlug, QuartzPluginData> {
|
||||||
|
if (!pageIndex) {
|
||||||
|
pageIndex = new Map()
|
||||||
|
for (const file of allFiles) {
|
||||||
|
pageIndex.set(file.slug!, file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageIndex
|
||||||
|
}
|
||||||
|
|
||||||
export function renderPage(
|
export function renderPage(
|
||||||
cfg: GlobalConfiguration,
|
cfg: GlobalConfiguration,
|
||||||
slug: FullSlug,
|
slug: FullSlug,
|
||||||
@ -60,18 +71,14 @@ export function renderPage(
|
|||||||
components: RenderComponents,
|
components: RenderComponents,
|
||||||
pageResources: StaticResources,
|
pageResources: StaticResources,
|
||||||
): string {
|
): string {
|
||||||
// make a deep copy of the tree so we don't remove the transclusion references
|
|
||||||
// for the file cached in contentMap in build.ts
|
|
||||||
const root = clone(componentData.tree) as Root
|
|
||||||
|
|
||||||
// process transcludes in componentData
|
// process transcludes in componentData
|
||||||
visit(root, "element", (node, _index, _parent) => {
|
visit(componentData.tree as Root, "element", (node, _index, _parent) => {
|
||||||
if (node.tagName === "blockquote") {
|
if (node.tagName === "blockquote") {
|
||||||
const classNames = (node.properties?.className ?? []) as string[]
|
const classNames = (node.properties?.className ?? []) as string[]
|
||||||
if (classNames.includes("transclude")) {
|
if (classNames.includes("transclude")) {
|
||||||
const inner = node.children[0] as Element
|
const inner = node.children[0] as Element
|
||||||
const transcludeTarget = inner.properties["data-slug"] as FullSlug
|
const transcludeTarget = inner.properties["data-slug"] as FullSlug
|
||||||
const page = componentData.allFiles.find((f) => f.slug === transcludeTarget)
|
const page = getOrComputeFileIndex(componentData.allFiles).get(transcludeTarget)
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -96,7 +103,7 @@ export function renderPage(
|
|||||||
{
|
{
|
||||||
type: "element",
|
type: "element",
|
||||||
tagName: "a",
|
tagName: "a",
|
||||||
properties: { href: inner.properties?.href, class: ["internal", "transclude-src"] },
|
properties: { href: inner.properties?.href, class: ["internal"] },
|
||||||
children: [
|
children: [
|
||||||
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
||||||
],
|
],
|
||||||
@ -107,24 +114,18 @@ export function renderPage(
|
|||||||
// header transclude
|
// header transclude
|
||||||
blockRef = blockRef.slice(1)
|
blockRef = blockRef.slice(1)
|
||||||
let startIdx = undefined
|
let startIdx = undefined
|
||||||
let startDepth = undefined
|
|
||||||
let endIdx = undefined
|
let endIdx = undefined
|
||||||
for (const [i, el] of page.htmlAst.children.entries()) {
|
for (const [i, el] of page.htmlAst.children.entries()) {
|
||||||
// skip non-headers
|
if (el.type === "element" && el.tagName.match(/h[1-6]/)) {
|
||||||
if (!(el.type === "element" && el.tagName.match(headerRegex))) continue
|
if (endIdx) {
|
||||||
const depth = Number(el.tagName.substring(1))
|
break
|
||||||
|
}
|
||||||
// lookin for our blockref
|
|
||||||
if (startIdx === undefined || startDepth === undefined) {
|
if (startIdx !== undefined) {
|
||||||
// skip until we find the blockref that matches
|
endIdx = i
|
||||||
if (el.properties?.id === blockRef) {
|
} else if (el.properties?.id === blockRef) {
|
||||||
startIdx = i
|
startIdx = i
|
||||||
startDepth = depth
|
|
||||||
}
|
}
|
||||||
} else if (depth <= startDepth) {
|
|
||||||
// looking for new header that is same level or higher
|
|
||||||
endIdx = i
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ export function renderPage(
|
|||||||
{
|
{
|
||||||
type: "element",
|
type: "element",
|
||||||
tagName: "a",
|
tagName: "a",
|
||||||
properties: { href: inner.properties?.href, class: ["internal", "transclude-src"] },
|
properties: { href: inner.properties?.href, class: ["internal"] },
|
||||||
children: [
|
children: [
|
||||||
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
||||||
],
|
],
|
||||||
@ -169,7 +170,7 @@ export function renderPage(
|
|||||||
{
|
{
|
||||||
type: "element",
|
type: "element",
|
||||||
tagName: "a",
|
tagName: "a",
|
||||||
properties: { href: inner.properties?.href, class: ["internal", "transclude-src"] },
|
properties: { href: inner.properties?.href, class: ["internal"] },
|
||||||
children: [
|
children: [
|
||||||
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
|
||||||
],
|
],
|
||||||
@ -180,15 +181,11 @@ export function renderPage(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// set componentData.tree to the edited html that has transclusions rendered
|
|
||||||
componentData.tree = root
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
head: Head,
|
head: Head,
|
||||||
header,
|
header,
|
||||||
beforeBody,
|
beforeBody,
|
||||||
pageBody: Content,
|
pageBody: Content,
|
||||||
afterBody,
|
|
||||||
left,
|
left,
|
||||||
right,
|
right,
|
||||||
footer: Footer,
|
footer: Footer,
|
||||||
@ -212,11 +209,14 @@ export function renderPage(
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
const lang = componentData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
||||||
const doc = (
|
const doc = (
|
||||||
<html lang={lang}>
|
<html lang={lang}>
|
||||||
<Head {...componentData} />
|
<Head {...componentData} />
|
||||||
<body data-slug={slug}>
|
<body
|
||||||
|
data-slug={slug}
|
||||||
|
data-enable-preview={componentData.fileData.frontmatter?.preview ?? true}
|
||||||
|
>
|
||||||
<div id="quartz-root" class="page">
|
<div id="quartz-root" class="page">
|
||||||
<Body {...componentData}>
|
<Body {...componentData}>
|
||||||
{LeftComponent}
|
{LeftComponent}
|
||||||
@ -234,12 +234,6 @@ export function renderPage(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Content {...componentData} />
|
<Content {...componentData} />
|
||||||
<hr />
|
|
||||||
<div class="page-footer">
|
|
||||||
{afterBody.map((BodyComponent) => (
|
|
||||||
<BodyComponent {...componentData} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{RightComponent}
|
{RightComponent}
|
||||||
</Body>
|
</Body>
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
const changeTheme = (e: CustomEventMap["themechange"]) => {
|
|
||||||
const theme = e.detail.theme
|
|
||||||
const iframe = document.querySelector("iframe.giscus-frame") as HTMLIFrameElement
|
|
||||||
if (!iframe) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!iframe.contentWindow) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
iframe.contentWindow.postMessage(
|
|
||||||
{
|
|
||||||
giscus: {
|
|
||||||
setConfig: {
|
|
||||||
theme: theme,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"https://giscus.app",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
type GiscusElement = Omit<HTMLElement, "dataset"> & {
|
|
||||||
dataset: DOMStringMap & {
|
|
||||||
repo: `${string}/${string}`
|
|
||||||
repoId: string
|
|
||||||
category: string
|
|
||||||
categoryId: string
|
|
||||||
mapping: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
|
|
||||||
strict: string
|
|
||||||
reactionsEnabled: string
|
|
||||||
inputPosition: "top" | "bottom"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("nav", () => {
|
|
||||||
const giscusContainer = document.querySelector(".giscus") as GiscusElement
|
|
||||||
if (!giscusContainer) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const giscusScript = document.createElement("script")
|
|
||||||
giscusScript.src = "https://giscus.app/client.js"
|
|
||||||
giscusScript.async = true
|
|
||||||
giscusScript.crossOrigin = "anonymous"
|
|
||||||
giscusScript.setAttribute("data-loading", "lazy")
|
|
||||||
giscusScript.setAttribute("data-emit-metadata", "0")
|
|
||||||
giscusScript.setAttribute("data-repo", giscusContainer.dataset.repo)
|
|
||||||
giscusScript.setAttribute("data-repo-id", giscusContainer.dataset.repoId)
|
|
||||||
giscusScript.setAttribute("data-category", giscusContainer.dataset.category)
|
|
||||||
giscusScript.setAttribute("data-category-id", giscusContainer.dataset.categoryId)
|
|
||||||
giscusScript.setAttribute("data-mapping", giscusContainer.dataset.mapping)
|
|
||||||
giscusScript.setAttribute("data-strict", giscusContainer.dataset.strict)
|
|
||||||
giscusScript.setAttribute("data-reactions-enabled", giscusContainer.dataset.reactionsEnabled)
|
|
||||||
giscusScript.setAttribute("data-input-position", giscusContainer.dataset.inputPosition)
|
|
||||||
|
|
||||||
const theme = document.documentElement.getAttribute("saved-theme")
|
|
||||||
if (theme) {
|
|
||||||
giscusScript.setAttribute("data-theme", theme)
|
|
||||||
}
|
|
||||||
|
|
||||||
giscusContainer.appendChild(giscusScript)
|
|
||||||
|
|
||||||
document.addEventListener("themechange", changeTheme)
|
|
||||||
window.addCleanup(() => document.removeEventListener("themechange", changeTheme))
|
|
||||||
})
|
|
@ -11,8 +11,7 @@ const emitThemeChangeEvent = (theme: "light" | "dark") => {
|
|||||||
|
|
||||||
document.addEventListener("nav", () => {
|
document.addEventListener("nav", () => {
|
||||||
const switchTheme = (e: Event) => {
|
const switchTheme = (e: Event) => {
|
||||||
const newTheme =
|
const newTheme = (e.target as HTMLInputElement)?.checked ? "dark" : "light"
|
||||||
document.documentElement.getAttribute("saved-theme") === "dark" ? "light" : "dark"
|
|
||||||
document.documentElement.setAttribute("saved-theme", newTheme)
|
document.documentElement.setAttribute("saved-theme", newTheme)
|
||||||
localStorage.setItem("theme", newTheme)
|
localStorage.setItem("theme", newTheme)
|
||||||
emitThemeChangeEvent(newTheme)
|
emitThemeChangeEvent(newTheme)
|
||||||
@ -22,13 +21,17 @@ document.addEventListener("nav", () => {
|
|||||||
const newTheme = e.matches ? "dark" : "light"
|
const newTheme = e.matches ? "dark" : "light"
|
||||||
document.documentElement.setAttribute("saved-theme", newTheme)
|
document.documentElement.setAttribute("saved-theme", newTheme)
|
||||||
localStorage.setItem("theme", newTheme)
|
localStorage.setItem("theme", newTheme)
|
||||||
|
toggleSwitch.checked = e.matches
|
||||||
emitThemeChangeEvent(newTheme)
|
emitThemeChangeEvent(newTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Darkmode toggle
|
// Darkmode toggle
|
||||||
const themeButton = document.querySelector("#darkmode") as HTMLButtonElement
|
const toggleSwitch = document.querySelector("#darkmode-toggle") as HTMLInputElement
|
||||||
themeButton.addEventListener("click", switchTheme)
|
toggleSwitch.addEventListener("change", switchTheme)
|
||||||
window.addCleanup(() => themeButton.removeEventListener("click", switchTheme))
|
window.addCleanup(() => toggleSwitch.removeEventListener("change", switchTheme))
|
||||||
|
if (currentTheme === "dark") {
|
||||||
|
toggleSwitch.checked = true
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for changes in prefers-color-scheme
|
// Listen for changes in prefers-color-scheme
|
||||||
const colorSchemeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)")
|
const colorSchemeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)")
|
||||||
|
@ -17,10 +17,6 @@ const observer = new IntersectionObserver((entries) => {
|
|||||||
|
|
||||||
function toggleExplorer(this: HTMLElement) {
|
function toggleExplorer(this: HTMLElement) {
|
||||||
this.classList.toggle("collapsed")
|
this.classList.toggle("collapsed")
|
||||||
this.setAttribute(
|
|
||||||
"aria-expanded",
|
|
||||||
this.getAttribute("aria-expanded") === "true" ? "false" : "true",
|
|
||||||
)
|
|
||||||
const content = this.nextElementSibling as MaybeHTMLElement
|
const content = this.nextElementSibling as MaybeHTMLElement
|
||||||
if (!content) return
|
if (!content) return
|
||||||
|
|
||||||
|
@ -1,54 +1,17 @@
|
|||||||
import type { ContentDetails } from "../../plugins/emitters/contentIndex"
|
import type { ContentDetails, ContentIndex } from "../../plugins/emitters/contentIndex"
|
||||||
import {
|
import * as d3 from "d3"
|
||||||
SimulationNodeDatum,
|
|
||||||
SimulationLinkDatum,
|
|
||||||
Simulation,
|
|
||||||
forceSimulation,
|
|
||||||
forceManyBody,
|
|
||||||
forceCenter,
|
|
||||||
forceLink,
|
|
||||||
forceCollide,
|
|
||||||
zoomIdentity,
|
|
||||||
select,
|
|
||||||
drag,
|
|
||||||
zoom,
|
|
||||||
} from "d3"
|
|
||||||
import { Text, Graphics, Application, Container, Circle } from "pixi.js"
|
|
||||||
import { Group as TweenGroup, Tween as Tweened } from "@tweenjs/tween.js"
|
|
||||||
import { registerEscapeHandler, removeAllChildren } from "./util"
|
import { registerEscapeHandler, removeAllChildren } from "./util"
|
||||||
import { FullSlug, SimpleSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path"
|
import { FullSlug, SimpleSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path"
|
||||||
import { D3Config } from "../Graph"
|
|
||||||
|
|
||||||
type GraphicsInfo = {
|
|
||||||
color: string
|
|
||||||
gfx: Graphics
|
|
||||||
alpha: number
|
|
||||||
active: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type NodeData = {
|
type NodeData = {
|
||||||
id: SimpleSlug
|
id: SimpleSlug
|
||||||
text: string
|
text: string
|
||||||
tags: string[]
|
tags: string[]
|
||||||
} & SimulationNodeDatum
|
} & d3.SimulationNodeDatum
|
||||||
|
|
||||||
type SimpleLinkData = {
|
|
||||||
source: SimpleSlug
|
|
||||||
target: SimpleSlug
|
|
||||||
}
|
|
||||||
|
|
||||||
type LinkData = {
|
type LinkData = {
|
||||||
source: NodeData
|
source: SimpleSlug
|
||||||
target: NodeData
|
target: SimpleSlug
|
||||||
} & SimulationLinkDatum<NodeData>
|
|
||||||
|
|
||||||
type LinkRenderData = GraphicsInfo & {
|
|
||||||
simulationData: LinkData
|
|
||||||
}
|
|
||||||
|
|
||||||
type NodeRenderData = GraphicsInfo & {
|
|
||||||
simulationData: NodeData
|
|
||||||
label: Text
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const localStorageKey = "graph-visited"
|
const localStorageKey = "graph-visited"
|
||||||
@ -62,11 +25,6 @@ function addToVisited(slug: SimpleSlug) {
|
|||||||
localStorage.setItem(localStorageKey, JSON.stringify([...visited]))
|
localStorage.setItem(localStorageKey, JSON.stringify([...visited]))
|
||||||
}
|
}
|
||||||
|
|
||||||
type TweenNode = {
|
|
||||||
update: (time: number) => void
|
|
||||||
stop: () => void
|
|
||||||
}
|
|
||||||
|
|
||||||
async function renderGraph(container: string, fullSlug: FullSlug) {
|
async function renderGraph(container: string, fullSlug: FullSlug) {
|
||||||
const slug = simplifySlug(fullSlug)
|
const slug = simplifySlug(fullSlug)
|
||||||
const visited = getVisited()
|
const visited = getVisited()
|
||||||
@ -86,8 +44,7 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
|||||||
opacityScale,
|
opacityScale,
|
||||||
removeTags,
|
removeTags,
|
||||||
showTags,
|
showTags,
|
||||||
focusOnHover,
|
} = JSON.parse(graph.dataset["cfg"]!)
|
||||||
} = JSON.parse(graph.dataset["cfg"]!) as D3Config
|
|
||||||
|
|
||||||
const data: Map<SimpleSlug, ContentDetails> = new Map(
|
const data: Map<SimpleSlug, ContentDetails> = new Map(
|
||||||
Object.entries<ContentDetails>(await fetchData).map(([k, v]) => [
|
Object.entries<ContentDetails>(await fetchData).map(([k, v]) => [
|
||||||
@ -95,11 +52,10 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
|||||||
v,
|
v,
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
const links: SimpleLinkData[] = []
|
const links: LinkData[] = []
|
||||||
const tags: SimpleSlug[] = []
|
const tags: SimpleSlug[] = []
|
||||||
const validLinks = new Set(data.keys())
|
|
||||||
|
|
||||||
const tweens = new Map<string, TweenNode>()
|
const validLinks = new Set(data.keys())
|
||||||
for (const [source, details] of data.entries()) {
|
for (const [source, details] of data.entries()) {
|
||||||
const outgoing = details.links ?? []
|
const outgoing = details.links ?? []
|
||||||
|
|
||||||
@ -143,459 +99,232 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
|
|||||||
if (showTags) tags.forEach((tag) => neighbourhood.add(tag))
|
if (showTags) tags.forEach((tag) => neighbourhood.add(tag))
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodes = [...neighbourhood].map((url) => {
|
|
||||||
const text = url.startsWith("tags/") ? "#" + url.substring(5) : (data.get(url)?.title ?? url)
|
|
||||||
return {
|
|
||||||
id: url,
|
|
||||||
text,
|
|
||||||
tags: data.get(url)?.tags ?? [],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const graphData: { nodes: NodeData[]; links: LinkData[] } = {
|
const graphData: { nodes: NodeData[]; links: LinkData[] } = {
|
||||||
nodes,
|
nodes: [...neighbourhood].map((url) => {
|
||||||
links: links
|
const text = url.startsWith("tags/") ? "#" + url.substring(5) : data.get(url)?.title ?? url
|
||||||
.filter((l) => neighbourhood.has(l.source) && neighbourhood.has(l.target))
|
return {
|
||||||
.map((l) => ({
|
id: url,
|
||||||
source: nodes.find((n) => n.id === l.source)!,
|
text: text,
|
||||||
target: nodes.find((n) => n.id === l.target)!,
|
tags: data.get(url)?.tags ?? [],
|
||||||
})),
|
}
|
||||||
|
}),
|
||||||
|
links: links.filter((l) => neighbourhood.has(l.source) && neighbourhood.has(l.target)),
|
||||||
}
|
}
|
||||||
|
|
||||||
// we virtualize the simulation and use pixi to actually render it
|
const simulation: d3.Simulation<NodeData, LinkData> = d3
|
||||||
const simulation: Simulation<NodeData, LinkData> = forceSimulation<NodeData>(graphData.nodes)
|
.forceSimulation(graphData.nodes)
|
||||||
.force("charge", forceManyBody().strength(-100 * repelForce))
|
.force("charge", d3.forceManyBody().strength(-100 * repelForce))
|
||||||
.force("center", forceCenter().strength(centerForce))
|
.force(
|
||||||
.force("link", forceLink(graphData.links).distance(linkDistance))
|
"link",
|
||||||
.force("collide", forceCollide<NodeData>((n) => nodeRadius(n)).iterations(3))
|
d3
|
||||||
|
.forceLink(graphData.links)
|
||||||
|
.id((d: any) => d.id)
|
||||||
|
.distance(linkDistance),
|
||||||
|
)
|
||||||
|
.force("center", d3.forceCenter().strength(centerForce))
|
||||||
|
|
||||||
const width = graph.offsetWidth
|
|
||||||
const height = Math.max(graph.offsetHeight, 250)
|
const height = Math.max(graph.offsetHeight, 250)
|
||||||
|
const width = graph.offsetWidth
|
||||||
|
|
||||||
// precompute style prop strings as pixi doesn't support css variables
|
const svg = d3
|
||||||
const cssVars = [
|
.select<HTMLElement, NodeData>("#" + container)
|
||||||
"--secondary",
|
.append("svg")
|
||||||
"--tertiary",
|
.attr("width", width)
|
||||||
"--gray",
|
.attr("height", height)
|
||||||
"--light",
|
.attr("viewBox", [-width / 2 / scale, -height / 2 / scale, width / scale, height / scale])
|
||||||
"--lightgray",
|
|
||||||
"--dark",
|
// draw links between nodes
|
||||||
"--darkgray",
|
const link = svg
|
||||||
"--bodyFont",
|
.append("g")
|
||||||
] as const
|
.selectAll("line")
|
||||||
const computedStyleMap = cssVars.reduce(
|
.data(graphData.links)
|
||||||
(acc, key) => {
|
.join("line")
|
||||||
acc[key] = getComputedStyle(document.documentElement).getPropertyValue(key)
|
.attr("class", "link")
|
||||||
return acc
|
.attr("stroke", "var(--lightgray)")
|
||||||
},
|
.attr("stroke-width", 1)
|
||||||
{} as Record<(typeof cssVars)[number], string>,
|
|
||||||
)
|
// svg groups
|
||||||
|
const graphNode = svg.append("g").selectAll("g").data(graphData.nodes).enter().append("g")
|
||||||
|
|
||||||
// calculate color
|
// calculate color
|
||||||
const color = (d: NodeData) => {
|
const color = (d: NodeData) => {
|
||||||
const isCurrent = d.id === slug
|
const isCurrent = d.id === slug
|
||||||
if (isCurrent) {
|
if (isCurrent) {
|
||||||
return computedStyleMap["--secondary"]
|
return "var(--secondary)"
|
||||||
} else if (visited.has(d.id) || d.id.startsWith("tags/")) {
|
} else if (visited.has(d.id) || d.id.startsWith("tags/")) {
|
||||||
return computedStyleMap["--tertiary"]
|
return "var(--tertiary)"
|
||||||
} else {
|
} else {
|
||||||
return computedStyleMap["--gray"]
|
return "var(--gray)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const drag = (simulation: d3.Simulation<NodeData, LinkData>) => {
|
||||||
|
function dragstarted(event: any, d: NodeData) {
|
||||||
|
if (!event.active) simulation.alphaTarget(1).restart()
|
||||||
|
d.fx = d.x
|
||||||
|
d.fy = d.y
|
||||||
|
}
|
||||||
|
|
||||||
|
function dragged(event: any, d: NodeData) {
|
||||||
|
d.fx = event.x
|
||||||
|
d.fy = event.y
|
||||||
|
}
|
||||||
|
|
||||||
|
function dragended(event: any, d: NodeData) {
|
||||||
|
if (!event.active) simulation.alphaTarget(0)
|
||||||
|
d.fx = null
|
||||||
|
d.fy = null
|
||||||
|
}
|
||||||
|
|
||||||
|
const noop = () => {}
|
||||||
|
return d3
|
||||||
|
.drag<Element, NodeData>()
|
||||||
|
.on("start", enableDrag ? dragstarted : noop)
|
||||||
|
.on("drag", enableDrag ? dragged : noop)
|
||||||
|
.on("end", enableDrag ? dragended : noop)
|
||||||
|
}
|
||||||
|
|
||||||
function nodeRadius(d: NodeData) {
|
function nodeRadius(d: NodeData) {
|
||||||
const numLinks = graphData.links.filter(
|
const numLinks = links.filter((l: any) => l.source.id === d.id || l.target.id === d.id).length
|
||||||
(l) => l.source.id === d.id || l.target.id === d.id,
|
|
||||||
).length
|
|
||||||
return 2 + Math.sqrt(numLinks)
|
return 2 + Math.sqrt(numLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
let hoveredNodeId: string | null = null
|
// draw individual nodes
|
||||||
let hoveredNeighbours: Set<string> = new Set()
|
const node = graphNode
|
||||||
const linkRenderData: LinkRenderData[] = []
|
.append("circle")
|
||||||
const nodeRenderData: NodeRenderData[] = []
|
.attr("class", "node")
|
||||||
function updateHoverInfo(newHoveredId: string | null) {
|
.attr("id", (d) => d.id)
|
||||||
hoveredNodeId = newHoveredId
|
.attr("r", nodeRadius)
|
||||||
|
.attr("fill", color)
|
||||||
if (newHoveredId === null) {
|
.style("cursor", "pointer")
|
||||||
hoveredNeighbours = new Set()
|
.on("click", (_, d) => {
|
||||||
for (const n of nodeRenderData) {
|
const targ = resolveRelative(fullSlug, d.id)
|
||||||
n.active = false
|
window.spaNavigate(new URL(targ, window.location.toString()))
|
||||||
}
|
|
||||||
|
|
||||||
for (const l of linkRenderData) {
|
|
||||||
l.active = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hoveredNeighbours = new Set()
|
|
||||||
for (const l of linkRenderData) {
|
|
||||||
const linkData = l.simulationData
|
|
||||||
if (linkData.source.id === newHoveredId || linkData.target.id === newHoveredId) {
|
|
||||||
hoveredNeighbours.add(linkData.source.id)
|
|
||||||
hoveredNeighbours.add(linkData.target.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
l.active = linkData.source.id === newHoveredId || linkData.target.id === newHoveredId
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const n of nodeRenderData) {
|
|
||||||
n.active = hoveredNeighbours.has(n.simulationData.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let dragStartTime = 0
|
|
||||||
let dragging = false
|
|
||||||
|
|
||||||
function renderLinks() {
|
|
||||||
tweens.get("link")?.stop()
|
|
||||||
const tweenGroup = new TweenGroup()
|
|
||||||
|
|
||||||
for (const l of linkRenderData) {
|
|
||||||
let alpha = 1
|
|
||||||
|
|
||||||
// if we are hovering over a node, we want to highlight the immediate neighbours
|
|
||||||
// with full alpha and the rest with default alpha
|
|
||||||
if (hoveredNodeId) {
|
|
||||||
alpha = l.active ? 1 : 0.2
|
|
||||||
}
|
|
||||||
|
|
||||||
l.color = l.active ? computedStyleMap["--gray"] : computedStyleMap["--lightgray"]
|
|
||||||
tweenGroup.add(new Tweened<LinkRenderData>(l).to({ alpha }, 200))
|
|
||||||
}
|
|
||||||
|
|
||||||
tweenGroup.getAll().forEach((tw) => tw.start())
|
|
||||||
tweens.set("link", {
|
|
||||||
update: tweenGroup.update.bind(tweenGroup),
|
|
||||||
stop() {
|
|
||||||
tweenGroup.getAll().forEach((tw) => tw.stop())
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
.on("mouseover", function (_, d) {
|
||||||
|
const neighbours: SimpleSlug[] = data.get(slug)?.links ?? []
|
||||||
|
const neighbourNodes = d3
|
||||||
|
.selectAll<HTMLElement, NodeData>(".node")
|
||||||
|
.filter((d) => neighbours.includes(d.id))
|
||||||
|
const currentId = d.id
|
||||||
|
const linkNodes = d3
|
||||||
|
.selectAll(".link")
|
||||||
|
.filter((d: any) => d.source.id === currentId || d.target.id === currentId)
|
||||||
|
|
||||||
function renderLabels() {
|
// highlight neighbour nodes
|
||||||
tweens.get("label")?.stop()
|
neighbourNodes.transition().duration(200).attr("fill", color)
|
||||||
const tweenGroup = new TweenGroup()
|
|
||||||
|
|
||||||
const defaultScale = 1 / scale
|
// highlight links
|
||||||
const activeScale = defaultScale * 1.1
|
linkNodes.transition().duration(200).attr("stroke", "var(--gray)").attr("stroke-width", 1)
|
||||||
for (const n of nodeRenderData) {
|
|
||||||
const nodeId = n.simulationData.id
|
|
||||||
|
|
||||||
if (hoveredNodeId === nodeId) {
|
const bigFont = fontSize * 1.5
|
||||||
tweenGroup.add(
|
|
||||||
new Tweened<Text>(n.label).to(
|
|
||||||
{
|
|
||||||
alpha: 1,
|
|
||||||
scale: { x: activeScale, y: activeScale },
|
|
||||||
},
|
|
||||||
100,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
tweenGroup.add(
|
|
||||||
new Tweened<Text>(n.label).to(
|
|
||||||
{
|
|
||||||
alpha: n.label.alpha,
|
|
||||||
scale: { x: defaultScale, y: defaultScale },
|
|
||||||
},
|
|
||||||
100,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tweenGroup.getAll().forEach((tw) => tw.start())
|
// show text for self
|
||||||
tweens.set("label", {
|
const parent = this.parentNode as HTMLElement
|
||||||
update: tweenGroup.update.bind(tweenGroup),
|
d3.select<HTMLElement, NodeData>(parent)
|
||||||
stop() {
|
.raise()
|
||||||
tweenGroup.getAll().forEach((tw) => tw.stop())
|
.select("text")
|
||||||
},
|
.transition()
|
||||||
|
.duration(200)
|
||||||
|
.attr("opacityOld", d3.select(parent).select("text").style("opacity"))
|
||||||
|
.style("opacity", 1)
|
||||||
|
.style("font-size", bigFont + "em")
|
||||||
})
|
})
|
||||||
}
|
.on("mouseleave", function (_, d) {
|
||||||
|
const currentId = d.id
|
||||||
|
const linkNodes = d3
|
||||||
|
.selectAll(".link")
|
||||||
|
.filter((d: any) => d.source.id === currentId || d.target.id === currentId)
|
||||||
|
|
||||||
function renderNodes() {
|
linkNodes.transition().duration(200).attr("stroke", "var(--lightgray)")
|
||||||
tweens.get("hover")?.stop()
|
|
||||||
|
|
||||||
const tweenGroup = new TweenGroup()
|
const parent = this.parentNode as HTMLElement
|
||||||
for (const n of nodeRenderData) {
|
d3.select<HTMLElement, NodeData>(parent)
|
||||||
let alpha = 1
|
.select("text")
|
||||||
|
.transition()
|
||||||
// if we are hovering over a node, we want to highlight the immediate neighbours
|
.duration(200)
|
||||||
if (hoveredNodeId !== null && focusOnHover) {
|
.style("opacity", d3.select(parent).select("text").attr("opacityOld"))
|
||||||
alpha = n.active ? 1 : 0.2
|
.style("font-size", fontSize + "em")
|
||||||
}
|
|
||||||
|
|
||||||
tweenGroup.add(new Tweened<Graphics>(n.gfx, tweenGroup).to({ alpha }, 200))
|
|
||||||
}
|
|
||||||
|
|
||||||
tweenGroup.getAll().forEach((tw) => tw.start())
|
|
||||||
tweens.set("hover", {
|
|
||||||
update: tweenGroup.update.bind(tweenGroup),
|
|
||||||
stop() {
|
|
||||||
tweenGroup.getAll().forEach((tw) => tw.stop())
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
// @ts-ignore
|
||||||
|
.call(drag(simulation))
|
||||||
|
|
||||||
function renderPixiFromD3() {
|
// draw labels
|
||||||
renderNodes()
|
const labels = graphNode
|
||||||
renderLinks()
|
.append("text")
|
||||||
renderLabels()
|
.attr("dx", 0)
|
||||||
}
|
.attr("dy", (d) => -nodeRadius(d) + "px")
|
||||||
|
.attr("text-anchor", "middle")
|
||||||
tweens.forEach((tween) => tween.stop())
|
.text((d) => d.text)
|
||||||
tweens.clear()
|
.style("opacity", (opacityScale - 1) / 3.75)
|
||||||
|
.style("pointer-events", "none")
|
||||||
const app = new Application()
|
.style("font-size", fontSize + "em")
|
||||||
await app.init({
|
.raise()
|
||||||
width,
|
// @ts-ignore
|
||||||
height,
|
.call(drag(simulation))
|
||||||
antialias: true,
|
|
||||||
autoStart: false,
|
|
||||||
autoDensity: true,
|
|
||||||
backgroundAlpha: 0,
|
|
||||||
preference: "webgpu",
|
|
||||||
resolution: window.devicePixelRatio,
|
|
||||||
eventMode: "static",
|
|
||||||
})
|
|
||||||
graph.appendChild(app.canvas)
|
|
||||||
|
|
||||||
const stage = app.stage
|
|
||||||
stage.interactive = false
|
|
||||||
|
|
||||||
const labelsContainer = new Container<Text>({ zIndex: 3 })
|
|
||||||
const nodesContainer = new Container<Graphics>({ zIndex: 2 })
|
|
||||||
const linkContainer = new Container<Graphics>({ zIndex: 1 })
|
|
||||||
stage.addChild(nodesContainer, labelsContainer, linkContainer)
|
|
||||||
|
|
||||||
for (const n of graphData.nodes) {
|
|
||||||
const nodeId = n.id
|
|
||||||
|
|
||||||
const label = new Text({
|
|
||||||
interactive: false,
|
|
||||||
eventMode: "none",
|
|
||||||
text: n.text,
|
|
||||||
alpha: 0,
|
|
||||||
anchor: { x: 0.5, y: 1.2 },
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize * 15,
|
|
||||||
fill: computedStyleMap["--dark"],
|
|
||||||
fontFamily: computedStyleMap["--bodyFont"],
|
|
||||||
},
|
|
||||||
resolution: window.devicePixelRatio * 4,
|
|
||||||
})
|
|
||||||
label.scale.set(1 / scale)
|
|
||||||
|
|
||||||
let oldLabelOpacity = 0
|
|
||||||
const isTagNode = nodeId.startsWith("tags/")
|
|
||||||
const gfx = new Graphics({
|
|
||||||
interactive: true,
|
|
||||||
label: nodeId,
|
|
||||||
eventMode: "static",
|
|
||||||
hitArea: new Circle(0, 0, nodeRadius(n)),
|
|
||||||
cursor: "pointer",
|
|
||||||
})
|
|
||||||
.circle(0, 0, nodeRadius(n))
|
|
||||||
.fill({ color: isTagNode ? computedStyleMap["--light"] : color(n) })
|
|
||||||
.stroke({ width: isTagNode ? 2 : 0, color: color(n) })
|
|
||||||
.on("pointerover", (e) => {
|
|
||||||
updateHoverInfo(e.target.label)
|
|
||||||
oldLabelOpacity = label.alpha
|
|
||||||
if (!dragging) {
|
|
||||||
renderPixiFromD3()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on("pointerleave", () => {
|
|
||||||
updateHoverInfo(null)
|
|
||||||
label.alpha = oldLabelOpacity
|
|
||||||
if (!dragging) {
|
|
||||||
renderPixiFromD3()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
nodesContainer.addChild(gfx)
|
|
||||||
labelsContainer.addChild(label)
|
|
||||||
|
|
||||||
const nodeRenderDatum: NodeRenderData = {
|
|
||||||
simulationData: n,
|
|
||||||
gfx,
|
|
||||||
label,
|
|
||||||
color: color(n),
|
|
||||||
alpha: 1,
|
|
||||||
active: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeRenderData.push(nodeRenderDatum)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const l of graphData.links) {
|
|
||||||
const gfx = new Graphics({ interactive: false, eventMode: "none" })
|
|
||||||
linkContainer.addChild(gfx)
|
|
||||||
|
|
||||||
const linkRenderDatum: LinkRenderData = {
|
|
||||||
simulationData: l,
|
|
||||||
gfx,
|
|
||||||
color: computedStyleMap["--lightgray"],
|
|
||||||
alpha: 1,
|
|
||||||
active: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
linkRenderData.push(linkRenderDatum)
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentTransform = zoomIdentity
|
|
||||||
if (enableDrag) {
|
|
||||||
select<HTMLCanvasElement, NodeData | undefined>(app.canvas).call(
|
|
||||||
drag<HTMLCanvasElement, NodeData | undefined>()
|
|
||||||
.container(() => app.canvas)
|
|
||||||
.subject(() => graphData.nodes.find((n) => n.id === hoveredNodeId))
|
|
||||||
.on("start", function dragstarted(event) {
|
|
||||||
if (!event.active) simulation.alphaTarget(1).restart()
|
|
||||||
event.subject.fx = event.subject.x
|
|
||||||
event.subject.fy = event.subject.y
|
|
||||||
event.subject.__initialDragPos = {
|
|
||||||
x: event.subject.x,
|
|
||||||
y: event.subject.y,
|
|
||||||
fx: event.subject.fx,
|
|
||||||
fy: event.subject.fy,
|
|
||||||
}
|
|
||||||
dragStartTime = Date.now()
|
|
||||||
dragging = true
|
|
||||||
})
|
|
||||||
.on("drag", function dragged(event) {
|
|
||||||
const initPos = event.subject.__initialDragPos
|
|
||||||
event.subject.fx = initPos.x + (event.x - initPos.x) / currentTransform.k
|
|
||||||
event.subject.fy = initPos.y + (event.y - initPos.y) / currentTransform.k
|
|
||||||
})
|
|
||||||
.on("end", function dragended(event) {
|
|
||||||
if (!event.active) simulation.alphaTarget(0)
|
|
||||||
event.subject.fx = null
|
|
||||||
event.subject.fy = null
|
|
||||||
dragging = false
|
|
||||||
|
|
||||||
// if the time between mousedown and mouseup is short, we consider it a click
|
|
||||||
if (Date.now() - dragStartTime < 500) {
|
|
||||||
const node = graphData.nodes.find((n) => n.id === event.subject.id) as NodeData
|
|
||||||
const targ = resolveRelative(fullSlug, node.id)
|
|
||||||
window.spaNavigate(new URL(targ, window.location.toString()))
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
for (const node of nodeRenderData) {
|
|
||||||
node.gfx.on("click", () => {
|
|
||||||
const targ = resolveRelative(fullSlug, node.simulationData.id)
|
|
||||||
window.spaNavigate(new URL(targ, window.location.toString()))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set panning
|
||||||
if (enableZoom) {
|
if (enableZoom) {
|
||||||
select<HTMLCanvasElement, NodeData>(app.canvas).call(
|
svg.call(
|
||||||
zoom<HTMLCanvasElement, NodeData>()
|
d3
|
||||||
|
.zoom<SVGSVGElement, NodeData>()
|
||||||
.extent([
|
.extent([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[width, height],
|
[width, height],
|
||||||
])
|
])
|
||||||
.scaleExtent([0.25, 4])
|
.scaleExtent([0.25, 4])
|
||||||
.on("zoom", ({ transform }) => {
|
.on("zoom", ({ transform }) => {
|
||||||
currentTransform = transform
|
link.attr("transform", transform)
|
||||||
stage.scale.set(transform.k, transform.k)
|
node.attr("transform", transform)
|
||||||
stage.position.set(transform.x, transform.y)
|
|
||||||
|
|
||||||
// zoom adjusts opacity of labels too
|
|
||||||
const scale = transform.k * opacityScale
|
const scale = transform.k * opacityScale
|
||||||
let scaleOpacity = Math.max((scale - 1) / 3.75, 0)
|
const scaledOpacity = Math.max((scale - 1) / 3.75, 0)
|
||||||
const activeNodes = nodeRenderData.filter((n) => n.active).flatMap((n) => n.label)
|
labels.attr("transform", transform).style("opacity", scaledOpacity)
|
||||||
|
|
||||||
for (const label of labelsContainer.children) {
|
|
||||||
if (!activeNodes.includes(label)) {
|
|
||||||
label.alpha = scaleOpacity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function animate(time: number) {
|
// progress the simulation
|
||||||
for (const n of nodeRenderData) {
|
simulation.on("tick", () => {
|
||||||
const { x, y } = n.simulationData
|
link
|
||||||
if (!x || !y) continue
|
.attr("x1", (d: any) => d.source.x)
|
||||||
n.gfx.position.set(x + width / 2, y + height / 2)
|
.attr("y1", (d: any) => d.source.y)
|
||||||
if (n.label) {
|
.attr("x2", (d: any) => d.target.x)
|
||||||
n.label.position.set(x + width / 2, y + height / 2)
|
.attr("y2", (d: any) => d.target.y)
|
||||||
}
|
node.attr("cx", (d: any) => d.x).attr("cy", (d: any) => d.y)
|
||||||
}
|
labels.attr("x", (d: any) => d.x).attr("y", (d: any) => d.y)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
for (const l of linkRenderData) {
|
function renderGlobalGraph() {
|
||||||
const linkData = l.simulationData
|
const slug = getFullSlug(window)
|
||||||
l.gfx.clear()
|
const container = document.getElementById("global-graph-outer")
|
||||||
l.gfx.moveTo(linkData.source.x! + width / 2, linkData.source.y! + height / 2)
|
const sidebar = container?.closest(".sidebar") as HTMLElement
|
||||||
l.gfx
|
container?.classList.add("active")
|
||||||
.lineTo(linkData.target.x! + width / 2, linkData.target.y! + height / 2)
|
if (sidebar) {
|
||||||
.stroke({ alpha: l.alpha, width: 1, color: l.color })
|
sidebar.style.zIndex = "1"
|
||||||
}
|
|
||||||
|
|
||||||
tweens.forEach((t) => t.update(time))
|
|
||||||
app.renderer.render(stage)
|
|
||||||
requestAnimationFrame(animate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const graphAnimationFrameHandle = requestAnimationFrame(animate)
|
renderGraph("global-graph-container", slug)
|
||||||
window.addCleanup(() => cancelAnimationFrame(graphAnimationFrameHandle))
|
|
||||||
|
function hideGlobalGraph() {
|
||||||
|
container?.classList.remove("active")
|
||||||
|
const graph = document.getElementById("global-graph-container")
|
||||||
|
if (sidebar) {
|
||||||
|
sidebar.style.zIndex = "unset"
|
||||||
|
}
|
||||||
|
if (!graph) return
|
||||||
|
removeAllChildren(graph)
|
||||||
|
}
|
||||||
|
|
||||||
|
registerEscapeHandler(container, hideGlobalGraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
const slug = e.detail.url
|
const slug = e.detail.url
|
||||||
addToVisited(simplifySlug(slug))
|
addToVisited(slug)
|
||||||
await renderGraph("graph-container", slug)
|
await renderGraph("graph-container", slug)
|
||||||
|
|
||||||
// Function to re-render the graph when the theme changes
|
|
||||||
const handleThemeChange = () => {
|
|
||||||
renderGraph("graph-container", slug)
|
|
||||||
}
|
|
||||||
|
|
||||||
// event listener for theme change
|
|
||||||
document.addEventListener("themechange", handleThemeChange)
|
|
||||||
|
|
||||||
// cleanup for the event listener
|
|
||||||
window.addCleanup(() => {
|
|
||||||
document.removeEventListener("themechange", handleThemeChange)
|
|
||||||
})
|
|
||||||
|
|
||||||
const container = document.getElementById("global-graph-outer")
|
|
||||||
const sidebar = container?.closest(".sidebar") as HTMLElement
|
|
||||||
|
|
||||||
function renderGlobalGraph() {
|
|
||||||
const slug = getFullSlug(window)
|
|
||||||
container?.classList.add("active")
|
|
||||||
if (sidebar) {
|
|
||||||
sidebar.style.zIndex = "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
renderGraph("global-graph-container", slug)
|
|
||||||
registerEscapeHandler(container, hideGlobalGraph)
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideGlobalGraph() {
|
|
||||||
container?.classList.remove("active")
|
|
||||||
if (sidebar) {
|
|
||||||
sidebar.style.zIndex = "unset"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function shortcutHandler(e: HTMLElementEventMap["keydown"]) {
|
|
||||||
if (e.key === "g" && (e.ctrlKey || e.metaKey) && !e.shiftKey) {
|
|
||||||
e.preventDefault()
|
|
||||||
const globalGraphOpen = container?.classList.contains("active")
|
|
||||||
globalGraphOpen ? hideGlobalGraph() : renderGlobalGraph()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const containerIcon = document.getElementById("global-graph-icon")
|
const containerIcon = document.getElementById("global-graph-icon")
|
||||||
containerIcon?.addEventListener("click", renderGlobalGraph)
|
containerIcon?.addEventListener("click", renderGlobalGraph)
|
||||||
window.addCleanup(() => containerIcon?.removeEventListener("click", renderGlobalGraph))
|
window.addCleanup(() => containerIcon?.removeEventListener("click", renderGlobalGraph))
|
||||||
|
|
||||||
document.addEventListener("keydown", shortcutHandler)
|
|
||||||
window.addCleanup(() => document.removeEventListener("keydown", shortcutHandler))
|
|
||||||
})
|
})
|
||||||
|
@ -3,7 +3,7 @@ import { normalizeRelativeURLs } from "../../util/path"
|
|||||||
|
|
||||||
const p = new DOMParser()
|
const p = new DOMParser()
|
||||||
async function mouseEnterHandler(
|
async function mouseEnterHandler(
|
||||||
this: HTMLAnchorElement,
|
this: HTMLLinkElement,
|
||||||
{ clientX, clientY }: { clientX: number; clientY: number },
|
{ clientX, clientY }: { clientX: number; clientY: number },
|
||||||
) {
|
) {
|
||||||
const link = this
|
const link = this
|
||||||
@ -33,59 +33,39 @@ async function mouseEnterHandler(
|
|||||||
thisUrl.hash = ""
|
thisUrl.hash = ""
|
||||||
thisUrl.search = ""
|
thisUrl.search = ""
|
||||||
const targetUrl = new URL(link.href)
|
const targetUrl = new URL(link.href)
|
||||||
const hash = decodeURIComponent(targetUrl.hash)
|
const hash = targetUrl.hash
|
||||||
targetUrl.hash = ""
|
targetUrl.hash = ""
|
||||||
targetUrl.search = ""
|
targetUrl.search = ""
|
||||||
|
|
||||||
const response = await fetch(`${targetUrl}`).catch((err) => {
|
const contents = await fetch(`${targetUrl}`)
|
||||||
console.error(err)
|
.then((res) => res.text())
|
||||||
})
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
|
||||||
// bailout if another popover exists
|
// bailout if another popover exists
|
||||||
if (hasAlreadyBeenFetched()) {
|
if (hasAlreadyBeenFetched()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response) return
|
if (!contents) return
|
||||||
const [contentType] = response.headers.get("Content-Type")!.split(";")
|
const html = p.parseFromString(contents, "text/html")
|
||||||
const [contentTypeCategory, typeInfo] = contentType.split("/")
|
normalizeRelativeURLs(html, targetUrl)
|
||||||
|
let elts: Element[]
|
||||||
|
if (html.body.dataset.enablePreview === "false") {
|
||||||
|
const noPreview = document.createElement("div")
|
||||||
|
noPreview.innerHTML = `<p>Preview is disabled for this page.</p>`
|
||||||
|
elts = [noPreview]
|
||||||
|
} else elts = [...html.getElementsByClassName("popover-hint")]
|
||||||
|
|
||||||
|
if (elts.length === 0) return
|
||||||
|
|
||||||
const popoverElement = document.createElement("div")
|
const popoverElement = document.createElement("div")
|
||||||
popoverElement.classList.add("popover")
|
popoverElement.classList.add("popover")
|
||||||
const popoverInner = document.createElement("div")
|
const popoverInner = document.createElement("div")
|
||||||
popoverInner.classList.add("popover-inner")
|
popoverInner.classList.add("popover-inner")
|
||||||
popoverElement.appendChild(popoverInner)
|
popoverElement.appendChild(popoverInner)
|
||||||
|
elts.forEach((elt) => popoverInner.appendChild(elt))
|
||||||
popoverInner.dataset.contentType = contentType ?? undefined
|
|
||||||
|
|
||||||
switch (contentTypeCategory) {
|
|
||||||
case "image":
|
|
||||||
const img = document.createElement("img")
|
|
||||||
img.src = targetUrl.toString()
|
|
||||||
img.alt = targetUrl.pathname
|
|
||||||
|
|
||||||
popoverInner.appendChild(img)
|
|
||||||
break
|
|
||||||
case "application":
|
|
||||||
switch (typeInfo) {
|
|
||||||
case "pdf":
|
|
||||||
const pdf = document.createElement("iframe")
|
|
||||||
pdf.src = targetUrl.toString()
|
|
||||||
popoverInner.appendChild(pdf)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
const contents = await response.text()
|
|
||||||
const html = p.parseFromString(contents, "text/html")
|
|
||||||
normalizeRelativeURLs(html, targetUrl)
|
|
||||||
const elts = [...html.getElementsByClassName("popover-hint")]
|
|
||||||
if (elts.length === 0) return
|
|
||||||
|
|
||||||
elts.forEach((elt) => popoverInner.appendChild(elt))
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition(popoverElement)
|
setPosition(popoverElement)
|
||||||
link.appendChild(popoverElement)
|
link.appendChild(popoverElement)
|
||||||
@ -100,7 +80,7 @@ async function mouseEnterHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("nav", () => {
|
document.addEventListener("nav", () => {
|
||||||
const links = [...document.getElementsByClassName("internal")] as HTMLAnchorElement[]
|
const links = [...document.getElementsByClassName("internal")] as HTMLLinkElement[]
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
link.addEventListener("mouseenter", mouseEnterHandler)
|
link.addEventListener("mouseenter", mouseEnterHandler)
|
||||||
window.addCleanup(() => link.removeEventListener("mouseenter", mouseEnterHandler))
|
window.addCleanup(() => link.removeEventListener("mouseenter", mouseEnterHandler))
|
||||||
|
@ -21,7 +21,6 @@ let index = new FlexSearch.Document<Item>({
|
|||||||
encode: encoder,
|
encode: encoder,
|
||||||
document: {
|
document: {
|
||||||
id: "id",
|
id: "id",
|
||||||
tag: "tags",
|
|
||||||
index: [
|
index: [
|
||||||
{
|
{
|
||||||
field: "title",
|
field: "title",
|
||||||
@ -148,7 +147,7 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
const data = await fetchData
|
const data = await fetchData
|
||||||
const container = document.getElementById("search-container")
|
const container = document.getElementById("search-container")
|
||||||
const sidebar = container?.closest(".sidebar") as HTMLElement
|
const sidebar = container?.closest(".sidebar") as HTMLElement
|
||||||
const searchButton = document.getElementById("search-button")
|
const searchIcon = document.getElementById("search-icon")
|
||||||
const searchBar = document.getElementById("search-bar") as HTMLInputElement | null
|
const searchBar = document.getElementById("search-bar") as HTMLInputElement | null
|
||||||
const searchLayout = document.getElementById("search-layout")
|
const searchLayout = document.getElementById("search-layout")
|
||||||
const idDataMap = Object.keys(data) as FullSlug[]
|
const idDataMap = Object.keys(data) as FullSlug[]
|
||||||
@ -191,8 +190,6 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchType = "basic" // reset search type after closing
|
searchType = "basic" // reset search type after closing
|
||||||
|
|
||||||
searchButton?.focus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSearch(searchTypeNew: SearchType) {
|
function showSearch(searchTypeNew: SearchType) {
|
||||||
@ -374,6 +371,11 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
throw new Error(`Could not fetch ${targetUrl}`)
|
throw new Error(`Could not fetch ${targetUrl}`)
|
||||||
}
|
}
|
||||||
const html = p.parseFromString(contents ?? "", "text/html")
|
const html = p.parseFromString(contents ?? "", "text/html")
|
||||||
|
if (html.body.dataset.enablePreview === "false") {
|
||||||
|
const noPreview = document.createElement("div")
|
||||||
|
noPreview.innerHTML = `<p>Preview is disabled for this page.</p>`
|
||||||
|
return [noPreview]
|
||||||
|
}
|
||||||
normalizeRelativeURLs(html, targetUrl)
|
normalizeRelativeURLs(html, targetUrl)
|
||||||
return [...html.getElementsByClassName("popover-hint")]
|
return [...html.getElementsByClassName("popover-hint")]
|
||||||
})
|
})
|
||||||
@ -408,33 +410,11 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
|
|
||||||
let searchResults: FlexSearch.SimpleDocumentSearchResultSetUnit[]
|
let searchResults: FlexSearch.SimpleDocumentSearchResultSetUnit[]
|
||||||
if (searchType === "tags") {
|
if (searchType === "tags") {
|
||||||
currentSearchTerm = currentSearchTerm.substring(1).trim()
|
searchResults = await index.searchAsync({
|
||||||
const separatorIndex = currentSearchTerm.indexOf(" ")
|
query: currentSearchTerm.substring(1),
|
||||||
if (separatorIndex != -1) {
|
limit: numSearchResults,
|
||||||
// search by title and content index and then filter by tag (implemented in flexsearch)
|
index: ["tags"],
|
||||||
const tag = currentSearchTerm.substring(0, separatorIndex)
|
})
|
||||||
const query = currentSearchTerm.substring(separatorIndex + 1).trim()
|
|
||||||
searchResults = await index.searchAsync({
|
|
||||||
query: query,
|
|
||||||
// return at least 10000 documents, so it is enough to filter them by tag (implemented in flexsearch)
|
|
||||||
limit: Math.max(numSearchResults, 10000),
|
|
||||||
index: ["title", "content"],
|
|
||||||
tag: tag,
|
|
||||||
})
|
|
||||||
for (let searchResult of searchResults) {
|
|
||||||
searchResult.result = searchResult.result.slice(0, numSearchResults)
|
|
||||||
}
|
|
||||||
// set search type to basic and remove tag from term for proper highlightning and scroll
|
|
||||||
searchType = "basic"
|
|
||||||
currentSearchTerm = query
|
|
||||||
} else {
|
|
||||||
// default search by tags index
|
|
||||||
searchResults = await index.searchAsync({
|
|
||||||
query: currentSearchTerm,
|
|
||||||
limit: numSearchResults,
|
|
||||||
index: ["tags"],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (searchType === "basic") {
|
} else if (searchType === "basic") {
|
||||||
searchResults = await index.searchAsync({
|
searchResults = await index.searchAsync({
|
||||||
query: currentSearchTerm,
|
query: currentSearchTerm,
|
||||||
@ -460,8 +440,8 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
|
|
||||||
document.addEventListener("keydown", shortcutHandler)
|
document.addEventListener("keydown", shortcutHandler)
|
||||||
window.addCleanup(() => document.removeEventListener("keydown", shortcutHandler))
|
window.addCleanup(() => document.removeEventListener("keydown", shortcutHandler))
|
||||||
searchButton?.addEventListener("click", () => showSearch("basic"))
|
searchIcon?.addEventListener("click", () => showSearch("basic"))
|
||||||
window.addCleanup(() => searchButton?.removeEventListener("click", () => showSearch("basic")))
|
window.addCleanup(() => searchIcon?.removeEventListener("click", () => showSearch("basic")))
|
||||||
searchBar?.addEventListener("input", onType)
|
searchBar?.addEventListener("input", onType)
|
||||||
window.addCleanup(() => searchBar?.removeEventListener("input", onType))
|
window.addCleanup(() => searchBar?.removeEventListener("input", onType))
|
||||||
|
|
||||||
|
@ -16,10 +16,6 @@ const observer = new IntersectionObserver((entries) => {
|
|||||||
|
|
||||||
function toggleToc(this: HTMLElement) {
|
function toggleToc(this: HTMLElement) {
|
||||||
this.classList.toggle("collapsed")
|
this.classList.toggle("collapsed")
|
||||||
this.setAttribute(
|
|
||||||
"aria-expanded",
|
|
||||||
this.getAttribute("aria-expanded") === "true" ? "false" : "true",
|
|
||||||
)
|
|
||||||
const content = this.nextElementSibling as HTMLElement | undefined
|
const content = this.nextElementSibling as HTMLElement | undefined
|
||||||
if (!content) return
|
if (!content) return
|
||||||
content.classList.toggle("collapsed")
|
content.classList.toggle("collapsed")
|
||||||
|
@ -3,7 +3,6 @@ export function registerEscapeHandler(outsideContainer: HTMLElement | null, cb:
|
|||||||
function click(this: HTMLElement, e: HTMLElementEventMap["click"]) {
|
function click(this: HTMLElement, e: HTMLElementEventMap["click"]) {
|
||||||
if (e.target !== this) return
|
if (e.target !== this) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
.content-meta {
|
|
||||||
margin-top: 0;
|
|
||||||
color: var(--gray);
|
|
||||||
|
|
||||||
&[show-comma="true"] {
|
|
||||||
> span:not(:last-child) {
|
|
||||||
margin-right: 8px;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user