mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-20 03:27:57 +01:00
Compare commits
81 Commits
457b77dd48
...
sidebar-du
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0560711ed | ||
|
|
6b05c6ba64 | ||
|
|
50b6c217c6 | ||
|
|
b31acc6f0f | ||
|
|
08b2228a43 | ||
|
|
52a5196f38 | ||
|
|
cdd0be2aa8 | ||
|
|
9de370ae14 | ||
|
|
ae0466eedb | ||
|
|
499adf4a4e | ||
|
|
cd13ce3c47 | ||
|
|
b48aa91728 | ||
|
|
7b052e8844 | ||
|
|
1cfc87652c | ||
|
|
096ef220dc | ||
|
|
bc16822d14 | ||
|
|
7fa9253abc | ||
|
|
996d8d51fa | ||
|
|
951d1dec24 | ||
|
|
51b43a2115 | ||
|
|
c9349457ed | ||
|
|
6d49d97559 | ||
|
|
c9741d00f3 | ||
|
|
73983cfb0e | ||
|
|
52344cd816 | ||
|
|
fec0a62b74 | ||
|
|
e98d97a271 | ||
|
|
c33f96e572 | ||
|
|
0b348a0532 | ||
|
|
59d4b4eddd | ||
|
|
adf442036b | ||
|
|
dc2c4dca08 | ||
|
|
6ba9c7c02a | ||
|
|
8d5b13ee03 | ||
|
|
4d07ac93b4 | ||
|
|
32d3fc0ce8 | ||
|
|
00e860d8e6 | ||
|
|
2acdec323f | ||
|
|
9e58857746 | ||
|
|
4bd714b7be | ||
|
|
78e13bcb40 | ||
|
|
7d49dff074 | ||
|
|
cdebd05dc9 | ||
|
|
2a9290b3df | ||
|
|
771c05ff18 | ||
|
|
6dd772bf00 | ||
|
|
c238dd16d9 | ||
|
|
b34d521293 | ||
|
|
bfd72347cf | ||
|
|
091cc1b05e | ||
|
|
e9b60c7285 | ||
|
|
b1a920e5c0 | ||
|
|
61770d3e50 | ||
|
|
9db66d500e | ||
|
|
ee8c1dc968 | ||
|
|
bb24cd13c7 | ||
|
|
d61fb266c7 | ||
|
|
685c06ce2e | ||
|
|
3ae89a1d16 | ||
|
|
4d6e7ccba9 | ||
|
|
f334e78ed6 | ||
|
|
c5304b35c0 | ||
|
|
99f353968e | ||
|
|
ec4700d522 | ||
|
|
d6f69e830c | ||
|
|
9ee6fe15fd | ||
|
|
a21f588c48 | ||
|
|
2119025513 | ||
|
|
f70e562432 | ||
|
|
9ff6c7a3f5 | ||
|
|
7ca9dd9a70 | ||
|
|
b397dae951 | ||
|
|
23b691f38c | ||
|
|
c18e6cd5bb | ||
|
|
fe2e16d937 | ||
|
|
722b4321db | ||
|
|
9d8d238912 | ||
|
|
141f053b0d | ||
|
|
3027eced6c | ||
|
|
aaa5c8e8e4 | ||
|
|
4e74d11b1a |
43
.github/workflows/build-preview.yaml
vendored
Normal file
43
.github/workflows/build-preview.yaml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: Build Preview Deployment
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-preview:
|
||||||
|
if: ${{ github.repository == 'jackyzha0/quartz' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Build Preview
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- name: Check types and style
|
||||||
|
run: npm run check
|
||||||
|
|
||||||
|
- name: Build Quartz
|
||||||
|
run: npx quartz build -d docs -v
|
||||||
|
|
||||||
|
- name: Upload build artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: preview-build
|
||||||
|
path: public
|
||||||
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 22
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 22
|
||||||
- name: Get package version
|
- name: Get package version
|
||||||
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
||||||
- name: Create release tag
|
- name: Create release tag
|
||||||
|
|||||||
37
.github/workflows/deploy-preview.yaml
vendored
Normal file
37
.github/workflows/deploy-preview.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Upload Preview Deployment
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Build Preview Deployment"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
deployments: write
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-preview:
|
||||||
|
if: ${{ github.repository == 'jackyzha0/quartz' && github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Deploy Preview to Cloudflare Pages
|
||||||
|
steps:
|
||||||
|
- name: Download build artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
id: preview-build-artifact
|
||||||
|
with:
|
||||||
|
name: preview-build
|
||||||
|
path: build
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run-id: ${{ github.event.workflow_run.id }}
|
||||||
|
|
||||||
|
- name: Deploy to Cloudflare Pages
|
||||||
|
uses: AdrianGonz97/refined-cf-pages-action@v1
|
||||||
|
with:
|
||||||
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
githubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
projectName: quartz
|
||||||
|
deploymentName: Branch Preview
|
||||||
|
directory: ${{ steps.preview-build-artifact.outputs.download-path }}
|
||||||
2
.github/workflows/docker-build-push.yaml
vendored
2
.github/workflows/docker-build-push.yaml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
network=host
|
network=host
|
||||||
- name: Install cosign
|
- name: Install cosign
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: sigstore/cosign-installer@v3.8.1
|
uses: sigstore/cosign-installer@v3.8.2
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v20.9.0
|
v22.16.0
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ This part of the configuration concerns anything that can affect the whole 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: 'google', tagId: '<your-google-tag>' }`: use Google Analytics;
|
||||||
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: '<your-plausible-host>' }` (self-hosted): use [Plausible](https://plausible.io/);
|
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: 'https://<your-plausible-host>' }` (self-hosted, make sure to include the `https://` protocol prefix): use [Plausible](https://plausible.io/);
|
||||||
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>' }`: use [Umami](https://umami.is/);
|
- `{ 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: '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: 'posthog', apiKey: '<your-posthog-project-apiKey>', host: '<your-posthog-host>' }`: use [Posthog](https://posthog.com/);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Component.Breadcrumbs({
|
|||||||
spacerSymbol: "❯", // symbol between crumbs
|
spacerSymbol: "❯", // symbol between crumbs
|
||||||
rootName: "Home", // name of first/root element
|
rootName: "Home", // name of first/root element
|
||||||
resolveFrontmatterTitle: true, // whether to resolve folder names through frontmatter titles
|
resolveFrontmatterTitle: true, // whether to resolve folder names through frontmatter titles
|
||||||
hideOnRoot: true, // whether to hide breadcrumbs on root `index.md` page
|
|
||||||
showCurrentPage: true, // whether to display the current page in the breadcrumbs
|
showCurrentPage: true, // whether to display the current page in the breadcrumbs
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ afterBody: [
|
|||||||
category: 'Announcements',
|
category: 'Announcements',
|
||||||
// from data-category-id
|
// from data-category-id
|
||||||
categoryId: 'DIC_kwDOFxRnmM4B-Xg6',
|
categoryId: 'DIC_kwDOFxRnmM4B-Xg6',
|
||||||
|
// from data-lang
|
||||||
|
lang: 'en'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@@ -90,6 +92,10 @@ type Options = {
|
|||||||
// where to put the comment input box relative to the comments
|
// where to put the comment input box relative to the comments
|
||||||
// defaults to 'bottom'
|
// defaults to 'bottom'
|
||||||
inputPosition?: "top" | "bottom"
|
inputPosition?: "top" | "bottom"
|
||||||
|
|
||||||
|
// set your preference language here
|
||||||
|
// defaults to 'en'
|
||||||
|
lang?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ Want to customize it even more?
|
|||||||
- Removing explorer: remove `Component.Explorer()` from `quartz.layout.ts`
|
- Removing explorer: 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: `quartz/components/Explorer.tsx`
|
||||||
- Wrapper (Outer component, generates file tree, etc): `quartz/components/Explorer.tsx`
|
|
||||||
- Explorer node (recursive, either a folder or a file): `quartz/components/ExplorerNode.tsx`
|
|
||||||
- Style: `quartz/components/styles/explorer.scss`
|
- Style: `quartz/components/styles/explorer.scss`
|
||||||
- Script: `quartz/components/scripts/explorer.inline.ts`
|
- Script: `quartz/components/scripts/explorer.inline.ts`
|
||||||
|
|
||||||
@@ -131,7 +129,8 @@ Using this example, the display names of all `FileNodes` (folders + files) will
|
|||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
mapFn: (node) => {
|
mapFn: (node) => {
|
||||||
return (node.displayName = node.displayName.toUpperCase())
|
node.displayName = node.displayName.toUpperCase()
|
||||||
|
return node
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -145,8 +144,12 @@ Note that this example filters on the title but you can also do it via slug or a
|
|||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
filterFn: (node) => {
|
filterFn: (node) => {
|
||||||
// set containing names of everything you want to filter out
|
// set containing names of everything you want to filter out
|
||||||
const omit = new Set(["authoring content", "tags", "hosting"])
|
const omit = new Set(["authoring content", "tags", "advanced"])
|
||||||
return !omit.has(node.data.title.toLowerCase())
|
|
||||||
|
// can also use node.slug or by anything on node.data
|
||||||
|
// note that node.data is only present for files that exist on disk
|
||||||
|
// (e.g. implicit folder nodes that have no associated index.md)
|
||||||
|
return !omit.has(node.displayName.toLowerCase())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -159,7 +162,7 @@ You can access the tags of a file by `node.data.tags`.
|
|||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
filterFn: (node) => {
|
filterFn: (node) => {
|
||||||
// exclude files with the tag "explorerexclude"
|
// exclude files with the tag "explorerexclude"
|
||||||
return node.data.tags.includes("explorerexclude") !== true
|
return node.data.tags?.includes("explorerexclude") !== true
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -183,7 +186,7 @@ Component.Explorer({
|
|||||||
> and passing it in.
|
> and passing it in.
|
||||||
>
|
>
|
||||||
> ```ts title="quartz.layout.ts"
|
> ```ts title="quartz.layout.ts"
|
||||||
> import { Options } from "./quartz/components/ExplorerNode"
|
> import { Options } from "./quartz/components/Explorer"
|
||||||
>
|
>
|
||||||
> export const mapFn: Options["mapFn"] = (node) => {
|
> export const mapFn: Options["mapFn"] = (node) => {
|
||||||
> // implement your function here
|
> // implement your function here
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ There may be some notes you want to avoid publishing as a website. Quartz suppor
|
|||||||
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 [[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.
|
||||||
>
|
|
||||||
> `"!(PublicMedia)**/!(*.md)", "!(*.md)"`
|
|
||||||
|
|
||||||
## `ignorePatterns`
|
## `ignorePatterns`
|
||||||
|
|
||||||
@@ -28,7 +26,7 @@ Common examples include:
|
|||||||
|
|
||||||
- `some/folder`: exclude the entire of `some/folder`
|
- `some/folder`: exclude the entire of `some/folder`
|
||||||
- `*.md`: exclude all files with a `.md` extension
|
- `*.md`: exclude all files with a `.md` extension
|
||||||
- `!*.md` exclude all files that _don't_ have a `.md` extension
|
- `!(*.md)` exclude all files that _don't_ have a `.md` extension. Note that negations _must_ parenthesize the rest of the pattern!
|
||||||
- `**/private`: exclude any files or folders named `private` at any level of nesting
|
- `**/private`: exclude any files or folders named `private` at any level of nesting
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
|
|||||||
44
docs/features/reader mode.md
Normal file
44
docs/features/reader mode.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
title: Reader Mode
|
||||||
|
tags:
|
||||||
|
- component
|
||||||
|
---
|
||||||
|
|
||||||
|
Reader Mode is a feature that allows users to focus on the content by hiding the sidebars and other UI elements. When enabled, it provides a clean, distraction-free reading experience.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Reader Mode is enabled by default. To disable it, you can remove the component from your layout configuration in `quartz.layout.ts`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Remove or comment out this line
|
||||||
|
Component.ReaderMode(),
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The Reader Mode toggle appears as a button with a book icon. When clicked:
|
||||||
|
|
||||||
|
- Sidebars are hidden
|
||||||
|
- Hovering over the content area reveals the sidebars temporarily
|
||||||
|
|
||||||
|
Unlike Dark Mode, Reader Mode state is not persisted between page reloads but is maintained during SPA navigation within the site.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
You can customize the appearance of Reader Mode through CSS variables and styles. The component uses the following classes:
|
||||||
|
|
||||||
|
- `.readermode`: The toggle button
|
||||||
|
- `.readerIcon`: The book icon
|
||||||
|
- `[reader-mode="on"]`: Applied to the root element when Reader Mode is active
|
||||||
|
|
||||||
|
Example customization in your custom CSS:
|
||||||
|
|
||||||
|
```scss
|
||||||
|
.readermode {
|
||||||
|
// Customize the button
|
||||||
|
svg {
|
||||||
|
stroke: var(--custom-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -189,7 +189,7 @@ stages:
|
|||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
image: node:20
|
image: node:22
|
||||||
cache: # Cache modules in between jobs
|
cache: # Cache modules in between jobs
|
||||||
key: $CI_COMMIT_REF_SLUG
|
key: $CI_COMMIT_REF_SLUG
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -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/) v22** and `npm` v10.9.2 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]], [[wikilinks|wikilinks, transclusions]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]], [[comments]] and [many more](./features/) right out of the box
|
||||||
- Hot-reload on configuration edits and incremental rebuilds for content edits
|
- Hot-reload on configuration edits and incremental rebuilds for content edits
|
||||||
- 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
|
||||||
|
|||||||
@@ -41,6 +41,15 @@ Component.Flex({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!note] Overriding behavior
|
||||||
|
> Components inside `Flex` get an additional CSS class `flex-component` that add the `display: flex` property. If you want to override this behavior, you can add a `display` property to the component's CSS class in your custom CSS file.
|
||||||
|
>
|
||||||
|
> ```scss
|
||||||
|
> .flex-component {
|
||||||
|
> display: block; // or any other display type
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
|
||||||
## `MobileOnly` Component
|
## `MobileOnly` Component
|
||||||
|
|
||||||
The `MobileOnly` component is a wrapper that makes its child component only visible on mobile devices. This is useful for creating responsive layouts where certain components should only appear on smaller screens.
|
The `MobileOnly` component is a wrapper that makes its child component only visible on mobile devices. This is useful for creating responsive layouts where certain components should only appear on smaller screens.
|
||||||
@@ -60,3 +69,34 @@ The `DesktopOnly` component is the counterpart to `MobileOnly`. It makes its chi
|
|||||||
```typescript
|
```typescript
|
||||||
Component.DesktopOnly(Component.TableOfContents())
|
Component.DesktopOnly(Component.TableOfContents())
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `ConditionalRender` Component
|
||||||
|
|
||||||
|
The `ConditionalRender` component is a wrapper that conditionally renders its child component based on a provided condition function. This is useful for creating dynamic layouts where components should only appear under certain conditions.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
type ConditionalRenderConfig = {
|
||||||
|
component: QuartzComponent
|
||||||
|
condition: (props: QuartzComponentProps) => boolean
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
Component.ConditionalRender({
|
||||||
|
component: Component.Search(),
|
||||||
|
condition: (props) => props.displayClass !== "fullpage",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
The example above would only render the Search component when the page is not in fullpage mode.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
Component.ConditionalRender({
|
||||||
|
component: Component.Breadcrumbs(),
|
||||||
|
condition: (page) => page.fileData.slug !== "index",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
The example above would hide breadcrumbs on the root `index.md` page.
|
||||||
|
|||||||
19
docs/plugins/Favicon.md
Normal file
19
docs/plugins/Favicon.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: Favicon
|
||||||
|
tags:
|
||||||
|
- plugin/emitter
|
||||||
|
---
|
||||||
|
|
||||||
|
This plugin emits a `favicon.ico` into the `public` folder. It creates the favicon from `icon.png` located in the `quartz/static` folder.
|
||||||
|
The plugin resizes `icon.png` to 48x48px to make it as small as possible.
|
||||||
|
|
||||||
|
> [!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.Favicon()`.
|
||||||
|
- Source: [`quartz/plugins/emitters/favicon.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/favicon.ts).
|
||||||
@@ -23,6 +23,7 @@ This plugin accepts the following configuration options:
|
|||||||
- `enableYouTubeEmbed`: If `true` (default), enables the embedding of YouTube videos and playlists using external image Markdown syntax.
|
- `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.
|
- `enableVideoEmbed`: If `true` (default), enables the embedding of video files.
|
||||||
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content. Defaults to `false`.
|
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content. Defaults to `false`.
|
||||||
|
- `disableBrokenWikilinks`: If `true`, replaces links to non-existent notes with a dimmed, disabled link. Defaults to `false`.
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> Don't remove this plugin if you're using [[Obsidian compatibility|Obsidian]] to author the content!
|
> Don't remove this plugin if you're using [[Obsidian compatibility|Obsidian]] to author the content!
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ npx quartz sync --no-pull
|
|||||||
> [!warning]- `fatal: --[no-]autostash option is only valid with --rebase`
|
> [!warning]- `fatal: --[no-]autostash option is only valid with --rebase`
|
||||||
> You may have an outdated version of `git`. Updating `git` should fix this issue.
|
> You may have an outdated version of `git`. Updating `git` should fix this issue.
|
||||||
|
|
||||||
|
> [!warning]- `fatal: The remote end hung up unexpectedly`
|
||||||
|
> It might be due to Git's default buffer size. You can fix it by increasing the buffer with this command:
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> git config http.postBuffer 524288000
|
||||||
|
> ```
|
||||||
|
|
||||||
In future updates, you can simply run `npx quartz sync` every time you want to push updates to your repository.
|
In future updates, you can simply run `npx quartz sync` every time you want to push updates to your repository.
|
||||||
|
|
||||||
> [!hint] Flags and options
|
> [!hint] Flags and options
|
||||||
|
|||||||
@@ -6,29 +6,18 @@ 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/)
|
|
||||||
- [Morrowind Modding Wiki](https://morrowind-modding.github.io/)
|
|
||||||
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
||||||
- [The Pond](https://turntrout.com/welcome)
|
- [The Pond](https://turntrout.com/welcome)
|
||||||
- [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/)
|
|
||||||
- [Eilleen's Everything Notebook](https://quartz.eilleeenz.com/)
|
- [Eilleen's Everything Notebook](https://quartz.eilleeenz.com/)
|
||||||
- [🧠🌳 Chad's Mind Garden](https://www.chadly.net/)
|
- [Morrowind Modding Wiki](https://morrowind-modding.github.io/)
|
||||||
- [Pedro MC Fernandes's Topo da Mente](https://www.pmcf.xyz/topo-da-mente/)
|
- [Stanford CME 302 Numerical Linear Algebra](https://ericdarve.github.io/NLA/)
|
||||||
- [Mau Camargo's Notkesto](https://notes.camargomau.com/)
|
- [Socratica Toolbox](https://toolbox.socratica.info/)
|
||||||
|
- [A Pattern Language - Christopher Alexander (Architecture)](https://patternlanguage.cc/)
|
||||||
- [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/)
|
||||||
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
||||||
- [Scaling Synthesis - A hypertext research notebook](https://scalingsynthesis.com/)
|
|
||||||
- [Simon's Second Brain: Crafted, Curated, Connected, Compounded](https://brain.ssp.sh/)
|
|
||||||
- [Data Engineering Vault: A Second Brain Knowledge Network](https://vault.ssp.sh/)
|
- [Data Engineering Vault: A Second Brain Knowledge Network](https://vault.ssp.sh/)
|
||||||
- [Data Dictionary 🧠](https://glossary.airbyte.com/)
|
|
||||||
- [🪴Aster's notebook](https://notes.asterhu.com)
|
- [🪴Aster's notebook](https://notes.asterhu.com)
|
||||||
- [Gatekeeper Wiki](https://www.gatekeeper.wiki)
|
- [Gatekeeper Wiki](https://www.gatekeeper.wiki)
|
||||||
- [Ellie's Notes](https://ellie.wtf)
|
- [Ellie's Notes](https://ellie.wtf)
|
||||||
- [🥷🏻🌳🍃 Computer Science & Thinkering Garden](https://notes.yxy.ninja)
|
|
||||||
- [Eledah's Crystalline](https://blog.eledah.ir/)
|
- [Eledah's Crystalline](https://blog.eledah.ir/)
|
||||||
- [🌓 Projects & Privacy - FOSS, tech, law](https://be-far.com)
|
- [🌓 Projects & Privacy - FOSS, tech, law](https://be-far.com)
|
||||||
- [Zen Browser Docs](https://docs.zen-browser.app)
|
|
||||||
- [🪴8cat life](https://8cat.life)
|
|
||||||
|
|||||||
1
index.d.ts
vendored
1
index.d.ts
vendored
@@ -8,6 +8,7 @@ interface CustomEventMap {
|
|||||||
prenav: CustomEvent<{}>
|
prenav: CustomEvent<{}>
|
||||||
nav: CustomEvent<{ url: FullSlug }>
|
nav: CustomEvent<{ url: FullSlug }>
|
||||||
themechange: CustomEvent<{ theme: "light" | "dark" }>
|
themechange: CustomEvent<{ theme: "light" | "dark" }>
|
||||||
|
readermodechange: CustomEvent<{ mode: "on" | "off" }>
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContentIndex = Record<FullSlug, ContentDetails>
|
type ContentIndex = Record<FullSlug, ContentDetails>
|
||||||
|
|||||||
1404
package-lock.json
generated
1404
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
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.5.0",
|
"version": "4.5.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
"profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1"
|
"profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"npm": ">=9.3.1",
|
"npm": ">=10.9.2",
|
||||||
"node": ">=20"
|
"node": ">=22"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"site generator",
|
"site generator",
|
||||||
@@ -35,14 +35,14 @@
|
|||||||
"quartz": "./quartz/bootstrap-cli.mjs"
|
"quartz": "./quartz/bootstrap-cli.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.10.0",
|
"@clack/prompts": "^0.11.0",
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.7.0",
|
||||||
"@myriaddreamin/rehype-typst": "^0.5.4",
|
"@myriaddreamin/rehype-typst": "^0.6.0",
|
||||||
"@napi-rs/simple-git": "0.1.19",
|
"@napi-rs/simple-git": "0.1.19",
|
||||||
"@tweenjs/tween.js": "^25.0.0",
|
"@tweenjs/tween.js": "^25.0.0",
|
||||||
|
"@webgpu/types": "^0.1.61",
|
||||||
"ansi-truncate": "^1.2.0",
|
"ansi-truncate": "^1.2.0",
|
||||||
"async-mutex": "^0.5.0",
|
"async-mutex": "^0.5.0",
|
||||||
"chalk": "^5.4.1",
|
|
||||||
"chokidar": "^4.0.3",
|
"chokidar": "^4.0.3",
|
||||||
"cli-spinner": "^0.2.10",
|
"cli-spinner": "^0.2.10",
|
||||||
"d3": "^7.9.0",
|
"d3": "^7.9.0",
|
||||||
@@ -56,23 +56,23 @@
|
|||||||
"hast-util-to-string": "^3.0.1",
|
"hast-util-to-string": "^3.0.1",
|
||||||
"is-absolute-url": "^4.0.1",
|
"is-absolute-url": "^4.0.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lightningcss": "^1.29.2",
|
"lightningcss": "^1.30.1",
|
||||||
"mdast-util-find-and-replace": "^3.0.2",
|
"mdast-util-find-and-replace": "^3.0.2",
|
||||||
"mdast-util-to-hast": "^13.2.0",
|
"mdast-util-to-hast": "^13.2.0",
|
||||||
"mdast-util-to-string": "^4.0.0",
|
"mdast-util-to-string": "^4.0.0",
|
||||||
"micromorph": "^0.4.5",
|
"micromorph": "^0.4.5",
|
||||||
"minimatch": "^10.0.1",
|
"minimatch": "^10.0.1",
|
||||||
"pixi.js": "^8.8.1",
|
"pixi.js": "^8.9.2",
|
||||||
"preact": "^10.26.4",
|
"preact": "^10.26.7",
|
||||||
"preact-render-to-string": "^6.5.13",
|
"preact-render-to-string": "^6.5.13",
|
||||||
"pretty-bytes": "^6.1.1",
|
"pretty-bytes": "^7.0.0",
|
||||||
"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.2.2",
|
"rehype-citation": "^2.3.1",
|
||||||
"rehype-katex": "^7.0.1",
|
"rehype-katex": "^7.0.1",
|
||||||
"rehype-mathjax": "^7.1.0",
|
"rehype-mathjax": "^7.1.0",
|
||||||
"rehype-pretty-code": "^0.14.0",
|
"rehype-pretty-code": "^0.14.1",
|
||||||
"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",
|
||||||
@@ -81,13 +81,12 @@
|
|||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"remark-parse": "^11.0.0",
|
"remark-parse": "^11.0.0",
|
||||||
"remark-rehype": "^11.1.1",
|
"remark-rehype": "^11.1.2",
|
||||||
"remark-smartypants": "^3.0.2",
|
"remark-smartypants": "^3.0.2",
|
||||||
"rfdc": "^1.4.1",
|
"rfdc": "^1.4.1",
|
||||||
"rimraf": "^6.0.1",
|
"satori": "^0.13.1",
|
||||||
"satori": "^0.12.1",
|
|
||||||
"serve-handler": "^6.1.6",
|
"serve-handler": "^6.1.6",
|
||||||
"sharp": "^0.33.5",
|
"sharp": "^0.34.2",
|
||||||
"shiki": "^1.26.2",
|
"shiki": "^1.26.2",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"to-vfile": "^8.0.0",
|
"to-vfile": "^8.0.0",
|
||||||
@@ -96,21 +95,21 @@
|
|||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
"vfile": "^6.0.3",
|
"vfile": "^6.0.3",
|
||||||
"workerpool": "^9.2.0",
|
"workerpool": "^9.2.0",
|
||||||
"ws": "^8.18.1",
|
"ws": "^8.18.2",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^18.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@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.13.10",
|
"@types/node": "^22.15.23",
|
||||||
"@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.18.0",
|
"@types/ws": "^8.18.1",
|
||||||
"@types/yargs": "^17.0.33",
|
"@types/yargs": "^17.0.33",
|
||||||
"esbuild": "^0.25.1",
|
"esbuild": "^0.25.5",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"tsx": "^4.19.3",
|
"tsx": "^4.19.4",
|
||||||
"typescript": "^5.8.2"
|
"typescript": "^5.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ const config: QuartzConfig = {
|
|||||||
}),
|
}),
|
||||||
Plugin.Assets(),
|
Plugin.Assets(),
|
||||||
Plugin.Static(),
|
Plugin.Static(),
|
||||||
|
Plugin.Favicon(),
|
||||||
Plugin.NotFoundPage(),
|
Plugin.NotFoundPage(),
|
||||||
// Comment out CustomOgImages to speed up build time
|
// Comment out CustomOgImages to speed up build time
|
||||||
Plugin.CustomOgImages(),
|
Plugin.CustomOgImages(),
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ export const sharedPageComponents: SharedLayout = {
|
|||||||
// components for pages that display a single page (e.g. a single note)
|
// components for pages that display a single page (e.g. a single note)
|
||||||
export const defaultContentPageLayout: PageLayout = {
|
export const defaultContentPageLayout: PageLayout = {
|
||||||
beforeBody: [
|
beforeBody: [
|
||||||
Component.Breadcrumbs(),
|
Component.ConditionalRender({
|
||||||
|
component: Component.Breadcrumbs(),
|
||||||
|
condition: (page) => page.fileData.slug !== "index",
|
||||||
|
}),
|
||||||
Component.ArticleTitle(),
|
Component.ArticleTitle(),
|
||||||
Component.ContentMeta(),
|
Component.ContentMeta(),
|
||||||
Component.TagList(),
|
Component.TagList(),
|
||||||
@@ -32,6 +35,7 @@ export const defaultContentPageLayout: PageLayout = {
|
|||||||
grow: true,
|
grow: true,
|
||||||
},
|
},
|
||||||
{ Component: Component.Darkmode() },
|
{ Component: Component.Darkmode() },
|
||||||
|
{ Component: Component.ReaderMode() },
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
Component.Explorer(),
|
Component.Explorer(),
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import sourceMapSupport from "source-map-support"
|
|||||||
sourceMapSupport.install(options)
|
sourceMapSupport.install(options)
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { PerfTimer } from "./util/perf"
|
import { PerfTimer } from "./util/perf"
|
||||||
import { rimraf } from "rimraf"
|
import { rm } from "fs/promises"
|
||||||
import { GlobbyFilterFunction, isGitIgnored } from "globby"
|
import { GlobbyFilterFunction, isGitIgnored } from "globby"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
import { parseMarkdown } from "./processors/parse"
|
import { parseMarkdown } from "./processors/parse"
|
||||||
import { filterContent } from "./processors/filter"
|
import { filterContent } from "./processors/filter"
|
||||||
import { emitContent } from "./processors/emit"
|
import { emitContent } from "./processors/emit"
|
||||||
@@ -67,7 +67,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 rm(output, { recursive: true, force: true })
|
||||||
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")
|
||||||
@@ -85,7 +85,9 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
|||||||
const filteredContent = filterContent(ctx, parsedFiles)
|
const filteredContent = filterContent(ctx, parsedFiles)
|
||||||
|
|
||||||
await emitContent(ctx, filteredContent)
|
await emitContent(ctx, filteredContent)
|
||||||
console.log(chalk.green(`Done processing ${markdownPaths.length} files in ${perf.timeSince()}`))
|
console.log(
|
||||||
|
styleText("green", `Done processing ${markdownPaths.length} files in ${perf.timeSince()}`),
|
||||||
|
)
|
||||||
release()
|
release()
|
||||||
|
|
||||||
if (argv.watch) {
|
if (argv.watch) {
|
||||||
@@ -123,9 +125,10 @@ async function startWatching(
|
|||||||
ctx,
|
ctx,
|
||||||
mut,
|
mut,
|
||||||
contentMap,
|
contentMap,
|
||||||
ignored: (path) => {
|
ignored: (fp) => {
|
||||||
if (gitIgnoredMatcher(path)) return true
|
const pathStr = toPosixPath(fp.toString())
|
||||||
const pathStr = path.toString()
|
if (pathStr.startsWith(".git/")) return true
|
||||||
|
if (gitIgnoredMatcher(pathStr)) return true
|
||||||
for (const pattern of cfg.configuration.ignorePatterns) {
|
for (const pattern of cfg.configuration.ignorePatterns) {
|
||||||
if (minimatch(pathStr, pattern)) {
|
if (minimatch(pathStr, pattern)) {
|
||||||
return true
|
return true
|
||||||
@@ -186,7 +189,7 @@ async function rebuild(changes: ChangeEvent[], clientRefresh: () => void, buildD
|
|||||||
|
|
||||||
const perf = new PerfTimer()
|
const perf = new PerfTimer()
|
||||||
perf.addEvent("rebuild")
|
perf.addEvent("rebuild")
|
||||||
console.log(chalk.yellow("Detected change, rebuilding..."))
|
console.log(styleText("yellow", "Detected change, rebuilding..."))
|
||||||
|
|
||||||
// update changesSinceLastBuild
|
// update changesSinceLastBuild
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
@@ -281,7 +284,7 @@ async function rebuild(changes: ChangeEvent[], clientRefresh: () => void, buildD
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Emitted ${emittedFiles} files to \`${argv.output}\` in ${perf.timeSince("rebuild")}`)
|
console.log(`Emitted ${emittedFiles} files to \`${argv.output}\` in ${perf.timeSince("rebuild")}`)
|
||||||
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
|
console.log(styleText("green", `Done rebuilding in ${perf.timeSince()}`))
|
||||||
changes.splice(0, numChangesInBuild)
|
changes.splice(0, numChangesInBuild)
|
||||||
clientRefresh()
|
clientRefresh()
|
||||||
release()
|
release()
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { promises } from "fs"
|
import { promises } from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import esbuild from "esbuild"
|
import esbuild from "esbuild"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
import { sassPlugin } from "esbuild-sass-plugin"
|
import { sassPlugin } from "esbuild-sass-plugin"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { intro, outro, select, text } from "@clack/prompts"
|
import { intro, outro, select, text } from "@clack/prompts"
|
||||||
import { rimraf } from "rimraf"
|
import { rm } from "fs/promises"
|
||||||
import chokidar from "chokidar"
|
import chokidar from "chokidar"
|
||||||
import prettyBytes from "pretty-bytes"
|
import prettyBytes from "pretty-bytes"
|
||||||
import { execSync, spawnSync } from "child_process"
|
import { execSync, spawnSync } from "child_process"
|
||||||
@@ -48,7 +48,7 @@ function resolveContentPath(contentPath) {
|
|||||||
*/
|
*/
|
||||||
export async function handleCreate(argv) {
|
export async function handleCreate(argv) {
|
||||||
console.log()
|
console.log()
|
||||||
intro(chalk.bgGreen.black(` Quartz v${version} `))
|
intro(styleText(["bgGreen", "black"], ` Quartz v${version} `))
|
||||||
const contentFolder = resolveContentPath(argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
let setupStrategy = argv.strategy?.toLowerCase()
|
let setupStrategy = argv.strategy?.toLowerCase()
|
||||||
let linkResolutionStrategy = argv.links?.toLowerCase()
|
let linkResolutionStrategy = argv.links?.toLowerCase()
|
||||||
@@ -61,12 +61,16 @@ export async function handleCreate(argv) {
|
|||||||
// Error handling
|
// Error handling
|
||||||
if (!sourceDirectory) {
|
if (!sourceDirectory) {
|
||||||
outro(
|
outro(
|
||||||
chalk.red(
|
styleText(
|
||||||
`Setup strategies (arg '${chalk.yellow(
|
"red",
|
||||||
|
`Setup strategies (arg '${styleText(
|
||||||
|
"yellow",
|
||||||
`-${CreateArgv.strategy.alias[0]}`,
|
`-${CreateArgv.strategy.alias[0]}`,
|
||||||
)}') other than '${chalk.yellow(
|
)}') other than '${styleText(
|
||||||
|
"yellow",
|
||||||
"new",
|
"new",
|
||||||
)}' require content folder argument ('${chalk.yellow(
|
)}' require content folder argument ('${styleText(
|
||||||
|
"yellow",
|
||||||
`-${CreateArgv.source.alias[0]}`,
|
`-${CreateArgv.source.alias[0]}`,
|
||||||
)}') to be set`,
|
)}') to be set`,
|
||||||
),
|
),
|
||||||
@@ -75,19 +79,23 @@ export async function handleCreate(argv) {
|
|||||||
} else {
|
} else {
|
||||||
if (!fs.existsSync(sourceDirectory)) {
|
if (!fs.existsSync(sourceDirectory)) {
|
||||||
outro(
|
outro(
|
||||||
chalk.red(
|
styleText(
|
||||||
`Input directory to copy/symlink 'content' from not found ('${chalk.yellow(
|
"red",
|
||||||
|
`Input directory to copy/symlink 'content' from not found ('${styleText(
|
||||||
|
"yellow",
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
)}', invalid argument "${chalk.yellow(`-${CreateArgv.source.alias[0]}`)})`,
|
)}', invalid argument "${styleText("yellow", `-${CreateArgv.source.alias[0]}`)})`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} else if (!fs.lstatSync(sourceDirectory).isDirectory()) {
|
} else if (!fs.lstatSync(sourceDirectory).isDirectory()) {
|
||||||
outro(
|
outro(
|
||||||
chalk.red(
|
styleText(
|
||||||
`Source directory to copy/symlink 'content' from is not a directory (found file at '${chalk.yellow(
|
"red",
|
||||||
|
`Source directory to copy/symlink 'content' from is not a directory (found file at '${styleText(
|
||||||
|
"yellow",
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
)}', invalid argument ${chalk.yellow(`-${CreateArgv.source.alias[0]}`)}")`,
|
)}', invalid argument ${styleText("yellow", `-${CreateArgv.source.alias[0]}`)}")`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
@@ -119,7 +127,7 @@ export async function handleCreate(argv) {
|
|||||||
if (contentStat.isSymbolicLink()) {
|
if (contentStat.isSymbolicLink()) {
|
||||||
await fs.promises.unlink(contentFolder)
|
await fs.promises.unlink(contentFolder)
|
||||||
} else {
|
} else {
|
||||||
await rimraf(contentFolder)
|
await rm(contentFolder, { recursive: true, force: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +237,7 @@ export async function handleBuild(argv) {
|
|||||||
argv.watch = true
|
argv.watch = true
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
console.log(`\n${styleText(["bgGreen", "black"], ` Quartz v${version} `)} \n`)
|
||||||
const ctx = await esbuild.context({
|
const ctx = await esbuild.context({
|
||||||
entryPoints: [fp],
|
entryPoints: [fp],
|
||||||
outfile: cacheFile,
|
outfile: cacheFile,
|
||||||
@@ -304,13 +312,13 @@ export async function handleBuild(argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cleanupBuild) {
|
if (cleanupBuild) {
|
||||||
console.log(chalk.yellow("Detected a source code change, doing a hard rebuild..."))
|
console.log(styleText("yellow", "Detected a source code change, doing a hard rebuild..."))
|
||||||
await cleanupBuild()
|
await cleanupBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await ctx.rebuild().catch((err) => {
|
const result = await ctx.rebuild().catch((err) => {
|
||||||
console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`)
|
console.error(`${styleText("red", "Couldn't parse Quartz configuration:")} ${fp}`)
|
||||||
console.log(`Reason: ${chalk.grey(err)}`)
|
console.log(`Reason: ${styleText("grey", err)}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
release()
|
release()
|
||||||
@@ -348,7 +356,8 @@ export async function handleBuild(argv) {
|
|||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
if (argv.baseDir && !req.url?.startsWith(argv.baseDir)) {
|
if (argv.baseDir && !req.url?.startsWith(argv.baseDir)) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.red(
|
styleText(
|
||||||
|
"red",
|
||||||
`[404] ${req.url} (warning: link outside of site, this is likely a Quartz bug)`,
|
`[404] ${req.url} (warning: link outside of site, this is likely a Quartz bug)`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -383,8 +392,10 @@ export async function handleBuild(argv) {
|
|||||||
})
|
})
|
||||||
const status = res.statusCode
|
const status = res.statusCode
|
||||||
const statusString =
|
const statusString =
|
||||||
status >= 200 && status < 300 ? chalk.green(`[${status}]`) : chalk.red(`[${status}]`)
|
status >= 200 && status < 300
|
||||||
console.log(statusString + chalk.grey(` ${argv.baseDir}${req.url}`))
|
? styleText("green", `[${status}]`)
|
||||||
|
: styleText("red", `[${status}]`)
|
||||||
|
console.log(statusString + styleText("grey", ` ${argv.baseDir}${req.url}`))
|
||||||
release()
|
release()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +404,10 @@ export async function handleBuild(argv) {
|
|||||||
res.writeHead(302, {
|
res.writeHead(302, {
|
||||||
Location: newFp,
|
Location: newFp,
|
||||||
})
|
})
|
||||||
console.log(chalk.yellow("[302]") + chalk.grey(` ${argv.baseDir}${req.url} -> ${newFp}`))
|
console.log(
|
||||||
|
styleText("yellow", "[302]") +
|
||||||
|
styleText("grey", ` ${argv.baseDir}${req.url} -> ${newFp}`),
|
||||||
|
)
|
||||||
res.end()
|
res.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +457,8 @@ export async function handleBuild(argv) {
|
|||||||
const wss = new WebSocketServer({ port: argv.wsPort })
|
const wss = new WebSocketServer({ port: argv.wsPort })
|
||||||
wss.on("connection", (ws) => connections.push(ws))
|
wss.on("connection", (ws) => connections.push(ws))
|
||||||
console.log(
|
console.log(
|
||||||
chalk.cyan(
|
styleText(
|
||||||
|
"cyan",
|
||||||
`Started a Quartz server listening at http://localhost:${argv.port}${argv.baseDir}`,
|
`Started a Quartz server listening at http://localhost:${argv.port}${argv.baseDir}`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -467,7 +482,7 @@ export async function handleBuild(argv) {
|
|||||||
.on("change", () => build(clientRefresh))
|
.on("change", () => build(clientRefresh))
|
||||||
.on("unlink", () => build(clientRefresh))
|
.on("unlink", () => build(clientRefresh))
|
||||||
|
|
||||||
console.log(chalk.grey("hint: exit with ctrl+c"))
|
console.log(styleText("grey", "hint: exit with ctrl+c"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +492,7 @@ export async function handleBuild(argv) {
|
|||||||
*/
|
*/
|
||||||
export async function handleUpdate(argv) {
|
export async function handleUpdate(argv) {
|
||||||
const contentFolder = resolveContentPath(argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
console.log(`\n${styleText(["bgGreen", "black"], ` Quartz v${version} `)} \n`)
|
||||||
console.log("Backing up your content")
|
console.log("Backing up your content")
|
||||||
execSync(
|
execSync(
|
||||||
`git remote show upstream || git remote add upstream https://github.com/jackyzha0/quartz.git`,
|
`git remote show upstream || git remote add upstream https://github.com/jackyzha0/quartz.git`,
|
||||||
@@ -490,7 +505,7 @@ export async function handleUpdate(argv) {
|
|||||||
try {
|
try {
|
||||||
gitPull(UPSTREAM_NAME, QUARTZ_SOURCE_BRANCH)
|
gitPull(UPSTREAM_NAME, QUARTZ_SOURCE_BRANCH)
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.red("An error occurred above while pulling updates."))
|
console.log(styleText("red", "An error occurred above while pulling updates."))
|
||||||
await popContentFolder(contentFolder)
|
await popContentFolder(contentFolder)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -517,9 +532,9 @@ export async function handleUpdate(argv) {
|
|||||||
|
|
||||||
const res = spawnSync("npm", ["i"], opts)
|
const res = spawnSync("npm", ["i"], opts)
|
||||||
if (res.status === 0) {
|
if (res.status === 0) {
|
||||||
console.log(chalk.green("Done!"))
|
console.log(styleText("green", "Done!"))
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.red("An error occurred above while installing dependencies."))
|
console.log(styleText("red", "An error occurred above while installing dependencies."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,14 +553,14 @@ export async function handleRestore(argv) {
|
|||||||
*/
|
*/
|
||||||
export async function handleSync(argv) {
|
export async function handleSync(argv) {
|
||||||
const contentFolder = resolveContentPath(argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
console.log(`\n${styleText(["bgGreen", "black"], ` Quartz v${version} `)}\n`)
|
||||||
console.log("Backing up your content")
|
console.log("Backing up your content")
|
||||||
|
|
||||||
if (argv.commit) {
|
if (argv.commit) {
|
||||||
const contentStat = await fs.promises.lstat(contentFolder)
|
const contentStat = await fs.promises.lstat(contentFolder)
|
||||||
if (contentStat.isSymbolicLink()) {
|
if (contentStat.isSymbolicLink()) {
|
||||||
const linkTarg = await fs.promises.readlink(contentFolder)
|
const linkTarg = await fs.promises.readlink(contentFolder)
|
||||||
console.log(chalk.yellow("Detected symlink, trying to dereference before committing"))
|
console.log(styleText("yellow", "Detected symlink, trying to dereference before committing"))
|
||||||
|
|
||||||
// stash symlink file
|
// stash symlink file
|
||||||
await stashContentFolder(contentFolder)
|
await stashContentFolder(contentFolder)
|
||||||
@@ -580,7 +595,7 @@ export async function handleSync(argv) {
|
|||||||
try {
|
try {
|
||||||
gitPull(ORIGIN_NAME, QUARTZ_SOURCE_BRANCH)
|
gitPull(ORIGIN_NAME, QUARTZ_SOURCE_BRANCH)
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.red("An error occurred above while pulling updates."))
|
console.log(styleText("red", "An error occurred above while pulling updates."))
|
||||||
await popContentFolder(contentFolder)
|
await popContentFolder(contentFolder)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -589,14 +604,17 @@ export async function handleSync(argv) {
|
|||||||
await popContentFolder(contentFolder)
|
await popContentFolder(contentFolder)
|
||||||
if (argv.push) {
|
if (argv.push) {
|
||||||
console.log("Pushing your changes")
|
console.log("Pushing your changes")
|
||||||
const res = spawnSync("git", ["push", "-uf", ORIGIN_NAME, QUARTZ_SOURCE_BRANCH], {
|
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim()
|
||||||
|
const res = spawnSync("git", ["push", "-uf", ORIGIN_NAME, currentBranch], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
})
|
})
|
||||||
if (res.status !== 0) {
|
if (res.status !== 0) {
|
||||||
console.log(chalk.red(`An error occurred above while pushing to remote ${ORIGIN_NAME}.`))
|
console.log(
|
||||||
|
styleText("red", `An error occurred above while pushing to remote ${ORIGIN_NAME}.`),
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(chalk.green("Done!"))
|
console.log(styleText("green", "Done!"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { isCancel, outro } from "@clack/prompts"
|
import { isCancel, outro } from "@clack/prompts"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
import { contentCacheFolder } from "./constants.js"
|
import { contentCacheFolder } from "./constants.js"
|
||||||
import { spawnSync } from "child_process"
|
import { spawnSync } from "child_process"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
@@ -14,7 +14,7 @@ export function escapePath(fp) {
|
|||||||
|
|
||||||
export function exitIfCancel(val) {
|
export function exitIfCancel(val) {
|
||||||
if (isCancel(val)) {
|
if (isCancel(val)) {
|
||||||
outro(chalk.red("Exiting"))
|
outro(styleText("red", "Exiting"))
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
} else {
|
} else {
|
||||||
return val
|
return val
|
||||||
@@ -36,9 +36,9 @@ export function gitPull(origin, branch) {
|
|||||||
const flags = ["--no-rebase", "--autostash", "-s", "recursive", "-X", "ours", "--no-edit"]
|
const flags = ["--no-rebase", "--autostash", "-s", "recursive", "-X", "ours", "--no-edit"]
|
||||||
const out = spawnSync("git", ["pull", ...flags, origin, branch], { stdio: "inherit" })
|
const out = spawnSync("git", ["pull", ...flags, origin, branch], { stdio: "inherit" })
|
||||||
if (out.stderr) {
|
if (out.stderr) {
|
||||||
throw new Error(chalk.red(`Error while pulling updates: ${out.stderr}`))
|
throw new Error(styleText("red", `Error while pulling updates: ${out.stderr}`))
|
||||||
} else if (out.status !== 0) {
|
} else if (out.status !== 0) {
|
||||||
throw new Error(chalk.red("Error while pulling updates"))
|
throw new Error(styleText("red", "Error while pulling updates"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, 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, simplifySlug } from "../util/path"
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
import { trieFromAllFiles } from "../util/ctx"
|
||||||
|
|
||||||
type CrumbData = {
|
type CrumbData = {
|
||||||
displayName: string
|
displayName: string
|
||||||
@@ -22,10 +22,6 @@ interface BreadcrumbOptions {
|
|||||||
* Whether to look up frontmatter title for folders (could cause performance problems with big vaults)
|
* Whether to look up frontmatter title for folders (could cause performance problems with big vaults)
|
||||||
*/
|
*/
|
||||||
resolveFrontmatterTitle: boolean
|
resolveFrontmatterTitle: boolean
|
||||||
/**
|
|
||||||
* Whether to display breadcrumbs on root `index.md`
|
|
||||||
*/
|
|
||||||
hideOnRoot: boolean
|
|
||||||
/**
|
/**
|
||||||
* Whether to display the current page in the breadcrumbs.
|
* Whether to display the current page in the breadcrumbs.
|
||||||
*/
|
*/
|
||||||
@@ -36,7 +32,6 @@ const defaultOptions: BreadcrumbOptions = {
|
|||||||
spacerSymbol: "❯",
|
spacerSymbol: "❯",
|
||||||
rootName: "Home",
|
rootName: "Home",
|
||||||
resolveFrontmatterTitle: true,
|
resolveFrontmatterTitle: true,
|
||||||
hideOnRoot: true,
|
|
||||||
showCurrentPage: true,
|
showCurrentPage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,78 +43,37 @@ function formatCrumb(displayName: string, baseSlug: FullSlug, currentSlug: Simpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: Partial<BreadcrumbOptions>) => {
|
export default ((opts?: Partial<BreadcrumbOptions>) => {
|
||||||
// Merge options with defaults
|
|
||||||
const options: BreadcrumbOptions = { ...defaultOptions, ...opts }
|
const options: BreadcrumbOptions = { ...defaultOptions, ...opts }
|
||||||
|
|
||||||
// computed index of folder name to its associated file data
|
|
||||||
let folderIndex: Map<string, QuartzPluginData> | undefined
|
|
||||||
|
|
||||||
const Breadcrumbs: QuartzComponent = ({
|
const Breadcrumbs: QuartzComponent = ({
|
||||||
fileData,
|
fileData,
|
||||||
allFiles,
|
allFiles,
|
||||||
displayClass,
|
displayClass,
|
||||||
|
ctx,
|
||||||
}: QuartzComponentProps) => {
|
}: QuartzComponentProps) => {
|
||||||
// Hide crumbs on root if enabled
|
const trie = (ctx.trie ??= trieFromAllFiles(allFiles))
|
||||||
if (options.hideOnRoot && fileData.slug === "index") {
|
const slugParts = fileData.slug!.split("/")
|
||||||
return <></>
|
const pathNodes = trie.ancestryChain(slugParts)
|
||||||
|
|
||||||
|
if (!pathNodes) {
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format entry for root element
|
const crumbs: CrumbData[] = pathNodes.map((node, idx) => {
|
||||||
const firstEntry = formatCrumb(options.rootName, fileData.slug!, "/" as SimpleSlug)
|
const crumb = formatCrumb(node.displayName, fileData.slug!, simplifySlug(node.slug))
|
||||||
const crumbs: CrumbData[] = [firstEntry]
|
if (idx === 0) {
|
||||||
|
crumb.displayName = options.rootName
|
||||||
if (!folderIndex && options.resolveFrontmatterTitle) {
|
|
||||||
folderIndex = new Map()
|
|
||||||
// construct the index for the first time
|
|
||||||
for (const file of allFiles) {
|
|
||||||
const folderParts = file.slug?.split("/")
|
|
||||||
if (folderParts?.at(-1) === "index") {
|
|
||||||
folderIndex.set(folderParts.slice(0, -1).join("/"), file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split slug into hierarchy/parts
|
|
||||||
const slugParts = fileData.slug?.split("/")
|
|
||||||
if (slugParts) {
|
|
||||||
// is tag breadcrumb?
|
|
||||||
const isTagPath = slugParts[0] === "tags"
|
|
||||||
|
|
||||||
// full path until current part
|
|
||||||
let currentPath = ""
|
|
||||||
|
|
||||||
for (let i = 0; i < slugParts.length - 1; i++) {
|
|
||||||
let curPathSegment = slugParts[i]
|
|
||||||
|
|
||||||
// Try to resolve frontmatter folder title
|
|
||||||
const currentFile = folderIndex?.get(slugParts.slice(0, i + 1).join("/"))
|
|
||||||
if (currentFile) {
|
|
||||||
const title = currentFile.frontmatter!.title
|
|
||||||
if (title !== "index") {
|
|
||||||
curPathSegment = title
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add current slug to full path
|
|
||||||
currentPath = joinSegments(currentPath, slugParts[i])
|
|
||||||
const includeTrailingSlash = !isTagPath || i < slugParts.length - 1
|
|
||||||
|
|
||||||
// Format and add current crumb
|
|
||||||
const crumb = formatCrumb(
|
|
||||||
curPathSegment,
|
|
||||||
fileData.slug!,
|
|
||||||
(currentPath + (includeTrailingSlash ? "/" : "")) as SimpleSlug,
|
|
||||||
)
|
|
||||||
crumbs.push(crumb)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add current file to crumb (can directly use frontmatter title)
|
// For last node (current page), set empty path
|
||||||
if (options.showCurrentPage && slugParts.at(-1) !== "index") {
|
if (idx === pathNodes.length - 1) {
|
||||||
crumbs.push({
|
crumb.path = ""
|
||||||
displayName: fileData.frontmatter!.title,
|
|
||||||
path: "",
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return crumb
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!options.showCurrentPage) {
|
||||||
|
crumbs.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type Options = {
|
|||||||
strict?: boolean
|
strict?: boolean
|
||||||
reactionsEnabled?: boolean
|
reactionsEnabled?: boolean
|
||||||
inputPosition?: "top" | "bottom"
|
inputPosition?: "top" | "bottom"
|
||||||
|
lang?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ export default ((opts: Options) => {
|
|||||||
data-theme-url={
|
data-theme-url={
|
||||||
opts.options.themeUrl ?? `https://${cfg.baseUrl ?? "example.com"}/static/giscus`
|
opts.options.themeUrl ?? `https://${cfg.baseUrl ?? "example.com"}/static/giscus`
|
||||||
}
|
}
|
||||||
|
data-lang={opts.options.lang ?? "en"}
|
||||||
></div>
|
></div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
22
quartz/components/ConditionalRender.tsx
Normal file
22
quartz/components/ConditionalRender.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
|
type ConditionalRenderConfig = {
|
||||||
|
component: QuartzComponent
|
||||||
|
condition: (props: QuartzComponentProps) => boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ((config: ConditionalRenderConfig) => {
|
||||||
|
const ConditionalRender: QuartzComponent = (props: QuartzComponentProps) => {
|
||||||
|
if (config.condition(props)) {
|
||||||
|
return <config.component {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
ConditionalRender.afterDOMLoaded = config.component.afterDOMLoaded
|
||||||
|
ConditionalRender.beforeDOMLoaded = config.component.beforeDOMLoaded
|
||||||
|
ConditionalRender.css = config.component.css
|
||||||
|
|
||||||
|
return ConditionalRender
|
||||||
|
}) satisfies QuartzComponentConstructor<ConditionalRenderConfig>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { concatenateResources } from "../util/resources"
|
import { concatenateResources } from "../util/resources"
|
||||||
|
import { classNames } from "../util/lang"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
type FlexConfig = {
|
type FlexConfig = {
|
||||||
@@ -23,7 +24,10 @@ export default ((config: FlexConfig) => {
|
|||||||
const gap = config.gap ?? "1rem"
|
const gap = config.gap ?? "1rem"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={`display: flex; flex-direction: ${direction}; flex-wrap: ${wrap}; gap: ${gap};`}>
|
<div
|
||||||
|
class={classNames(props.displayClass, "flex-component")}
|
||||||
|
style={`flex-direction: ${direction}; flex-wrap: ${wrap}; gap: ${gap};`}
|
||||||
|
>
|
||||||
{config.components.map((c) => {
|
{config.components.map((c) => {
|
||||||
const grow = c.grow ? 1 : 0
|
const grow = c.grow ? 1 : 0
|
||||||
const shrink = (c.shrink ?? true) ? 1 : 0
|
const shrink = (c.shrink ?? true) ? 1 : 0
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { JSX } from "preact"
|
import { JSX } from "preact"
|
||||||
import { randomIdNonSecure } from "../util/random"
|
|
||||||
|
|
||||||
const OverflowList = ({
|
const OverflowList = ({
|
||||||
children,
|
children,
|
||||||
@@ -13,8 +12,9 @@ const OverflowList = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let numExplorers = 0
|
||||||
export default () => {
|
export default () => {
|
||||||
const id = randomIdNonSecure()
|
const id = `list-${numExplorers++}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
OverflowList: (props: JSX.HTMLAttributes<HTMLUListElement>) => (
|
OverflowList: (props: JSX.HTMLAttributes<HTMLUListElement>) => (
|
||||||
|
|||||||
@@ -7,6 +7,26 @@ import { GlobalConfiguration } from "../cfg"
|
|||||||
export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
||||||
|
|
||||||
export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn {
|
export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn {
|
||||||
|
return (f1, f2) => {
|
||||||
|
// Sort by date/alphabetical
|
||||||
|
if (f1.dates && f2.dates) {
|
||||||
|
// sort descending
|
||||||
|
return getDate(cfg, f2)!.getTime() - getDate(cfg, f1)!.getTime()
|
||||||
|
} else if (f1.dates && !f2.dates) {
|
||||||
|
// prioritize files with dates
|
||||||
|
return -1
|
||||||
|
} else if (!f1.dates && f2.dates) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, sort lexographically by title
|
||||||
|
const f1Title = f1.frontmatter?.title.toLowerCase() ?? ""
|
||||||
|
const f2Title = f2.frontmatter?.title.toLowerCase() ?? ""
|
||||||
|
return f1Title.localeCompare(f2Title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function byDateAndAlphabeticalFolderFirst(cfg: GlobalConfiguration): SortFn {
|
||||||
return (f1, f2) => {
|
return (f1, f2) => {
|
||||||
// Sort folders first
|
// Sort folders first
|
||||||
const f1IsFolder = isFolderPath(f1.slug ?? "")
|
const f1IsFolder = isFolderPath(f1.slug ?? "")
|
||||||
@@ -38,7 +58,7 @@ type Props = {
|
|||||||
} & QuartzComponentProps
|
} & QuartzComponentProps
|
||||||
|
|
||||||
export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
|
export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
|
||||||
const sorter = sort ?? byDateAndAlphabetical(cfg)
|
const sorter = sort ?? byDateAndAlphabeticalFolderFirst(cfg)
|
||||||
let list = allFiles.sort(sorter)
|
let list = allFiles.sort(sorter)
|
||||||
if (limit) {
|
if (limit) {
|
||||||
list = list.slice(0, limit)
|
list = list.slice(0, limit)
|
||||||
|
|||||||
38
quartz/components/ReaderMode.tsx
Normal file
38
quartz/components/ReaderMode.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
import readerModeScript from "./scripts/readermode.inline"
|
||||||
|
import styles from "./styles/readermode.scss"
|
||||||
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
import { i18n } from "../i18n"
|
||||||
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
|
const ReaderMode: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
||||||
|
return (
|
||||||
|
<button class={classNames(displayClass, "readermode")}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
|
version="1.1"
|
||||||
|
class="readerIcon"
|
||||||
|
fill="currentColor"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="0.2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
width="64px"
|
||||||
|
height="64px"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
aria-label={i18n(cfg.locale).components.readerMode.title}
|
||||||
|
>
|
||||||
|
<title>{i18n(cfg.locale).components.readerMode.title}</title>
|
||||||
|
<g transform="translate(-1.8, -1.8) scale(1.15, 1.2)">
|
||||||
|
<path d="M8.9891247,2.5 C10.1384702,2.5 11.2209868,2.96705384 12.0049645,3.76669482 C12.7883914,2.96705384 13.8709081,2.5 15.0202536,2.5 L18.7549359,2.5 C19.1691495,2.5 19.5049359,2.83578644 19.5049359,3.25 L19.5046891,4.004 L21.2546891,4.00457396 C21.6343849,4.00457396 21.9481801,4.28672784 21.9978425,4.6528034 L22.0046891,4.75457396 L22.0046891,20.25 C22.0046891,20.6296958 21.7225353,20.943491 21.3564597,20.9931534 L21.2546891,21 L2.75468914,21 C2.37499337,21 2.06119817,20.7178461 2.01153575,20.3517706 L2.00468914,20.25 L2.00468914,4.75457396 C2.00468914,4.37487819 2.28684302,4.061083 2.65291858,4.01142057 L2.75468914,4.00457396 L4.50368914,4.004 L4.50444233,3.25 C4.50444233,2.87030423 4.78659621,2.55650904 5.15267177,2.50684662 L5.25444233,2.5 L8.9891247,2.5 Z M4.50368914,5.504 L3.50468914,5.504 L3.50468914,19.5 L10.9478955,19.4998273 C10.4513189,18.9207296 9.73864328,18.5588115 8.96709342,18.5065584 L8.77307039,18.5 L5.25444233,18.5 C4.87474657,18.5 4.56095137,18.2178461 4.51128895,17.8517706 L4.50444233,17.75 L4.50368914,5.504 Z M19.5049359,17.75 C19.5049359,18.1642136 19.1691495,18.5 18.7549359,18.5 L15.2363079,18.5 C14.3910149,18.5 13.5994408,18.8724714 13.0614828,19.4998273 L20.5046891,19.5 L20.5046891,5.504 L19.5046891,5.504 L19.5049359,17.75 Z M18.0059359,3.999 L15.0202536,4 L14.8259077,4.00692283 C13.9889509,4.06666544 13.2254227,4.50975805 12.7549359,5.212 L12.7549359,17.777 L12.7782651,17.7601316 C13.4923805,17.2719483 14.3447024,17 15.2363079,17 L18.0059359,16.999 L18.0056891,4.798 L18.0033792,4.75457396 L18.0056891,4.71 L18.0059359,3.999 Z M8.9891247,4 L6.00368914,3.999 L6.00599909,4.75457396 L6.00599909,4.75457396 L6.00368914,4.783 L6.00368914,16.999 L8.77307039,17 C9.57551536,17 10.3461406,17.2202781 11.0128313,17.6202194 L11.2536891,17.776 L11.2536891,5.211 C10.8200889,4.56369974 10.1361548,4.13636104 9.37521067,4.02745763 L9.18347055,4.00692283 L8.9891247,4 Z" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ReaderMode.beforeDOMLoaded = readerModeScript
|
||||||
|
ReaderMode.css = styles
|
||||||
|
|
||||||
|
export default (() => ReaderMode) satisfies QuartzComponentConstructor
|
||||||
@@ -53,17 +53,15 @@ export default ((opts?: Partial<Options>) => {
|
|||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div class={fileData.collapseToc ? "collapsed toc-content" : "toc-content"}>
|
<OverflowList class={fileData.collapseToc ? "collapsed toc-content" : "toc-content"}>
|
||||||
<OverflowList>
|
{fileData.toc.map((tocEntry) => (
|
||||||
{fileData.toc.map((tocEntry) => (
|
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
||||||
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
||||||
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
{tocEntry.text}
|
||||||
{tocEntry.text}
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
))}
|
||||||
))}
|
</OverflowList>
|
||||||
</OverflowList>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { pathToRoot, slugTag } from "../util/path"
|
import { FullSlug, resolveRelative } from "../util/path"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
|
||||||
const TagList: QuartzComponent = ({ fileData, displayClass }: QuartzComponentProps) => {
|
const TagList: QuartzComponent = ({ fileData, displayClass }: QuartzComponentProps) => {
|
||||||
const tags = fileData.frontmatter?.tags
|
const tags = fileData.frontmatter?.tags
|
||||||
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 linkDest = baseDir + `/tags/${slugTag(tag)}`
|
const linkDest = resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)
|
||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<a href={linkDest} class="internal tag-link">
|
<a href={linkDest} class="internal tag-link">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import FolderContent from "./pages/FolderContent"
|
|||||||
import NotFound from "./pages/404"
|
import NotFound from "./pages/404"
|
||||||
import ArticleTitle from "./ArticleTitle"
|
import ArticleTitle from "./ArticleTitle"
|
||||||
import Darkmode from "./Darkmode"
|
import Darkmode from "./Darkmode"
|
||||||
|
import ReaderMode from "./ReaderMode"
|
||||||
import Head from "./Head"
|
import Head from "./Head"
|
||||||
import PageTitle from "./PageTitle"
|
import PageTitle from "./PageTitle"
|
||||||
import ContentMeta from "./ContentMeta"
|
import ContentMeta from "./ContentMeta"
|
||||||
@@ -21,6 +22,7 @@ import RecentNotes from "./RecentNotes"
|
|||||||
import Breadcrumbs from "./Breadcrumbs"
|
import Breadcrumbs from "./Breadcrumbs"
|
||||||
import Comments from "./Comments"
|
import Comments from "./Comments"
|
||||||
import Flex from "./Flex"
|
import Flex from "./Flex"
|
||||||
|
import ConditionalRender from "./ConditionalRender"
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ArticleTitle,
|
ArticleTitle,
|
||||||
@@ -28,6 +30,7 @@ export {
|
|||||||
TagContent,
|
TagContent,
|
||||||
FolderContent,
|
FolderContent,
|
||||||
Darkmode,
|
Darkmode,
|
||||||
|
ReaderMode,
|
||||||
Head,
|
Head,
|
||||||
PageTitle,
|
PageTitle,
|
||||||
ContentMeta,
|
ContentMeta,
|
||||||
@@ -46,4 +49,5 @@ export {
|
|||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Comments,
|
Comments,
|
||||||
Flex,
|
Flex,
|
||||||
|
ConditionalRender,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import { i18n } from "../../i18n"
|
|||||||
import { QuartzPluginData } from "../../plugins/vfile"
|
import { QuartzPluginData } from "../../plugins/vfile"
|
||||||
import { ComponentChildren } from "preact"
|
import { ComponentChildren } from "preact"
|
||||||
import { concatenateResources } from "../../util/resources"
|
import { concatenateResources } from "../../util/resources"
|
||||||
import { FileTrieNode } from "../../util/fileTrie"
|
import { trieFromAllFiles } from "../../util/ctx"
|
||||||
|
|
||||||
interface FolderContentOptions {
|
interface FolderContentOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to display number of folders
|
* Whether to display number of folders
|
||||||
@@ -25,31 +26,11 @@ const defaultOptions: FolderContentOptions = {
|
|||||||
|
|
||||||
export default ((opts?: Partial<FolderContentOptions>) => {
|
export default ((opts?: Partial<FolderContentOptions>) => {
|
||||||
const options: FolderContentOptions = { ...defaultOptions, ...opts }
|
const options: FolderContentOptions = { ...defaultOptions, ...opts }
|
||||||
let trie: FileTrieNode<
|
|
||||||
QuartzPluginData & {
|
|
||||||
slug: string
|
|
||||||
title: string
|
|
||||||
filePath: string
|
|
||||||
}
|
|
||||||
>
|
|
||||||
|
|
||||||
const FolderContent: QuartzComponent = (props: QuartzComponentProps) => {
|
const FolderContent: QuartzComponent = (props: QuartzComponentProps) => {
|
||||||
const { tree, fileData, allFiles, cfg } = props
|
const { tree, fileData, allFiles, cfg } = props
|
||||||
|
|
||||||
if (!trie) {
|
const trie = (props.ctx.trie ??= trieFromAllFiles(allFiles))
|
||||||
trie = new FileTrieNode([])
|
|
||||||
allFiles.forEach((file) => {
|
|
||||||
if (file.frontmatter) {
|
|
||||||
trie.add({
|
|
||||||
...file,
|
|
||||||
slug: file.slug!,
|
|
||||||
title: file.frontmatter.title,
|
|
||||||
filePath: file.filePath!,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const folder = trie.findNode(fileData.slug!.split("/"))
|
const folder = trie.findNode(fileData.slug!.split("/"))
|
||||||
if (!folder) {
|
if (!folder) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
|
||||||
import style from "../styles/listPage.scss"
|
import style from "../styles/listPage.scss"
|
||||||
import { PageList, SortFn } from "../PageList"
|
import { PageList, SortFn } from "../PageList"
|
||||||
import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path"
|
import { FullSlug, getAllSegmentPrefixes, resolveRelative, 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"
|
||||||
@@ -74,10 +74,13 @@ export default ((opts?: Partial<TagContentOptions>) => {
|
|||||||
? contentPage?.description
|
? contentPage?.description
|
||||||
: htmlToJsx(contentPage.filePath!, root)
|
: htmlToJsx(contentPage.filePath!, root)
|
||||||
|
|
||||||
|
const tagListingPage = `/tags/${tag}` as FullSlug
|
||||||
|
const href = resolveRelative(fileData.slug!, tagListingPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>
|
<h2>
|
||||||
<a class="internal tag-link" href={`../tags/${tag}`}>
|
<a class="internal tag-link" href={href}>
|
||||||
{tag}
|
{tag}
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
@@ -112,8 +115,8 @@ export default ((opts?: Partial<TagContentOptions>) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classes}>
|
<div class="popover-hint">
|
||||||
<article class="popover-hint">{content}</article>
|
<article class={classes}>{content}</article>
|
||||||
<div class="page-listing">
|
<div class="page-listing">
|
||||||
<p>{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}</p>
|
<p>{i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })}</p>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function renderTranscludes(
|
|||||||
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"] ?? slug) as FullSlug
|
||||||
const page = componentData.allFiles.find((f) => f.slug === transcludeTarget)
|
const page = componentData.allFiles.find((f) => f.slug === transcludeTarget)
|
||||||
if (!page) {
|
if (!page) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
function toggleCallout(this: HTMLElement) {
|
function toggleCallout(this: HTMLElement) {
|
||||||
const outerBlock = this.parentElement!
|
const outerBlock = this.parentElement!
|
||||||
outerBlock.classList.toggle("is-collapsed")
|
outerBlock.classList.toggle("is-collapsed")
|
||||||
|
const content = outerBlock.getElementsByClassName("callout-content")[0] as HTMLElement
|
||||||
|
if (!content) return
|
||||||
const collapsed = outerBlock.classList.contains("is-collapsed")
|
const collapsed = outerBlock.classList.contains("is-collapsed")
|
||||||
const height = collapsed ? this.scrollHeight : outerBlock.scrollHeight
|
content.style.gridTemplateRows = collapsed ? "0fr" : "1fr"
|
||||||
outerBlock.style.maxHeight = height + "px"
|
|
||||||
|
|
||||||
// walk and adjust height of all parents
|
|
||||||
let current = outerBlock
|
|
||||||
let parent = outerBlock.parentElement
|
|
||||||
while (parent) {
|
|
||||||
if (!parent.classList.contains("callout")) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const collapsed = parent.classList.contains("is-collapsed")
|
|
||||||
const height = collapsed ? parent.scrollHeight : parent.scrollHeight + current.scrollHeight
|
|
||||||
parent.style.maxHeight = height + "px"
|
|
||||||
|
|
||||||
current = parent
|
|
||||||
parent = parent.parentElement
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupCallout() {
|
function setupCallout() {
|
||||||
@@ -27,15 +12,15 @@ function setupCallout() {
|
|||||||
`callout is-collapsible`,
|
`callout is-collapsible`,
|
||||||
) as HTMLCollectionOf<HTMLElement>
|
) as HTMLCollectionOf<HTMLElement>
|
||||||
for (const div of collapsible) {
|
for (const div of collapsible) {
|
||||||
const title = div.firstElementChild
|
const title = div.getElementsByClassName("callout-title")[0] as HTMLElement
|
||||||
if (!title) continue
|
const content = div.getElementsByClassName("callout-content")[0] as HTMLElement
|
||||||
|
if (!title || !content) continue
|
||||||
|
|
||||||
title.addEventListener("click", toggleCallout)
|
title.addEventListener("click", toggleCallout)
|
||||||
window.addCleanup(() => title.removeEventListener("click", toggleCallout))
|
window.addCleanup(() => title.removeEventListener("click", toggleCallout))
|
||||||
|
|
||||||
const collapsed = div.classList.contains("is-collapsed")
|
const collapsed = div.classList.contains("is-collapsed")
|
||||||
const height = collapsed ? title.scrollHeight : div.scrollHeight
|
content.style.gridTemplateRows = collapsed ? "0fr" : "1fr"
|
||||||
div.style.maxHeight = height + "px"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ type GiscusElement = Omit<HTMLElement, "dataset"> & {
|
|||||||
strict: string
|
strict: string
|
||||||
reactionsEnabled: string
|
reactionsEnabled: string
|
||||||
inputPosition: "top" | "bottom"
|
inputPosition: "top" | "bottom"
|
||||||
|
lang: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ document.addEventListener("nav", () => {
|
|||||||
giscusScript.setAttribute("data-strict", giscusContainer.dataset.strict)
|
giscusScript.setAttribute("data-strict", giscusContainer.dataset.strict)
|
||||||
giscusScript.setAttribute("data-reactions-enabled", giscusContainer.dataset.reactionsEnabled)
|
giscusScript.setAttribute("data-reactions-enabled", giscusContainer.dataset.reactionsEnabled)
|
||||||
giscusScript.setAttribute("data-input-position", giscusContainer.dataset.inputPosition)
|
giscusScript.setAttribute("data-input-position", giscusContainer.dataset.inputPosition)
|
||||||
|
giscusScript.setAttribute("data-lang", giscusContainer.dataset.lang)
|
||||||
const theme = document.documentElement.getAttribute("saved-theme")
|
const theme = document.documentElement.getAttribute("saved-theme")
|
||||||
if (theme) {
|
if (theme) {
|
||||||
giscusScript.setAttribute("data-theme", getThemeUrl(getThemeName(theme)))
|
giscusScript.setAttribute("data-theme", getThemeUrl(getThemeName(theme)))
|
||||||
|
|||||||
@@ -23,11 +23,18 @@ let currentExplorerState: Array<FolderState>
|
|||||||
function toggleExplorer(this: HTMLElement) {
|
function toggleExplorer(this: HTMLElement) {
|
||||||
const nearestExplorer = this.closest(".explorer") as HTMLElement
|
const nearestExplorer = this.closest(".explorer") as HTMLElement
|
||||||
if (!nearestExplorer) return
|
if (!nearestExplorer) return
|
||||||
nearestExplorer.classList.toggle("collapsed")
|
const explorerCollapsed = nearestExplorer.classList.toggle("collapsed")
|
||||||
nearestExplorer.setAttribute(
|
nearestExplorer.setAttribute(
|
||||||
"aria-expanded",
|
"aria-expanded",
|
||||||
nearestExplorer.getAttribute("aria-expanded") === "true" ? "false" : "true",
|
nearestExplorer.getAttribute("aria-expanded") === "true" ? "false" : "true",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!explorerCollapsed) {
|
||||||
|
// Stop <html> from being scrollable when mobile explorer is open
|
||||||
|
document.documentElement.classList.add("mobile-no-scroll")
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.remove("mobile-no-scroll")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFolder(evt: MouseEvent) {
|
function toggleFolder(evt: MouseEvent) {
|
||||||
@@ -67,9 +74,6 @@ function toggleFolder(evt: MouseEvent) {
|
|||||||
collapsed: isCollapsed,
|
collapsed: isCollapsed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const stringifiedFileTree = JSON.stringify(currentExplorerState)
|
|
||||||
localStorage.setItem("fileTree", stringifiedFileTree)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFileNode(currentSlug: FullSlug, node: FileTrieNode): HTMLLIElement {
|
function createFileNode(currentSlug: FullSlug, node: FileTrieNode): HTMLLIElement {
|
||||||
@@ -158,8 +162,8 @@ async function setupExplorer(currentSlug: FullSlug) {
|
|||||||
mapFn: new Function("return " + (dataFns.mapFn || "undefined"))(),
|
mapFn: new Function("return " + (dataFns.mapFn || "undefined"))(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get folder state from local storage
|
// Get folder state from session storage
|
||||||
const storageTree = localStorage.getItem("fileTree")
|
const storageTree = sessionStorage.getItem("fileTree")
|
||||||
const serializedExplorerState = storageTree && opts.useSavedState ? JSON.parse(storageTree) : []
|
const serializedExplorerState = storageTree && opts.useSavedState ? JSON.parse(storageTree) : []
|
||||||
const oldIndex = new Map<string, boolean>(
|
const oldIndex = new Map<string, boolean>(
|
||||||
serializedExplorerState.map((entry: FolderState) => [entry.path, entry.collapsed]),
|
serializedExplorerState.map((entry: FolderState) => [entry.path, entry.collapsed]),
|
||||||
@@ -256,6 +260,9 @@ document.addEventListener("prenav", async () => {
|
|||||||
const explorer = document.querySelector(".explorer-ul")
|
const explorer = document.querySelector(".explorer-ul")
|
||||||
if (!explorer) return
|
if (!explorer) return
|
||||||
sessionStorage.setItem("explorerScrollTop", explorer.scrollTop.toString())
|
sessionStorage.setItem("explorerScrollTop", explorer.scrollTop.toString())
|
||||||
|
if (!currentExplorerState) return
|
||||||
|
const stringifiedFileTree = JSON.stringify(currentExplorerState)
|
||||||
|
sessionStorage.setItem("fileTree", stringifiedFileTree)
|
||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
||||||
@@ -270,12 +277,25 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
|
|||||||
if (mobileExplorer.checkVisibility()) {
|
if (mobileExplorer.checkVisibility()) {
|
||||||
explorer.classList.add("collapsed")
|
explorer.classList.add("collapsed")
|
||||||
explorer.setAttribute("aria-expanded", "false")
|
explorer.setAttribute("aria-expanded", "false")
|
||||||
|
|
||||||
|
// Allow <html> to be scrollable when mobile explorer is collapsed
|
||||||
|
document.documentElement.classList.remove("mobile-no-scroll")
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileExplorer.classList.remove("hide-until-loaded")
|
mobileExplorer.classList.remove("hide-until-loaded")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.addEventListener("resize", function () {
|
||||||
|
// Desktop explorer opens by default, and it stays open when the window is resized
|
||||||
|
// to mobile screen size. Applies `no-scroll` to <html> in this edge case.
|
||||||
|
const explorer = document.querySelector(".explorer")
|
||||||
|
if (explorer && !explorer.classList.contains("collapsed")) {
|
||||||
|
document.documentElement.classList.add("mobile-no-scroll")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function setFolderState(folderElement: HTMLElement, collapsed: boolean) {
|
function setFolderState(folderElement: HTMLElement, collapsed: boolean) {
|
||||||
return collapsed ? folderElement.classList.remove("open") : folderElement.classList.add("open")
|
return collapsed ? folderElement.classList.remove("open") : folderElement.classList.add("open")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,30 @@ type TweenNode = {
|
|||||||
stop: () => void
|
stop: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// workaround for pixijs webgpu issue: https://github.com/pixijs/pixijs/issues/11389
|
||||||
|
async function determineGraphicsAPI(): Promise<"webgpu" | "webgl"> {
|
||||||
|
const adapter = await navigator.gpu?.requestAdapter().catch(() => null)
|
||||||
|
const device = adapter && (await adapter.requestDevice().catch(() => null))
|
||||||
|
if (!device) {
|
||||||
|
return "webgl"
|
||||||
|
}
|
||||||
|
|
||||||
|
const canvas = document.createElement("canvas")
|
||||||
|
const gl =
|
||||||
|
(canvas.getContext("webgl2") as WebGL2RenderingContext | null) ??
|
||||||
|
(canvas.getContext("webgl") as WebGLRenderingContext | null)
|
||||||
|
|
||||||
|
// we have to return webgl so pixijs automatically falls back to canvas
|
||||||
|
if (!gl) {
|
||||||
|
return "webgl"
|
||||||
|
}
|
||||||
|
|
||||||
|
const webglMaxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)
|
||||||
|
const webgpuMaxTextures = device.limits.maxSampledTexturesPerShaderStage
|
||||||
|
|
||||||
|
return webglMaxTextures === webgpuMaxTextures ? "webgpu" : "webgl"
|
||||||
|
}
|
||||||
|
|
||||||
async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) {
|
async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) {
|
||||||
const slug = simplifySlug(fullSlug)
|
const slug = simplifySlug(fullSlug)
|
||||||
const visited = getVisited()
|
const visited = getVisited()
|
||||||
@@ -349,6 +373,7 @@ async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) {
|
|||||||
tweens.forEach((tween) => tween.stop())
|
tweens.forEach((tween) => tween.stop())
|
||||||
tweens.clear()
|
tweens.clear()
|
||||||
|
|
||||||
|
const pixiPreference = await determineGraphicsAPI()
|
||||||
const app = new Application()
|
const app = new Application()
|
||||||
await app.init({
|
await app.init({
|
||||||
width,
|
width,
|
||||||
@@ -357,7 +382,7 @@ async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) {
|
|||||||
autoStart: false,
|
autoStart: false,
|
||||||
autoDensity: true,
|
autoDensity: true,
|
||||||
backgroundAlpha: 0,
|
backgroundAlpha: 0,
|
||||||
preference: "webgpu",
|
preference: pixiPreference,
|
||||||
resolution: window.devicePixelRatio,
|
resolution: window.devicePixelRatio,
|
||||||
eventMode: "static",
|
eventMode: "static",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,61 +3,70 @@ import { normalizeRelativeURLs } from "../../util/path"
|
|||||||
import { fetchCanonical } from "./util"
|
import { fetchCanonical } from "./util"
|
||||||
|
|
||||||
const p = new DOMParser()
|
const p = new DOMParser()
|
||||||
|
let activeAnchor: HTMLAnchorElement | null = null
|
||||||
|
|
||||||
async function mouseEnterHandler(
|
async function mouseEnterHandler(
|
||||||
this: HTMLAnchorElement,
|
this: HTMLAnchorElement,
|
||||||
{ clientX, clientY }: { clientX: number; clientY: number },
|
{ clientX, clientY }: { clientX: number; clientY: number },
|
||||||
) {
|
) {
|
||||||
const link = this
|
const link = (activeAnchor = this)
|
||||||
if (link.dataset.noPopover === "true") {
|
if (link.dataset.noPopover === "true") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setPosition(popoverElement: HTMLElement) {
|
async function setPosition(popoverElement: HTMLElement) {
|
||||||
const { x, y } = await computePosition(link, popoverElement, {
|
const { x, y } = await computePosition(link, popoverElement, {
|
||||||
|
strategy: "fixed",
|
||||||
middleware: [inline({ x: clientX, y: clientY }), shift(), flip()],
|
middleware: [inline({ x: clientX, y: clientY }), shift(), flip()],
|
||||||
})
|
})
|
||||||
Object.assign(popoverElement.style, {
|
Object.assign(popoverElement.style, {
|
||||||
left: `${x}px`,
|
transform: `translate(${x.toFixed()}px, ${y.toFixed()}px)`,
|
||||||
top: `${y}px`,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasAlreadyBeenFetched = () =>
|
function showPopover(popoverElement: HTMLElement) {
|
||||||
[...link.children].some((child) => child.classList.contains("popover"))
|
clearActivePopover()
|
||||||
|
popoverElement.classList.add("active-popover")
|
||||||
|
setPosition(popoverElement as HTMLElement)
|
||||||
|
|
||||||
// dont refetch if there's already a popover
|
if (hash !== "") {
|
||||||
if (hasAlreadyBeenFetched()) {
|
const targetAnchor = `#popover-internal-${hash.slice(1)}`
|
||||||
return setPosition(link.lastChild as HTMLElement)
|
const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null
|
||||||
|
if (heading) {
|
||||||
|
// leave ~12px of buffer when scrolling to a heading
|
||||||
|
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const thisUrl = new URL(document.location.href)
|
|
||||||
thisUrl.hash = ""
|
|
||||||
thisUrl.search = ""
|
|
||||||
const targetUrl = new URL(link.href)
|
const targetUrl = new URL(link.href)
|
||||||
const hash = decodeURIComponent(targetUrl.hash)
|
const hash = decodeURIComponent(targetUrl.hash)
|
||||||
targetUrl.hash = ""
|
targetUrl.hash = ""
|
||||||
targetUrl.search = ""
|
targetUrl.search = ""
|
||||||
|
const popoverId = `popover-${link.pathname}`
|
||||||
|
const prevPopoverElement = document.getElementById(popoverId)
|
||||||
|
|
||||||
|
// dont refetch if there's already a popover
|
||||||
|
if (!!document.getElementById(popoverId)) {
|
||||||
|
showPopover(prevPopoverElement as HTMLElement)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetchCanonical(targetUrl).catch((err) => {
|
const response = await fetchCanonical(targetUrl).catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
// bailout if another popover exists
|
|
||||||
if (hasAlreadyBeenFetched()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response) return
|
if (!response) return
|
||||||
const [contentType] = response.headers.get("Content-Type")!.split(";")
|
const [contentType] = response.headers.get("Content-Type")!.split(";")
|
||||||
const [contentTypeCategory, typeInfo] = contentType.split("/")
|
const [contentTypeCategory, typeInfo] = contentType.split("/")
|
||||||
|
|
||||||
const popoverElement = document.createElement("div")
|
const popoverElement = document.createElement("div")
|
||||||
|
popoverElement.id = popoverId
|
||||||
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)
|
|
||||||
|
|
||||||
popoverInner.dataset.contentType = contentType ?? undefined
|
popoverInner.dataset.contentType = contentType ?? undefined
|
||||||
|
popoverElement.appendChild(popoverInner)
|
||||||
|
|
||||||
switch (contentTypeCategory) {
|
switch (contentTypeCategory) {
|
||||||
case "image":
|
case "image":
|
||||||
@@ -82,30 +91,43 @@ async function mouseEnterHandler(
|
|||||||
const contents = await response.text()
|
const contents = await response.text()
|
||||||
const html = p.parseFromString(contents, "text/html")
|
const html = p.parseFromString(contents, "text/html")
|
||||||
normalizeRelativeURLs(html, targetUrl)
|
normalizeRelativeURLs(html, targetUrl)
|
||||||
// strip all IDs from elements to prevent duplicates
|
// prepend all IDs inside popovers to prevent duplicates
|
||||||
html.querySelectorAll("[id]").forEach((el) => el.removeAttribute("id"))
|
html.querySelectorAll("[id]").forEach((el) => {
|
||||||
|
const targetID = `popover-internal-${el.id}`
|
||||||
|
el.id = targetID
|
||||||
|
})
|
||||||
const elts = [...html.getElementsByClassName("popover-hint")]
|
const elts = [...html.getElementsByClassName("popover-hint")]
|
||||||
if (elts.length === 0) return
|
if (elts.length === 0) return
|
||||||
|
|
||||||
elts.forEach((elt) => popoverInner.appendChild(elt))
|
elts.forEach((elt) => popoverInner.appendChild(elt))
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(popoverElement)
|
if (!!document.getElementById(popoverId)) {
|
||||||
link.appendChild(popoverElement)
|
return
|
||||||
|
|
||||||
if (hash !== "") {
|
|
||||||
const heading = popoverInner.querySelector(hash) as HTMLElement | null
|
|
||||||
if (heading) {
|
|
||||||
// leave ~12px of buffer when scrolling to a heading
|
|
||||||
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.body.appendChild(popoverElement)
|
||||||
|
if (activeAnchor !== this) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
showPopover(popoverElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearActivePopover() {
|
||||||
|
activeAnchor = null
|
||||||
|
const allPopoverElements = document.querySelectorAll(".popover")
|
||||||
|
allPopoverElements.forEach((popoverElement) => popoverElement.classList.remove("active-popover"))
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("nav", () => {
|
document.addEventListener("nav", () => {
|
||||||
const links = [...document.getElementsByClassName("internal")] as HTMLAnchorElement[]
|
const links = [...document.querySelectorAll("a.internal")] as HTMLAnchorElement[]
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
link.addEventListener("mouseenter", mouseEnterHandler)
|
link.addEventListener("mouseenter", mouseEnterHandler)
|
||||||
window.addCleanup(() => link.removeEventListener("mouseenter", mouseEnterHandler))
|
link.addEventListener("mouseleave", clearActivePopover)
|
||||||
|
window.addCleanup(() => {
|
||||||
|
link.removeEventListener("mouseenter", mouseEnterHandler)
|
||||||
|
link.removeEventListener("mouseleave", clearActivePopover)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
25
quartz/components/scripts/readermode.inline.ts
Normal file
25
quartz/components/scripts/readermode.inline.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
let isReaderMode = false
|
||||||
|
|
||||||
|
const emitReaderModeChangeEvent = (mode: "on" | "off") => {
|
||||||
|
const event: CustomEventMap["readermodechange"] = new CustomEvent("readermodechange", {
|
||||||
|
detail: { mode },
|
||||||
|
})
|
||||||
|
document.dispatchEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("nav", () => {
|
||||||
|
const switchReaderMode = () => {
|
||||||
|
isReaderMode = !isReaderMode
|
||||||
|
const newMode = isReaderMode ? "on" : "off"
|
||||||
|
document.documentElement.setAttribute("reader-mode", newMode)
|
||||||
|
emitReaderModeChangeEvent(newMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const readerModeButton of document.getElementsByClassName("readermode")) {
|
||||||
|
readerModeButton.addEventListener("click", switchReaderMode)
|
||||||
|
window.addCleanup(() => readerModeButton.removeEventListener("click", switchReaderMode))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set initial state
|
||||||
|
document.documentElement.setAttribute("reader-mode", isReaderMode ? "on" : "off")
|
||||||
|
})
|
||||||
@@ -147,8 +147,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
|||||||
const container = searchElement.querySelector(".search-container") as HTMLElement
|
const container = searchElement.querySelector(".search-container") as HTMLElement
|
||||||
if (!container) return
|
if (!container) return
|
||||||
|
|
||||||
const sidebar = container.closest(".sidebar") as HTMLElement
|
const sidebar = container.closest(".sidebar") as HTMLElement | null
|
||||||
if (!sidebar) return
|
|
||||||
|
|
||||||
const searchButton = searchElement.querySelector(".search-button") as HTMLButtonElement
|
const searchButton = searchElement.querySelector(".search-button") as HTMLButtonElement
|
||||||
if (!searchButton) return
|
if (!searchButton) return
|
||||||
@@ -180,7 +179,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
|||||||
function hideSearch() {
|
function hideSearch() {
|
||||||
container.classList.remove("active")
|
container.classList.remove("active")
|
||||||
searchBar.value = "" // clear the input when we dismiss the search
|
searchBar.value = "" // clear the input when we dismiss the search
|
||||||
sidebar.style.zIndex = ""
|
if (sidebar) sidebar.style.zIndex = ""
|
||||||
removeAllChildren(results)
|
removeAllChildren(results)
|
||||||
if (preview) {
|
if (preview) {
|
||||||
removeAllChildren(preview)
|
removeAllChildren(preview)
|
||||||
@@ -192,7 +191,7 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
|||||||
|
|
||||||
function showSearch(searchTypeNew: SearchType) {
|
function showSearch(searchTypeNew: SearchType) {
|
||||||
searchType = searchTypeNew
|
searchType = searchTypeNew
|
||||||
sidebar.style.zIndex = "1"
|
if (sidebar) sidebar.style.zIndex = "1"
|
||||||
container.classList.add("active")
|
container.classList.add("active")
|
||||||
searchBar.focus()
|
searchBar.focus()
|
||||||
}
|
}
|
||||||
@@ -301,9 +300,11 @@ async function setupSearch(searchElement: Element, currentSlug: FullSlug, data:
|
|||||||
itemTile.classList.add("result-card")
|
itemTile.classList.add("result-card")
|
||||||
itemTile.id = slug
|
itemTile.id = slug
|
||||||
itemTile.href = resolveUrl(slug).toString()
|
itemTile.href = resolveUrl(slug).toString()
|
||||||
itemTile.innerHTML = `<h3>${title}</h3>${htmlTags}${
|
itemTile.innerHTML = `
|
||||||
enablePreview && window.innerWidth > 600 ? "" : `<p>${content}</p>`
|
<h3 class="card-title">${title}</h3>
|
||||||
}`
|
${htmlTags}
|
||||||
|
<p class="card-description">${content}</p>
|
||||||
|
`
|
||||||
itemTile.addEventListener("click", (event) => {
|
itemTile.addEventListener("click", (event) => {
|
||||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
||||||
hideSearch()
|
hideSearch()
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
const observer = new IntersectionObserver((entries) => {
|
const observer = new IntersectionObserver((entries) => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const slug = entry.target.id
|
const slug = entry.target.id
|
||||||
const tocEntryElement = document.querySelector(`a[data-for="${slug}"]`)
|
const tocEntryElements = document.querySelectorAll(`a[data-for="${slug}"]`)
|
||||||
const windowHeight = entry.rootBounds?.height
|
const windowHeight = entry.rootBounds?.height
|
||||||
if (windowHeight && tocEntryElement) {
|
if (windowHeight && tocEntryElements.length > 0) {
|
||||||
if (entry.boundingClientRect.y < windowHeight) {
|
if (entry.boundingClientRect.y < windowHeight) {
|
||||||
tocEntryElement.classList.add("in-view")
|
tocEntryElements.forEach((tocEntryElement) => tocEntryElement.classList.add("in-view"))
|
||||||
} else {
|
} else {
|
||||||
tocEntryElement.classList.remove("in-view")
|
tocEntryElements.forEach((tocEntryElement) => tocEntryElement.classList.remove("in-view"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,12 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
& > ul {
|
& > ul.overflow {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
|
max-height: calc(100% - 2rem);
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
|
||||||
& > li {
|
& > li {
|
||||||
& > a {
|
& > a {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.content-meta {
|
.content-meta {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
color: var(--gray);
|
color: var(--darkgray);
|
||||||
|
|
||||||
&[show-comma="true"] {
|
&[show-comma="true"] {
|
||||||
> *:not(:last-child) {
|
> *:not(:last-child) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
border: none;
|
border: none;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin: 0 10px;
|
margin: 0;
|
||||||
text-align: inherit;
|
text-align: inherit;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ button.desktop-explorer {
|
|||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
|
||||||
& li > a {
|
& li > a {
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
@@ -198,6 +199,7 @@ button.desktop-explorer {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: transform 0.3s ease;
|
transition: transform 0.3s ease;
|
||||||
backface-visibility: visible;
|
backface-visibility: visible;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
||||||
@@ -237,7 +239,7 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
background-color: var(--light);
|
background-color: var(--light);
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
width: 100%;
|
width: 100vw;
|
||||||
transform: translateX(-100vw);
|
transform: translateX(-100vw);
|
||||||
transition:
|
transition:
|
||||||
transform 200ms ease,
|
transform 200ms ease,
|
||||||
@@ -261,22 +263,8 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-scroll {
|
.mobile-no-scroll {
|
||||||
opacity: 0;
|
@media all and ($mobile) {
|
||||||
overflow: hidden;
|
overscroll-behavior: none;
|
||||||
}
|
|
||||||
|
|
||||||
html:has(.no-scroll) {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media all and not ($mobile) {
|
|
||||||
.no-scroll {
|
|
||||||
opacity: 1 !important;
|
|
||||||
overflow: auto !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html:has(.no-scroll) {
|
|
||||||
overflow: auto !important;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,12 @@
|
|||||||
|
|
||||||
.popover {
|
.popover {
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
will-change: transform;
|
||||||
|
|
||||||
& > .popover-inner {
|
& > .popover-inner {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -35,7 +38,10 @@
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
box-shadow: 6px 6px 36px 0 rgba(0, 0, 0, 0.25);
|
box-shadow: 6px 6px 36px 0 rgba(0, 0, 0, 0.25);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
|
user-select: none;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .popover-inner[data-content-type] {
|
& > .popover-inner[data-content-type] {
|
||||||
@@ -75,7 +81,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover .popover,
|
.active-popover,
|
||||||
.popover:hover {
|
.popover:hover {
|
||||||
animation: dropin 0.3s ease;
|
animation: dropin 0.3s ease;
|
||||||
animation-fill-mode: forwards;
|
animation-fill-mode: forwards;
|
||||||
|
|||||||
34
quartz/components/styles/readermode.scss
Normal file
34
quartz/components/styles/readermode.scss
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
.readermode {
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0;
|
||||||
|
position: relative;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin: 0;
|
||||||
|
text-align: inherit;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
& svg {
|
||||||
|
position: absolute;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
top: calc(50% - 10px);
|
||||||
|
fill: var(--darkgray);
|
||||||
|
stroke: var(--darkgray);
|
||||||
|
transition: opacity 0.1s ease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[reader-mode="on"] {
|
||||||
|
& .sidebar.left,
|
||||||
|
& .sidebar.right {
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
& > .search-button {
|
& > .search-button {
|
||||||
background-color: var(--lightgray);
|
background-color: color-mix(in srgb, var(--lightgray) 60%, var(--light));
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
@@ -133,11 +133,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media all and ($mobile) {
|
@media all and ($mobile) {
|
||||||
& > #preview-container {
|
flex-direction: column;
|
||||||
|
|
||||||
|
& > .preview-container {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-preview] > #results-container {
|
&[data-preview] > .results-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
flex: 0 0 100%;
|
flex: 0 0 100%;
|
||||||
@@ -204,6 +206,12 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media all and not ($mobile) {
|
||||||
|
& > p.card-description {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
& > ul.tags {
|
& > ul.tags {
|
||||||
margin-top: 0.45rem;
|
margin-top: 0.45rem;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|||||||
@@ -3,18 +3,11 @@
|
|||||||
.toc {
|
.toc {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
min-height: 4rem;
|
min-height: 1.4rem;
|
||||||
flex: 0 1 auto;
|
flex: 0 0.5 auto;
|
||||||
&:has(button.toc-header.collapsed) {
|
&:has(button.toc-header.collapsed) {
|
||||||
flex: 0 1 1.2rem;
|
flex: 0 1 1.4rem;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media all and not ($mobile) {
|
|
||||||
.toc-header {
|
|
||||||
display: flex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,23 +38,23 @@ button.toc-header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc-content {
|
ul.toc-content.overflow {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
padding: 0;
|
||||||
|
max-height: calc(100% - 2rem);
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
list-style: none;
|
||||||
|
|
||||||
& ul {
|
& > li > a {
|
||||||
list-style: none;
|
color: var(--dark);
|
||||||
margin: 0.5rem 0;
|
opacity: 0.35;
|
||||||
padding: 0;
|
transition:
|
||||||
& > li > a {
|
0.5s ease opacity,
|
||||||
color: var(--dark);
|
0.3s ease color;
|
||||||
opacity: 0.35;
|
&.in-view {
|
||||||
transition:
|
opacity: 0.75;
|
||||||
0.5s ease opacity,
|
|
||||||
0.3s ease color;
|
|
||||||
&.in-view {
|
|
||||||
opacity: 0.75;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import th from "./locales/th-TH"
|
|||||||
import lt from "./locales/lt-LT"
|
import lt from "./locales/lt-LT"
|
||||||
import fi from "./locales/fi-FI"
|
import fi from "./locales/fi-FI"
|
||||||
import no from "./locales/nb-NO"
|
import no from "./locales/nb-NO"
|
||||||
|
import id from "./locales/id-ID"
|
||||||
|
|
||||||
export const TRANSLATIONS = {
|
export const TRANSLATIONS = {
|
||||||
"en-US": enUs,
|
"en-US": enUs,
|
||||||
@@ -76,6 +77,7 @@ export const TRANSLATIONS = {
|
|||||||
"lt-LT": lt,
|
"lt-LT": lt,
|
||||||
"fi-FI": fi,
|
"fi-FI": fi,
|
||||||
"nb-NO": no,
|
"nb-NO": no,
|
||||||
|
"id-ID": id,
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const defaultTranslation = "en-US"
|
export const defaultTranslation = "en-US"
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ export default {
|
|||||||
explorer: {
|
explorer: {
|
||||||
title: "المستعرض",
|
title: "المستعرض",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "وضع القارئ",
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
createdWith: "أُنشئ باستخدام",
|
createdWith: "أُنشئ باستخدام",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Mode clar",
|
lightMode: "Mode clar",
|
||||||
darkMode: "Mode fosc",
|
darkMode: "Mode fosc",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Mode lector",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorador",
|
title: "Explorador",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Světlý režim",
|
lightMode: "Světlý režim",
|
||||||
darkMode: "Tmavý režim",
|
darkMode: "Tmavý režim",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Režim čtečky",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Procházet",
|
title: "Procházet",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ export default {
|
|||||||
noBacklinksFound: "Keine Backlinks gefunden",
|
noBacklinksFound: "Keine Backlinks gefunden",
|
||||||
},
|
},
|
||||||
themeToggle: {
|
themeToggle: {
|
||||||
lightMode: "Light Mode",
|
lightMode: "Heller Modus",
|
||||||
darkMode: "Dark Mode",
|
darkMode: "Dunkler Modus",
|
||||||
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Lesemodus",
|
||||||
},
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorer",
|
title: "Explorer",
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ export interface Translation {
|
|||||||
lightMode: string
|
lightMode: string
|
||||||
darkMode: string
|
darkMode: string
|
||||||
}
|
}
|
||||||
|
readerMode: {
|
||||||
|
title: string
|
||||||
|
}
|
||||||
explorer: {
|
explorer: {
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Light mode",
|
lightMode: "Light mode",
|
||||||
darkMode: "Dark mode",
|
darkMode: "Dark mode",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Reader mode",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorer",
|
title: "Explorer",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Light mode",
|
lightMode: "Light mode",
|
||||||
darkMode: "Dark mode",
|
darkMode: "Dark mode",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Reader mode",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorer",
|
title: "Explorer",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Modo claro",
|
lightMode: "Modo claro",
|
||||||
darkMode: "Modo oscuro",
|
darkMode: "Modo oscuro",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Modo lector",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorador",
|
title: "Explorador",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "حالت روشن",
|
lightMode: "حالت روشن",
|
||||||
darkMode: "حالت تاریک",
|
darkMode: "حالت تاریک",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "حالت خواندن",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "مطالب",
|
title: "مطالب",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Vaalea tila",
|
lightMode: "Vaalea tila",
|
||||||
darkMode: "Tumma tila",
|
darkMode: "Tumma tila",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Lukijatila",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Selain",
|
title: "Selain",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Mode clair",
|
lightMode: "Mode clair",
|
||||||
darkMode: "Mode sombre",
|
darkMode: "Mode sombre",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Mode lecture",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorateur",
|
title: "Explorateur",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Világos mód",
|
lightMode: "Világos mód",
|
||||||
darkMode: "Sötét mód",
|
darkMode: "Sötét mód",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Olvasó mód",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Fájlböngésző",
|
title: "Fájlböngésző",
|
||||||
},
|
},
|
||||||
|
|||||||
87
quartz/i18n/locales/id-ID.ts
Normal file
87
quartz/i18n/locales/id-ID.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import { Translation } from "./definition"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
propertyDefaults: {
|
||||||
|
title: "Tanpa Judul",
|
||||||
|
description: "Tidak ada deskripsi",
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
callout: {
|
||||||
|
note: "Catatan",
|
||||||
|
abstract: "Abstrak",
|
||||||
|
info: "Info",
|
||||||
|
todo: "Daftar Tugas",
|
||||||
|
tip: "Tips",
|
||||||
|
success: "Berhasil",
|
||||||
|
question: "Pertanyaan",
|
||||||
|
warning: "Peringatan",
|
||||||
|
failure: "Gagal",
|
||||||
|
danger: "Bahaya",
|
||||||
|
bug: "Bug",
|
||||||
|
example: "Contoh",
|
||||||
|
quote: "Kutipan",
|
||||||
|
},
|
||||||
|
backlinks: {
|
||||||
|
title: "Tautan Balik",
|
||||||
|
noBacklinksFound: "Tidak ada tautan balik ditemukan",
|
||||||
|
},
|
||||||
|
themeToggle: {
|
||||||
|
lightMode: "Mode Terang",
|
||||||
|
darkMode: "Mode Gelap",
|
||||||
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Mode Pembaca",
|
||||||
|
},
|
||||||
|
explorer: {
|
||||||
|
title: "Penjelajah",
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
createdWith: "Dibuat dengan",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
title: "Tampilan Grafik",
|
||||||
|
},
|
||||||
|
recentNotes: {
|
||||||
|
title: "Catatan Terbaru",
|
||||||
|
seeRemainingMore: ({ remaining }) => `Lihat ${remaining} lagi →`,
|
||||||
|
},
|
||||||
|
transcludes: {
|
||||||
|
transcludeOf: ({ targetSlug }) => `Transklusi dari ${targetSlug}`,
|
||||||
|
linkToOriginal: "Tautan ke asli",
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
title: "Cari",
|
||||||
|
searchBarPlaceholder: "Cari sesuatu",
|
||||||
|
},
|
||||||
|
tableOfContents: {
|
||||||
|
title: "Daftar Isi",
|
||||||
|
},
|
||||||
|
contentMeta: {
|
||||||
|
readingTime: ({ minutes }) => `${minutes} menit baca`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pages: {
|
||||||
|
rss: {
|
||||||
|
recentNotes: "Catatan terbaru",
|
||||||
|
lastFewNotes: ({ count }) => `${count} catatan terakhir`,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
title: "Tidak Ditemukan",
|
||||||
|
notFound: "Halaman ini bersifat privat atau tidak ada.",
|
||||||
|
home: "Kembali ke Beranda",
|
||||||
|
},
|
||||||
|
folderContent: {
|
||||||
|
folder: "Folder",
|
||||||
|
itemsUnderFolder: ({ count }) =>
|
||||||
|
count === 1 ? "1 item di bawah folder ini." : `${count} item di bawah folder ini.`,
|
||||||
|
},
|
||||||
|
tagContent: {
|
||||||
|
tag: "Tag",
|
||||||
|
tagIndex: "Indeks Tag",
|
||||||
|
itemsUnderTag: ({ count }) =>
|
||||||
|
count === 1 ? "1 item dengan tag ini." : `${count} item dengan tag ini.`,
|
||||||
|
showingFirst: ({ count }) => `Menampilkan ${count} tag pertama.`,
|
||||||
|
totalTags: ({ count }) => `Ditemukan total ${count} tag.`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as const satisfies Translation
|
||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Tema chiaro",
|
lightMode: "Tema chiaro",
|
||||||
darkMode: "Tema scuro",
|
darkMode: "Tema scuro",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Modalità lettura",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Esplora",
|
title: "Esplora",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "ライトモード",
|
lightMode: "ライトモード",
|
||||||
darkMode: "ダークモード",
|
darkMode: "ダークモード",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "リーダーモード",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "エクスプローラー",
|
title: "エクスプローラー",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "라이트 모드",
|
lightMode: "라이트 모드",
|
||||||
darkMode: "다크 모드",
|
darkMode: "다크 모드",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "리더 모드",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "탐색기",
|
title: "탐색기",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Šviesus Režimas",
|
lightMode: "Šviesus Režimas",
|
||||||
darkMode: "Tamsus Režimas",
|
darkMode: "Tamsus Režimas",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Modalità lettore",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Naršyklė",
|
title: "Naršyklė",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Lys modus",
|
lightMode: "Lys modus",
|
||||||
darkMode: "Mørk modus",
|
darkMode: "Mørk modus",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Læsemodus",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Utforsker",
|
title: "Utforsker",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Lichte modus",
|
lightMode: "Lichte modus",
|
||||||
darkMode: "Donkere modus",
|
darkMode: "Donkere modus",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Leesmodus",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Verkenner",
|
title: "Verkenner",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Trzyb jasny",
|
lightMode: "Trzyb jasny",
|
||||||
darkMode: "Tryb ciemny",
|
darkMode: "Tryb ciemny",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Tryb czytania",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Przeglądaj",
|
title: "Przeglądaj",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Tema claro",
|
lightMode: "Tema claro",
|
||||||
darkMode: "Tema escuro",
|
darkMode: "Tema escuro",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Modo leitor",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorador",
|
title: "Explorador",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Modul luminos",
|
lightMode: "Modul luminos",
|
||||||
darkMode: "Modul întunecat",
|
darkMode: "Modul întunecat",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Modul de citire",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Explorator",
|
title: "Explorator",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Светлый режим",
|
lightMode: "Светлый режим",
|
||||||
darkMode: "Тёмный режим",
|
darkMode: "Тёмный режим",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Режим чтения",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Проводник",
|
title: "Проводник",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "โหมดสว่าง",
|
lightMode: "โหมดสว่าง",
|
||||||
darkMode: "โหมดมืด",
|
darkMode: "โหมดมืด",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "โหมดอ่าน",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "รายการหน้า",
|
title: "รายการหน้า",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Açık mod",
|
lightMode: "Açık mod",
|
||||||
darkMode: "Koyu mod",
|
darkMode: "Koyu mod",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Okuma modu",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Gezgin",
|
title: "Gezgin",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Світлий режим",
|
lightMode: "Світлий режим",
|
||||||
darkMode: "Темний режим",
|
darkMode: "Темний режим",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Режим читання",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Провідник",
|
title: "Провідник",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "Sáng",
|
lightMode: "Sáng",
|
||||||
darkMode: "Tối",
|
darkMode: "Tối",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "Chế độ đọc",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "Trong bài này",
|
title: "Trong bài này",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "亮色模式",
|
lightMode: "亮色模式",
|
||||||
darkMode: "暗色模式",
|
darkMode: "暗色模式",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "阅读模式",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "探索",
|
title: "探索",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default {
|
|||||||
lightMode: "亮色模式",
|
lightMode: "亮色模式",
|
||||||
darkMode: "暗色模式",
|
darkMode: "暗色模式",
|
||||||
},
|
},
|
||||||
|
readerMode: {
|
||||||
|
title: "閱讀模式",
|
||||||
|
},
|
||||||
explorer: {
|
explorer: {
|
||||||
title: "探索",
|
title: "探索",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
import { resolveRelative, simplifySlug } from "../../util/path"
|
import { FullSlug, isRelativeURL, resolveRelative, simplifySlug } from "../../util/path"
|
||||||
import { QuartzEmitterPlugin } from "../types"
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
import { write } from "./helpers"
|
import { write } from "./helpers"
|
||||||
import { BuildCtx } from "../../util/ctx"
|
import { BuildCtx } from "../../util/ctx"
|
||||||
import { VFile } from "vfile"
|
import { VFile } from "vfile"
|
||||||
|
import path from "path"
|
||||||
|
|
||||||
async function* processFile(ctx: BuildCtx, file: VFile) {
|
async function* processFile(ctx: BuildCtx, file: VFile) {
|
||||||
const ogSlug = simplifySlug(file.data.slug!)
|
const ogSlug = simplifySlug(file.data.slug!)
|
||||||
|
|
||||||
for (const slug of file.data.aliases ?? []) {
|
for (const aliasTarget of file.data.aliases ?? []) {
|
||||||
const redirUrl = resolveRelative(slug, file.data.slug!)
|
const aliasTargetSlug = (
|
||||||
|
isRelativeURL(aliasTarget)
|
||||||
|
? path.normalize(path.join(ogSlug, "..", aliasTarget))
|
||||||
|
: aliasTarget
|
||||||
|
) as FullSlug
|
||||||
|
|
||||||
|
const redirUrl = resolveRelative(aliasTargetSlug, ogSlug)
|
||||||
yield write({
|
yield write({
|
||||||
ctx,
|
ctx,
|
||||||
content: `
|
content: `
|
||||||
@@ -23,7 +30,7 @@ async function* processFile(ctx: BuildCtx, file: VFile) {
|
|||||||
</head>
|
</head>
|
||||||
</html>
|
</html>
|
||||||
`,
|
`,
|
||||||
slug,
|
slug: aliasTargetSlug,
|
||||||
ext: ".html",
|
ext: ".html",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { FilePath, joinSegments } from "../../util/path"
|
import { FilePath, joinSegments } from "../../util/path"
|
||||||
import { QuartzEmitterPlugin } from "../types"
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
|
|
||||||
export function extractDomainFromBaseUrl(baseUrl: string) {
|
export function extractDomainFromBaseUrl(baseUrl: string) {
|
||||||
const url = new URL(`https://${baseUrl}`)
|
const url = new URL(`https://${baseUrl}`)
|
||||||
@@ -12,7 +12,9 @@ export const CNAME: QuartzEmitterPlugin = () => ({
|
|||||||
name: "CNAME",
|
name: "CNAME",
|
||||||
async emit({ argv, cfg }) {
|
async emit({ argv, cfg }) {
|
||||||
if (!cfg.configuration.baseUrl) {
|
if (!cfg.configuration.baseUrl) {
|
||||||
console.warn(chalk.yellow("CNAME emitter requires `baseUrl` to be set in your configuration"))
|
console.warn(
|
||||||
|
styleText("yellow", "CNAME emitter requires `baseUrl` to be set in your configuration"),
|
||||||
|
)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const path = joinSegments(argv.output, "CNAME")
|
const path = joinSegments(argv.output, "CNAME")
|
||||||
|
|||||||
@@ -128,14 +128,8 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
|
|||||||
const umamiScript = document.createElement("script");
|
const umamiScript = document.createElement("script");
|
||||||
umamiScript.src = "${cfg.analytics.host ?? "https://analytics.umami.is"}/script.js";
|
umamiScript.src = "${cfg.analytics.host ?? "https://analytics.umami.is"}/script.js";
|
||||||
umamiScript.setAttribute("data-website-id", "${cfg.analytics.websiteId}");
|
umamiScript.setAttribute("data-website-id", "${cfg.analytics.websiteId}");
|
||||||
umamiScript.setAttribute("data-auto-track", "false");
|
umamiScript.setAttribute("data-auto-track", "true");
|
||||||
umamiScript.defer = true;
|
umamiScript.defer = true;
|
||||||
umamiScript.onload = () => {
|
|
||||||
umami.track();
|
|
||||||
document.addEventListener("nav", () => {
|
|
||||||
umami.track();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
document.head.appendChild(umamiScript);
|
document.head.appendChild(umamiScript);
|
||||||
`)
|
`)
|
||||||
@@ -165,14 +159,10 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
|
|||||||
posthog.init('${cfg.analytics.apiKey}', {
|
posthog.init('${cfg.analytics.apiKey}', {
|
||||||
api_host: '${cfg.analytics.host ?? "https://app.posthog.com"}',
|
api_host: '${cfg.analytics.host ?? "https://app.posthog.com"}',
|
||||||
capture_pageview: false,
|
capture_pageview: false,
|
||||||
})\`
|
});
|
||||||
posthogScript.onload = () => {
|
document.addEventListener('nav', () => {
|
||||||
posthog.capture('$pageview', { path: location.pathname });
|
posthog.capture('$pageview', { path: location.pathname });
|
||||||
|
})\`
|
||||||
document.addEventListener('nav', () => {
|
|
||||||
posthog.capture('$pageview', { path: location.pathname });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
document.head.appendChild(posthogScript);
|
document.head.appendChild(posthogScript);
|
||||||
`)
|
`)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { FullPageLayout } from "../../cfg"
|
|||||||
import { pathToRoot } from "../../util/path"
|
import { pathToRoot } from "../../util/path"
|
||||||
import { defaultContentPageLayout, sharedPageComponents } from "../../../quartz.layout"
|
import { defaultContentPageLayout, sharedPageComponents } from "../../../quartz.layout"
|
||||||
import { Content } from "../../components"
|
import { Content } from "../../components"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
import { write } from "./helpers"
|
import { write } from "./helpers"
|
||||||
import { BuildCtx } from "../../util/ctx"
|
import { BuildCtx } from "../../util/ctx"
|
||||||
import { Node } from "unist"
|
import { Node } from "unist"
|
||||||
@@ -90,7 +90,8 @@ export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOp
|
|||||||
|
|
||||||
if (!containsIndex) {
|
if (!containsIndex) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow(
|
styleText(
|
||||||
|
"yellow",
|
||||||
`\nWarning: you seem to be missing an \`index.md\` home page file at the root of your \`${ctx.argv.directory}\` folder (\`${path.join(ctx.argv.directory, "index.md")} does not exist\`). This may cause errors when deploying.`,
|
`\nWarning: you seem to be missing an \`index.md\` home page file at the root of your \`${ctx.argv.directory}\` folder (\`${path.join(ctx.argv.directory, "index.md")} does not exist\`). This may cause errors when deploying.`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
22
quartz/plugins/emitters/favicon.ts
Normal file
22
quartz/plugins/emitters/favicon.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import sharp from "sharp"
|
||||||
|
import { joinSegments, QUARTZ, FullSlug } from "../../util/path"
|
||||||
|
import { QuartzEmitterPlugin } from "../types"
|
||||||
|
import { write } from "./helpers"
|
||||||
|
import { BuildCtx } from "../../util/ctx"
|
||||||
|
|
||||||
|
export const Favicon: QuartzEmitterPlugin = () => ({
|
||||||
|
name: "Favicon",
|
||||||
|
async *emit({ argv }) {
|
||||||
|
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
|
||||||
|
|
||||||
|
const faviconContent = sharp(iconPath).resize(48, 48).toFormat("png")
|
||||||
|
|
||||||
|
yield write({
|
||||||
|
ctx: { argv } as BuildCtx,
|
||||||
|
slug: "favicon" as FullSlug,
|
||||||
|
ext: ".ico",
|
||||||
|
content: faviconContent,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async *partialEmit() {},
|
||||||
|
})
|
||||||
@@ -5,6 +5,7 @@ export { ContentIndex as ContentIndex } from "./contentIndex"
|
|||||||
export { AliasRedirects } from "./aliases"
|
export { AliasRedirects } from "./aliases"
|
||||||
export { Assets } from "./assets"
|
export { Assets } from "./assets"
|
||||||
export { Static } from "./static"
|
export { Static } from "./static"
|
||||||
|
export { Favicon } from "./favicon"
|
||||||
export { ComponentResources } from "./componentResources"
|
export { ComponentResources } from "./componentResources"
|
||||||
export { NotFoundPage } from "./404"
|
export { NotFoundPage } from "./404"
|
||||||
export { CNAME } from "./cname"
|
export { CNAME } from "./cname"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { write } from "./helpers"
|
|||||||
import { BuildCtx } from "../../util/ctx"
|
import { BuildCtx } from "../../util/ctx"
|
||||||
import { QuartzPluginData } from "../vfile"
|
import { QuartzPluginData } from "../vfile"
|
||||||
import fs from "node:fs/promises"
|
import fs from "node:fs/promises"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
|
|
||||||
const defaultOptions: SocialImageOptions = {
|
const defaultOptions: SocialImageOptions = {
|
||||||
colorScheme: "lightMode",
|
colorScheme: "lightMode",
|
||||||
@@ -36,7 +36,7 @@ async function generateSocialImage(
|
|||||||
const iconData = await fs.readFile(iconPath)
|
const iconData = await fs.readFile(iconPath)
|
||||||
iconBase64 = `data:image/png;base64,${iconData.toString("base64")}`
|
iconBase64 = `data:image/png;base64,${iconData.toString("base64")}`
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(chalk.yellow(`Warning: Could not find icon at ${iconPath}`))
|
console.warn(styleText("yellow", `Warning: Could not find icon at ${iconPath}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageComponent = userOpts.imageStructure({
|
const imageComponent = userOpts.imageStructure({
|
||||||
@@ -55,8 +55,9 @@ async function generateSocialImage(
|
|||||||
fonts,
|
fonts,
|
||||||
loadAdditionalAsset: async (languageCode: string, segment: string) => {
|
loadAdditionalAsset: async (languageCode: string, segment: string) => {
|
||||||
if (languageCode === "emoji") {
|
if (languageCode === "emoji") {
|
||||||
return `data:image/svg+xml;base64,${btoa(await loadEmoji(getIconCode(segment)))}`
|
return await loadEmoji(getIconCode(segment))
|
||||||
}
|
}
|
||||||
|
|
||||||
return languageCode
|
return languageCode
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -101,7 +101,11 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options>> = (userOpts)
|
|||||||
const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"])
|
const socialImage = coalesceAliases(data, ["socialImage", "image", "cover"])
|
||||||
|
|
||||||
const created = coalesceAliases(data, ["created", "date"])
|
const created = coalesceAliases(data, ["created", "date"])
|
||||||
if (created) data.created = created
|
if (created) {
|
||||||
|
data.created = created
|
||||||
|
data.modified ||= created // if modified is not set, use created
|
||||||
|
}
|
||||||
|
|
||||||
const modified = coalesceAliases(data, [
|
const modified = coalesceAliases(data, [
|
||||||
"modified",
|
"modified",
|
||||||
"lastmod",
|
"lastmod",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { Repository } from "@napi-rs/simple-git"
|
import { Repository } from "@napi-rs/simple-git"
|
||||||
import { QuartzTransformerPlugin } from "../types"
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
import chalk from "chalk"
|
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { styleText } from "util"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
priority: ("frontmatter" | "git" | "filesystem")[]
|
priority: ("frontmatter" | "git" | "filesystem")[]
|
||||||
@@ -12,12 +12,23 @@ const defaultOptions: Options = {
|
|||||||
priority: ["frontmatter", "git", "filesystem"],
|
priority: ["frontmatter", "git", "filesystem"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// YYYY-MM-DD
|
||||||
|
const iso8601DateOnlyRegex = /^\d{4}-\d{2}-\d{2}$/
|
||||||
|
|
||||||
function coerceDate(fp: string, d: any): Date {
|
function coerceDate(fp: string, d: any): Date {
|
||||||
|
// check ISO8601 date-only format
|
||||||
|
// we treat this one as local midnight as the normal
|
||||||
|
// js date ctor treats YYYY-MM-DD as UTC midnight
|
||||||
|
if (typeof d === "string" && iso8601DateOnlyRegex.test(d)) {
|
||||||
|
d = `${d}T00:00:00`
|
||||||
|
}
|
||||||
|
|
||||||
const dt = new Date(d)
|
const dt = new Date(d)
|
||||||
const invalidDate = isNaN(dt.getTime()) || dt.getTime() === 0
|
const invalidDate = isNaN(dt.getTime()) || dt.getTime() === 0
|
||||||
if (invalidDate && d !== undefined) {
|
if (invalidDate && d !== undefined) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow(
|
styleText(
|
||||||
|
"yellow",
|
||||||
`\nWarning: found invalid date "${d}" in \`${fp}\`. Supported formats: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format`,
|
`\nWarning: found invalid date "${d}" in \`${fp}\`. Supported formats: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -42,7 +53,10 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
|
|||||||
repositoryWorkdir = repo.workdir() ?? ctx.argv.directory
|
repositoryWorkdir = repo.workdir() ?? ctx.argv.directory
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow(`\nWarning: couldn't find git repository for ${ctx.argv.directory}`),
|
styleText(
|
||||||
|
"yellow",
|
||||||
|
`\nWarning: couldn't find git repository for ${ctx.argv.directory}`,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +83,8 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
|
|||||||
modified ||= await repo.getFileLatestModifiedDateAsync(relativePath)
|
modified ||= await repo.getFileLatestModifiedDateAsync(relativePath)
|
||||||
} catch {
|
} catch {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow(
|
styleText(
|
||||||
|
"yellow",
|
||||||
`\nWarning: ${file.data.filePath!} isn't yet tracked by git, dates will be inaccurate`,
|
`\nWarning: ${file.data.filePath!} isn't yet tracked by git, dates will be inaccurate`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface Options {
|
|||||||
enableYouTubeEmbed: boolean
|
enableYouTubeEmbed: boolean
|
||||||
enableVideoEmbed: boolean
|
enableVideoEmbed: boolean
|
||||||
enableCheckbox: boolean
|
enableCheckbox: boolean
|
||||||
|
disableBrokenWikilinks: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: Options = {
|
const defaultOptions: Options = {
|
||||||
@@ -56,6 +57,7 @@ const defaultOptions: Options = {
|
|||||||
enableYouTubeEmbed: true,
|
enableYouTubeEmbed: true,
|
||||||
enableVideoEmbed: true,
|
enableVideoEmbed: true,
|
||||||
enableCheckbox: false,
|
enableCheckbox: false,
|
||||||
|
disableBrokenWikilinks: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const calloutMapping = {
|
const calloutMapping = {
|
||||||
@@ -113,9 +115,9 @@ export const arrowRegex = new RegExp(/(-{1,2}>|={1,2}>|<-{1,2}|<={1,2})/g)
|
|||||||
// \[\[ -> open brace
|
// \[\[ -> open brace
|
||||||
// ([^\[\]\|\#]+) -> one or more non-special characters ([,],|, or #) (name)
|
// ([^\[\]\|\#]+) -> one or more non-special characters ([,],|, or #) (name)
|
||||||
// (#[^\[\]\|\#]+)? -> # then one or more non-special characters (heading link)
|
// (#[^\[\]\|\#]+)? -> # then one or more non-special characters (heading link)
|
||||||
// (\\?\|[^\[\]\#]+)? -> optional escape \ then | then one or more non-special characters (alias)
|
// (\\?\|[^\[\]\#]+)? -> optional escape \ then | then zero or more non-special characters (alias)
|
||||||
export const wikilinkRegex = new RegExp(
|
export const wikilinkRegex = new RegExp(
|
||||||
/!?\[\[([^\[\]\|\#\\]+)?(#+[^\[\]\|\#\\]+)?(\\?\|[^\[\]\#]+)?\]\]/g,
|
/!?\[\[([^\[\]\|\#\\]+)?(#+[^\[\]\|\#\\]+)?(\\?\|[^\[\]\#]*)?\]\]/g,
|
||||||
)
|
)
|
||||||
|
|
||||||
// ^\|([^\n])+\|\n(\|) -> matches the header row
|
// ^\|([^\n])+\|\n(\|) -> matches the header row
|
||||||
@@ -191,7 +193,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
const [rawFp, rawHeader, rawAlias]: (string | undefined)[] = capture
|
const [rawFp, rawHeader, rawAlias]: (string | undefined)[] = capture
|
||||||
|
|
||||||
const [fp, anchor] = splitAnchor(`${rawFp ?? ""}${rawHeader ?? ""}`)
|
const [fp, anchor] = splitAnchor(`${rawFp ?? ""}${rawHeader ?? ""}`)
|
||||||
const blockRef = Boolean(rawHeader?.match(/^#?\^/)) ? "^" : ""
|
const blockRef = Boolean(rawHeader?.startsWith("#^")) ? "^" : ""
|
||||||
const displayAnchor = anchor ? `#${blockRef}${anchor.trim().replace(/^#+/, "")}` : ""
|
const displayAnchor = anchor ? `#${blockRef}${anchor.trim().replace(/^#+/, "")}` : ""
|
||||||
const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? ""
|
const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? ""
|
||||||
const embedDisplay = value.startsWith("!") ? "!" : ""
|
const embedDisplay = value.startsWith("!") ? "!" : ""
|
||||||
@@ -206,7 +208,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
|
|
||||||
return src
|
return src
|
||||||
},
|
},
|
||||||
markdownPlugins(_ctx) {
|
markdownPlugins(ctx) {
|
||||||
const plugins: PluggableList = []
|
const plugins: PluggableList = []
|
||||||
|
|
||||||
// regex replacements
|
// regex replacements
|
||||||
@@ -222,7 +224,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
let [rawFp, rawHeader, rawAlias] = capture
|
let [rawFp, rawHeader, rawAlias] = capture
|
||||||
const fp = rawFp?.trim() ?? ""
|
const fp = rawFp?.trim() ?? ""
|
||||||
const anchor = rawHeader?.trim() ?? ""
|
const anchor = rawHeader?.trim() ?? ""
|
||||||
const alias = rawAlias?.slice(1).trim()
|
const alias: string | undefined = rawAlias?.slice(1).trim()
|
||||||
|
|
||||||
// embed cases
|
// embed cases
|
||||||
if (value.startsWith("!")) {
|
if (value.startsWith("!")) {
|
||||||
@@ -275,6 +277,18 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
// otherwise, fall through to regular link
|
// otherwise, fall through to regular link
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// treat as broken link if slug not in ctx.allSlugs
|
||||||
|
if (opts.disableBrokenWikilinks) {
|
||||||
|
const slug = slugifyFilePath(fp as FilePath)
|
||||||
|
const exists = ctx.allSlugs && ctx.allSlugs.includes(slug)
|
||||||
|
if (!exists) {
|
||||||
|
return {
|
||||||
|
type: "html",
|
||||||
|
value: `<a class=\"internal broken\">${alias ?? fp}</a>`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// internal link
|
// internal link
|
||||||
const url = fp + anchor
|
const url = fp + anchor
|
||||||
|
|
||||||
@@ -464,6 +478,30 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For the rest of the MD callout elements other than the title, wrap them with
|
||||||
|
// two nested HTML <div>s (use some hacked mdhast component to achieve this) of
|
||||||
|
// class `callout-content` and `callout-content-inner` respectively for
|
||||||
|
// grid-based collapsible animation.
|
||||||
|
if (calloutContent.length > 0) {
|
||||||
|
node.children = [
|
||||||
|
node.children[0],
|
||||||
|
{
|
||||||
|
data: { hProperties: { className: ["callout-content"] }, hName: "div" },
|
||||||
|
type: "blockquote",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
hProperties: { className: ["callout-content-inner"] },
|
||||||
|
hName: "div",
|
||||||
|
},
|
||||||
|
type: "blockquote",
|
||||||
|
children: [...calloutContent],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// replace first line of blockquote with title and rest of the paragraph text
|
// replace first line of blockquote with title and rest of the paragraph text
|
||||||
node.children.splice(0, 1, ...blockquoteContent)
|
node.children.splice(0, 1, ...blockquoteContent)
|
||||||
|
|
||||||
@@ -485,21 +523,6 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
"data-callout-metadata": calloutMetaData,
|
"data-callout-metadata": calloutMetaData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add callout-content class to callout body if it has one.
|
|
||||||
if (calloutContent.length > 0) {
|
|
||||||
const contentData: BlockContent | DefinitionContent = {
|
|
||||||
data: {
|
|
||||||
hProperties: {
|
|
||||||
className: "callout-content",
|
|
||||||
},
|
|
||||||
hName: "div",
|
|
||||||
},
|
|
||||||
type: "blockquote",
|
|
||||||
children: [...calloutContent],
|
|
||||||
}
|
|
||||||
node.children = [node.children[0], contentData]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { ProcessedContent } from "../plugins/vfile"
|
|||||||
import { QuartzLogger } from "../util/log"
|
import { QuartzLogger } from "../util/log"
|
||||||
import { trace } from "../util/trace"
|
import { trace } from "../util/trace"
|
||||||
import { BuildCtx } from "../util/ctx"
|
import { BuildCtx } from "../util/ctx"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
|
|
||||||
export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
||||||
const { argv, cfg } = ctx
|
const { argv, cfg } = ctx
|
||||||
@@ -26,7 +26,7 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
|||||||
if (ctx.argv.verbose) {
|
if (ctx.argv.verbose) {
|
||||||
console.log(`[emit:${emitter.name}] ${file}`)
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
} else {
|
} else {
|
||||||
log.updateText(`${emitter.name} -> ${chalk.gray(file)}`)
|
log.updateText(`${emitter.name} -> ${styleText("gray", file)}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -36,7 +36,7 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
|||||||
if (ctx.argv.verbose) {
|
if (ctx.argv.verbose) {
|
||||||
console.log(`[emit:${emitter.name}] ${file}`)
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
} else {
|
} else {
|
||||||
log.updateText(`${emitter.name} -> ${chalk.gray(file)}`)
|
log.updateText(`${emitter.name} -> ${styleText("gray", file)}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import workerpool, { Promise as WorkerPromise } from "workerpool"
|
|||||||
import { QuartzLogger } from "../util/log"
|
import { QuartzLogger } from "../util/log"
|
||||||
import { trace } from "../util/trace"
|
import { trace } from "../util/trace"
|
||||||
import { BuildCtx, WorkerSerializableBuildCtx } from "../util/ctx"
|
import { BuildCtx, WorkerSerializableBuildCtx } from "../util/ctx"
|
||||||
import chalk from "chalk"
|
import { styleText } from "util"
|
||||||
|
|
||||||
export type QuartzMdProcessor = Processor<MDRoot, MDRoot, MDRoot>
|
export type QuartzMdProcessor = Processor<MDRoot, MDRoot, MDRoot>
|
||||||
export type QuartzHtmlProcessor = Processor<undefined, MDRoot, HTMLRoot>
|
export type QuartzHtmlProcessor = Processor<undefined, MDRoot, HTMLRoot>
|
||||||
@@ -194,7 +194,7 @@ export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<Pro
|
|||||||
textToMarkdownPromises.map(async (promise) => {
|
textToMarkdownPromises.map(async (promise) => {
|
||||||
const result = await promise
|
const result = await promise
|
||||||
processedFiles += result.length
|
processedFiles += result.length
|
||||||
log.updateText(`text->markdown ${chalk.gray(`${processedFiles}/${fps.length}`)}`)
|
log.updateText(`text->markdown ${styleText("gray", `${processedFiles}/${fps.length}`)}`)
|
||||||
return result
|
return result
|
||||||
}),
|
}),
|
||||||
).catch(errorHandler)
|
).catch(errorHandler)
|
||||||
@@ -208,7 +208,7 @@ export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<Pro
|
|||||||
markdownToHtmlPromises.map(async (promise) => {
|
markdownToHtmlPromises.map(async (promise) => {
|
||||||
const result = await promise
|
const result = await promise
|
||||||
processedFiles += result.length
|
processedFiles += result.length
|
||||||
log.updateText(`markdown->html ${chalk.gray(`${processedFiles}/${fps.length}`)}`)
|
log.updateText(`markdown->html ${styleText("gray", `${processedFiles}/${fps.length}`)}`)
|
||||||
return result
|
return result
|
||||||
}),
|
}),
|
||||||
).catch(errorHandler)
|
).catch(errorHandler)
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ html {
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
body,
|
body {
|
||||||
section {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: var(--light);
|
background-color: var(--light);
|
||||||
@@ -65,6 +64,21 @@ ul,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article {
|
||||||
|
> mjx-container.MathJax,
|
||||||
|
blockquote > div > mjx-container.MathJax {
|
||||||
|
display: flex;
|
||||||
|
> svg {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blockquote > div > mjx-container.MathJax > svg {
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
strong {
|
strong {
|
||||||
font-weight: $semiBoldWeight;
|
font-weight: $semiBoldWeight;
|
||||||
}
|
}
|
||||||
@@ -76,7 +90,7 @@ a {
|
|||||||
color: var(--secondary);
|
color: var(--secondary);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--tertiary) !important;
|
color: var(--tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.internal {
|
&.internal {
|
||||||
@@ -86,6 +100,15 @@ a {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
line-height: 1.4rem;
|
line-height: 1.4rem;
|
||||||
|
|
||||||
|
&.broken {
|
||||||
|
color: var(--secondary);
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
&:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:has(> img) {
|
&:has(> img) {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
@@ -108,16 +131,32 @@ a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-component {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
.desktop-only {
|
.desktop-only {
|
||||||
display: initial;
|
display: initial;
|
||||||
|
&.flex-component {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
@media all and ($mobile) {
|
@media all and ($mobile) {
|
||||||
|
&.flex-component {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-only {
|
.mobile-only {
|
||||||
display: none;
|
display: none;
|
||||||
|
&.flex-component {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@media all and ($mobile) {
|
@media all and ($mobile) {
|
||||||
|
&.flex-component {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
display: initial;
|
display: initial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,6 +262,7 @@ a {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
& > * {
|
& > * {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
max-height: 24rem;
|
||||||
}
|
}
|
||||||
& > .toc {
|
& > .toc {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -546,8 +586,8 @@ video {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div:has(> .overflow) {
|
div:has(> .overflow) {
|
||||||
display: flex;
|
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.overflow,
|
ul.overflow,
|
||||||
@@ -562,7 +602,7 @@ ol.overflow {
|
|||||||
clear: both;
|
clear: both;
|
||||||
|
|
||||||
& > li.overflow-end {
|
& > li.overflow-end {
|
||||||
height: 1rem;
|
height: 0.5rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,6 +618,7 @@ ol.overflow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.katex-display {
|
.katex-display {
|
||||||
|
display: initial;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,19 @@
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
transition: max-height 0.3s ease;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
& > .callout-content > :first-child {
|
& > .callout-content {
|
||||||
margin-top: 0;
|
display: grid;
|
||||||
|
transition: grid-template-rows 0.3s ease;
|
||||||
|
|
||||||
|
& > .callout-content-inner {
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
& > :first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
--callout-icon-note: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="2" x2="22" y2="6"></line><path d="M7.5 20.5 19 9l-4-4L3.5 16.5 2 22z"></path></svg>');
|
--callout-icon-note: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="2" x2="22" y2="6"></line><path d="M7.5 20.5 19 9l-4-4L3.5 16.5 2 22z"></path></svg>');
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { QuartzConfig } from "../cfg"
|
import { QuartzConfig } from "../cfg"
|
||||||
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
|
import { FileTrieNode } from "./fileTrie"
|
||||||
import { FilePath, FullSlug } from "./path"
|
import { FilePath, FullSlug } from "./path"
|
||||||
|
|
||||||
export interface Argv {
|
export interface Argv {
|
||||||
@@ -13,13 +15,36 @@ export interface Argv {
|
|||||||
concurrency?: number
|
concurrency?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type BuildTimeTrieData = QuartzPluginData & {
|
||||||
|
slug: string
|
||||||
|
title: string
|
||||||
|
filePath: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface BuildCtx {
|
export interface BuildCtx {
|
||||||
buildId: string
|
buildId: string
|
||||||
argv: Argv
|
argv: Argv
|
||||||
cfg: QuartzConfig
|
cfg: QuartzConfig
|
||||||
allSlugs: FullSlug[]
|
allSlugs: FullSlug[]
|
||||||
allFiles: FilePath[]
|
allFiles: FilePath[]
|
||||||
|
trie?: FileTrieNode<BuildTimeTrieData>
|
||||||
incremental: boolean
|
incremental: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg">
|
export function trieFromAllFiles(allFiles: QuartzPluginData[]): FileTrieNode<BuildTimeTrieData> {
|
||||||
|
const trie = new FileTrieNode<BuildTimeTrieData>([])
|
||||||
|
allFiles.forEach((file) => {
|
||||||
|
if (file.frontmatter) {
|
||||||
|
trie.add({
|
||||||
|
...file,
|
||||||
|
slug: file.slug!,
|
||||||
|
title: file.frontmatter.title,
|
||||||
|
filePath: file.filePath!,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return trie
|
||||||
|
}
|
||||||
|
|
||||||
|
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg" | "trie">
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user