mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-24 15:05:42 -05:00
Merge branch 'v4' of https://github.com/jackyzha0/quartz
This commit is contained in:
commit
901482553e
3
docs/advanced/index.md
Normal file
3
docs/advanced/index.md
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
title: "Advanced"
|
||||
---
|
||||
@ -21,12 +21,10 @@ const config: QuartzConfig = {
|
||||
This part of the configuration concerns anything that can affect the whole site. The following is a list breaking down all the things you can configure:
|
||||
|
||||
- `pageTitle`: title of the site. This is also used when generating the [[RSS Feed]] for your site.
|
||||
- `description`: description of the site. This will be used when someone installs your site as an App.
|
||||
- `enableSPA`: whether to enable [[SPA Routing]] on your site.
|
||||
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
||||
- `analytics`: what to use for analytics on your site. Values can be
|
||||
- `null`: don't use analytics;
|
||||
- `{ provider: "umami", websiteId: <your-umami-id> }`: easy, privacy-friendly, open source, GDPR Compliant analytics;
|
||||
- `{ provider: 'plausible' }`: use [Plausible](https://plausible.io/), a privacy-friendly alternative to Google Analytics; or
|
||||
- `{ provider: 'google', tagId: <your-google-tag> }`: use Google Analytics
|
||||
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
||||
|
||||
@ -8,6 +8,8 @@ Quartz features an explorer that allows you to navigate all files and folders on
|
||||
|
||||
By default, it shows all folders and files on your page. To display the explorer in a different spot, you can edit the [[layout]].
|
||||
|
||||
Display names for folders get determined by the `title` frontmatter field in `folder/index.md` (more detail in [[authoring content | Authoring Content]]). If this file does not exist or does not contain frontmatter, the local folder name will be used instead.
|
||||
|
||||
> [!info]
|
||||
> The explorer uses local storage by default to save the state of your explorer. This is done to ensure a smooth experience when navigating to different pages.
|
||||
>
|
||||
@ -29,7 +31,7 @@ Component.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
... // default implementation shown later
|
||||
},
|
||||
filterFn: undefined,
|
||||
filterFn: filterFn: (node) => node.name !== "tags", // filters out 'tags' folder
|
||||
mapFn: undefined,
|
||||
// what order to apply functions in
|
||||
order: ["filter", "map", "sort"],
|
||||
@ -57,7 +59,8 @@ All functions you can pass work with the `FileNode` class, which has the followi
|
||||
```ts title="quartz/components/ExplorerNode.tsx" {2-5}
|
||||
export class FileNode {
|
||||
children: FileNode[] // children of current node
|
||||
name: string // name of node (only useful for folders)
|
||||
name: string // last part of slug
|
||||
displayName: string // what actually should be displayed in the explorer
|
||||
file: QuartzPluginData | null // set if node is a file, see `QuartzPluginData` for more detail
|
||||
depth: number // depth of current node
|
||||
|
||||
@ -72,7 +75,7 @@ Every function you can pass is optional. By default, only a `sort` function will
|
||||
Component.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
||||
return a.name.localeCompare(b.name)
|
||||
return a.displayName.localeCompare(b.displayName)
|
||||
}
|
||||
if (a.file && !b.file) {
|
||||
return 1
|
||||
@ -120,7 +123,7 @@ Using this example, the explorer will alphabetically sort everything, but put al
|
||||
Component.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
||||
return a.name.localeCompare(b.name)
|
||||
return a.displayName.localeCompare(b.displayName)
|
||||
}
|
||||
if (a.file && !b.file) {
|
||||
return -1
|
||||
@ -138,7 +141,7 @@ Using this example, the display names of all `FileNodes` (folders + files) will
|
||||
```ts title="quartz.layout.ts"
|
||||
Component.Explorer({
|
||||
mapFn: (node) => {
|
||||
node.name = node.name.toUpperCase()
|
||||
node.displayName = node.displayName.toUpperCase()
|
||||
},
|
||||
})
|
||||
```
|
||||
@ -159,6 +162,16 @@ Component.Explorer({
|
||||
|
||||
You can customize this by changing the entries of the `omit` set. Simply add all folder or file names you want to remove.
|
||||
|
||||
### Show every element in explorer
|
||||
|
||||
To override the default filter function that removes the `tags` folder from the explorer, you can set the filter function to `undefined`.
|
||||
|
||||
```ts title="quartz.layout.ts"
|
||||
Component.Explorer({
|
||||
filterFn: undefined, // apply no filter function, every file and folder will visible
|
||||
})
|
||||
```
|
||||
|
||||
## Advanced examples
|
||||
|
||||
### Add emoji prefix
|
||||
@ -172,9 +185,9 @@ Component.Explorer({
|
||||
if (node.depth > 0) {
|
||||
// set emoji for file/folder
|
||||
if (node.file) {
|
||||
node.name = "📄 " + node.name
|
||||
node.displayName = "📄 " + node.displayName
|
||||
} else {
|
||||
node.name = "📁 " + node.name
|
||||
node.displayName = "📁 " + node.displayName
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
---
|
||||
title: "Offline Access (PWA)"
|
||||
tags:
|
||||
- plugin/emitter
|
||||
---
|
||||
|
||||
This plugin allows your website to be accessible offline and be installed as an app. You can enable it by adding `Plugin.Offline(),` to the `emitters` in `quartz.config.ts`
|
||||
|
||||
## Offline Capability
|
||||
|
||||
Whenever you visit a page it gets cached for offline use. Depending on the kind of content, the process for caching is diffent:
|
||||
|
||||
- **Pages** (HTML, your converted Markdown files): Quartz first tries to get them over the Network. If that fails, your browser attempts to fetch it from the cache.
|
||||
- **Static Resources** (Fonts, CSS Styling, JavaScript): Quartz uses cached resources by default and updates the cache over the network in the background.
|
||||
- **Images**: Images are saved once and then served from cache. Quartz uses a limited cache of 60 images and images remain in the cache for 30 days
|
||||
|
||||
You can edit the fallback page by changing the `offline.md` file in the root of your `content` directory
|
||||
|
||||
## Progressive Web App (PWA)
|
||||
|
||||
Progressive Web Apps can have [many properties](https://developer.mozilla.org/en-US/docs/Web/Manifest). We're only going to mention the ones Quartz supports by default, however you can edit the offline plugins file to add more in case required.
|
||||
|
||||
- **icons**: the `icon.svg` file in the `quartz/static` directory is used for all the icons. This makes it easier to scale the image since you don't need to provide an png for every size
|
||||
- **name**, **short_name**: Uses the `pageTitle` configured in `quartz.config.ts`
|
||||
- **description**: Uses the `description` configured in `quartz.config.ts`
|
||||
- **background_color**, **theme_color**: Uses the `lightMode.light` color configured in `quartz.config.ts`.
|
||||
- **start_url**: Uses the `baseUrl` configured in `quartz.config.ts`
|
||||
|
||||
### Default values
|
||||
|
||||
- **display**: this is set to `minimal-ui`
|
||||
@ -30,7 +30,7 @@ This will guide you through initializing your Quartz with content. Once you've d
|
||||
|
||||
## 🔧 Features
|
||||
|
||||
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[Latex]], [[syntax highlighting]], [[popover previews]], [[offline access]] and [many more](./features) right out of the box
|
||||
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[Latex]], [[syntax highlighting]], [[popover previews]], and [many more](./features) right out of the box
|
||||
- Hot-reload for both configuration and content
|
||||
- Simple JSX layouts and [[creating components|page components]]
|
||||
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
||||
|
||||
3
package-lock.json
generated
3
package-lock.json
generated
@ -73,7 +73,7 @@
|
||||
"@types/flexsearch": "^0.7.3",
|
||||
"@types/hast": "^2.3.4",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^20.6.2",
|
||||
"@types/node": "^20.1.2",
|
||||
"@types/pretty-time": "^1.1.2",
|
||||
"@types/source-map-support": "^0.5.6",
|
||||
"@types/workerpool": "^6.4.0",
|
||||
@ -113,7 +113,6 @@
|
||||
},
|
||||
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
|
||||
"version": "1.3.0",
|
||||
"extraneous": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "@jackyzha0/quartz",
|
||||
"description": "🌱 publish your digital garden and notes as a website",
|
||||
"private": true,
|
||||
"version": "4.0.11",
|
||||
"version": "4.1.0",
|
||||
"type": "module",
|
||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||
"license": "MIT",
|
||||
@ -94,7 +94,7 @@
|
||||
"@types/flexsearch": "^0.7.3",
|
||||
"@types/hast": "^2.3.4",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^20.6.2",
|
||||
"@types/node": "^20.1.2",
|
||||
"@types/pretty-time": "^1.1.2",
|
||||
"@types/source-map-support": "^0.5.6",
|
||||
"@types/workerpool": "^6.4.0",
|
||||
|
||||
@ -19,7 +19,6 @@ export type Analytics =
|
||||
|
||||
export interface GlobalConfiguration {
|
||||
pageTitle: string
|
||||
description: string
|
||||
/** Whether to enable single-page-app style rendering. this prevents flashes of unstyled content and improves smoothness of Quartz */
|
||||
enableSPA: boolean
|
||||
/** Whether to display Wikipedia-style popovers when hovering over links */
|
||||
|
||||
@ -4,6 +4,7 @@ import explorerStyle from "./styles/explorer.scss"
|
||||
// @ts-ignore
|
||||
import script from "./scripts/explorer.inline"
|
||||
import { ExplorerNode, FileNode, Options } from "./ExplorerNode"
|
||||
import { QuartzPluginData } from "../plugins/vfile"
|
||||
|
||||
// Options interface defined in `ExplorerNode` to avoid circular dependency
|
||||
const defaultOptions = {
|
||||
@ -11,10 +12,10 @@ const defaultOptions = {
|
||||
folderClickBehavior: "collapse",
|
||||
folderDefaultState: "collapsed",
|
||||
useSavedState: true,
|
||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
||||
sortFn: (a, b) => {
|
||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
||||
return a.name.localeCompare(b.name)
|
||||
return a.displayName.localeCompare(b.displayName)
|
||||
}
|
||||
if (a.file && !b.file) {
|
||||
return 1
|
||||
@ -27,49 +28,58 @@ const defaultOptions = {
|
||||
} satisfies Options
|
||||
|
||||
export default ((userOpts?: Partial<Options>) => {
|
||||
function Explorer({ allFiles, displayClass, fileData }: QuartzComponentProps) {
|
||||
// Parse config
|
||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||
// Parse config
|
||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||
|
||||
// Construct tree from allFiles
|
||||
const fileTree = new FileNode("")
|
||||
allFiles.forEach((file) => fileTree.add(file, 1))
|
||||
// memoized
|
||||
let fileTree: FileNode
|
||||
let jsonTree: string
|
||||
|
||||
/**
|
||||
* Keys of this object must match corresponding function name of `FileNode`,
|
||||
* while values must be the argument that will be passed to the function.
|
||||
*
|
||||
* e.g. entry for FileNode.sort: `sort: opts.sortFn` (value is sort function from options)
|
||||
*/
|
||||
const functions = {
|
||||
map: opts.mapFn,
|
||||
sort: opts.sortFn,
|
||||
filter: opts.filterFn,
|
||||
}
|
||||
function constructFileTree(allFiles: QuartzPluginData[]) {
|
||||
if (!fileTree) {
|
||||
// Construct tree from allFiles
|
||||
fileTree = new FileNode("")
|
||||
allFiles.forEach((file) => fileTree.add(file, 1))
|
||||
|
||||
// Execute all functions (sort, filter, map) that were provided (if none were provided, only default "sort" is applied)
|
||||
if (opts.order) {
|
||||
// Order is important, use loop with index instead of order.map()
|
||||
for (let i = 0; i < opts.order.length; i++) {
|
||||
const functionName = opts.order[i]
|
||||
if (functions[functionName]) {
|
||||
// for every entry in order, call matching function in FileNode and pass matching argument
|
||||
// e.g. i = 0; functionName = "filter"
|
||||
// converted to: (if opts.filterFn) => fileTree.filter(opts.filterFn)
|
||||
/**
|
||||
* Keys of this object must match corresponding function name of `FileNode`,
|
||||
* while values must be the argument that will be passed to the function.
|
||||
*
|
||||
* e.g. entry for FileNode.sort: `sort: opts.sortFn` (value is sort function from options)
|
||||
*/
|
||||
const functions = {
|
||||
map: opts.mapFn,
|
||||
sort: opts.sortFn,
|
||||
filter: opts.filterFn,
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
// typescript cant statically check these dynamic references, so manually make sure reference is valid and ignore warning
|
||||
fileTree[functionName].call(fileTree, functions[functionName])
|
||||
// Execute all functions (sort, filter, map) that were provided (if none were provided, only default "sort" is applied)
|
||||
if (opts.order) {
|
||||
// Order is important, use loop with index instead of order.map()
|
||||
for (let i = 0; i < opts.order.length; i++) {
|
||||
const functionName = opts.order[i]
|
||||
if (functions[functionName]) {
|
||||
// for every entry in order, call matching function in FileNode and pass matching argument
|
||||
// e.g. i = 0; functionName = "filter"
|
||||
// converted to: (if opts.filterFn) => fileTree.filter(opts.filterFn)
|
||||
|
||||
// @ts-ignore
|
||||
// typescript cant statically check these dynamic references, so manually make sure reference is valid and ignore warning
|
||||
fileTree[functionName].call(fileTree, functions[functionName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all folders of tree. Initialize with collapsed state
|
||||
const folders = fileTree.getFolderPaths(opts.folderDefaultState === "collapsed")
|
||||
|
||||
// Stringify to pass json tree as data attribute ([data-tree])
|
||||
jsonTree = JSON.stringify(folders)
|
||||
}
|
||||
}
|
||||
|
||||
// Get all folders of tree. Initialize with collapsed state
|
||||
const folders = fileTree.getFolderPaths(opts.folderDefaultState === "collapsed")
|
||||
|
||||
// Stringify to pass json tree as data attribute ([data-tree])
|
||||
const jsonTree = JSON.stringify(folders)
|
||||
|
||||
function Explorer({ allFiles, displayClass, fileData }: QuartzComponentProps) {
|
||||
constructFileTree(allFiles)
|
||||
return (
|
||||
<div class={`explorer ${displayClass}`}>
|
||||
<button
|
||||
@ -80,7 +90,7 @@ export default ((userOpts?: Partial<Options>) => {
|
||||
data-savestate={opts.useSavedState}
|
||||
data-tree={jsonTree}
|
||||
>
|
||||
<h3>{opts.title}</h3>
|
||||
<h1>{opts.title}</h1>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
@ -99,7 +109,7 @@ export default ((userOpts?: Partial<Options>) => {
|
||||
<div id="explorer-content">
|
||||
<ul class="overflow" id="explorer-ul">
|
||||
<ExplorerNode node={fileTree} opts={opts} fileData={fileData} />
|
||||
<div id="explorer-end" />
|
||||
<li id="explorer-end" />
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -29,19 +29,28 @@ export type FolderState = {
|
||||
export class FileNode {
|
||||
children: FileNode[]
|
||||
name: string
|
||||
displayName: string
|
||||
file: QuartzPluginData | null
|
||||
depth: number
|
||||
|
||||
constructor(name: string, file?: QuartzPluginData, depth?: number) {
|
||||
this.children = []
|
||||
this.name = name
|
||||
this.displayName = name
|
||||
this.file = file ? structuredClone(file) : null
|
||||
this.depth = depth ?? 0
|
||||
}
|
||||
|
||||
private insert(file: DataWrapper) {
|
||||
if (file.path.length === 1) {
|
||||
this.children.push(new FileNode(file.file.frontmatter!.title, file.file, this.depth + 1))
|
||||
if (file.path[0] !== "index.md") {
|
||||
this.children.push(new FileNode(file.file.frontmatter!.title, file.file, this.depth + 1))
|
||||
} else {
|
||||
const title = file.file.frontmatter?.title
|
||||
if (title && title !== "index" && file.path[0] === "index.md") {
|
||||
this.displayName = title
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const next = file.path[0]
|
||||
file.path = file.path.splice(1)
|
||||
@ -145,12 +154,12 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<li>
|
||||
{node.file ? (
|
||||
// Single file node
|
||||
<li key={node.file.slug}>
|
||||
<a href={resolveRelative(fileData.slug!, node.file.slug!)} data-for={node.file.slug}>
|
||||
{node.name}
|
||||
{node.displayName}
|
||||
</a>
|
||||
</li>
|
||||
) : (
|
||||
@ -174,17 +183,17 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
|
||||
<polyline points="6 9 12 15 18 9"></polyline>
|
||||
</svg>
|
||||
{/* render <a> tag if folderBehavior is "link", otherwise render <button> with collapse click event */}
|
||||
<li key={node.name} data-folderpath={folderPath}>
|
||||
<div key={node.name} data-folderpath={folderPath}>
|
||||
{folderBehavior === "link" ? (
|
||||
<a href={`${folderPath}`} data-for={node.name} class="folder-title">
|
||||
{node.name}
|
||||
{node.displayName}
|
||||
</a>
|
||||
) : (
|
||||
<button class="folder-button">
|
||||
<h3 class="folder-title">{node.name}</h3>
|
||||
<p class="folder-title">{node.displayName}</p>
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{/* Recursively render children of folder */}
|
||||
@ -210,6 +219,6 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
@ -14,8 +14,6 @@ export default (() => {
|
||||
|
||||
const iconPath = joinSegments(baseDir, "static/icon.png")
|
||||
const ogImagePath = `https://${cfg.baseUrl}/static/og-image.png`
|
||||
const manifest =
|
||||
cfg.baseUrl == undefined ? "/manifest.json" : `https://${cfg.baseUrl}/manifest.json`
|
||||
|
||||
return (
|
||||
<head>
|
||||
@ -27,9 +25,7 @@ export default (() => {
|
||||
{cfg.baseUrl && <meta property="og:image" content={ogImagePath} />}
|
||||
<meta property="og:width" content="1200" />
|
||||
<meta property="og:height" content="675" />
|
||||
<meta name="theme-color" content="#faf8f8" />
|
||||
<link rel="icon" href={iconPath} />
|
||||
<link rel="manifest" href={manifest} />
|
||||
<meta name="description" content={description} />
|
||||
<meta name="generator" content="Quartz" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
import { QuartzComponentConstructor } from "../types"
|
||||
|
||||
function OfflineFallbackPage() {
|
||||
return (
|
||||
<article class="popover-hint">
|
||||
<h1>Offline</h1>
|
||||
<p>You're offline and this page hasn't been cached yet.</p>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
export default (() => OfflineFallbackPage) satisfies QuartzComponentConstructor
|
||||
@ -113,9 +113,11 @@ function setupExplorer() {
|
||||
) as HTMLElement
|
||||
|
||||
// Get corresponding content <ul> tag and set state
|
||||
const folderUL = folderLi.parentElement?.nextElementSibling
|
||||
if (folderUL) {
|
||||
setFolderState(folderUL as HTMLElement, folderUl.collapsed)
|
||||
if (folderLi) {
|
||||
const folderUL = folderLi.parentElement?.nextElementSibling
|
||||
if (folderUL) {
|
||||
setFolderState(folderUL as HTMLElement, folderUl.collapsed)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
button#explorer {
|
||||
all: unset;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
text-align: left;
|
||||
@ -8,7 +9,7 @@ button#explorer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
& h3 {
|
||||
& h1 {
|
||||
font-size: 1rem;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
@ -58,7 +59,7 @@ button#explorer {
|
||||
max-height 0.35s ease,
|
||||
transform 0.35s ease,
|
||||
opacity 0.2s ease;
|
||||
& div > li > a {
|
||||
& li > a {
|
||||
color: var(--dark);
|
||||
opacity: 0.75;
|
||||
pointer-events: all;
|
||||
@ -80,19 +81,20 @@ svg {
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
|
||||
& li > a {
|
||||
// other selector is more specific, needs important
|
||||
color: var(--secondary) !important;
|
||||
opacity: 1 !important;
|
||||
font-size: 1.05rem !important;
|
||||
& div > a {
|
||||
color: var(--secondary);
|
||||
font-family: var(--headerFont);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.5rem;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
& li > a:hover {
|
||||
// other selector is more specific, needs important
|
||||
color: var(--tertiary) !important;
|
||||
& div > a:hover {
|
||||
color: var(--tertiary);
|
||||
}
|
||||
|
||||
& li > button {
|
||||
& div > button {
|
||||
color: var(--dark);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
@ -102,15 +104,15 @@ svg {
|
||||
padding-right: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-family: var(--headerFont);
|
||||
|
||||
& h3 {
|
||||
& p {
|
||||
font-size: 0.95rem;
|
||||
display: inline-block;
|
||||
color: var(--secondary);
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
line-height: 1.5rem;
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
@ -138,5 +140,7 @@ div:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
||||
|
||||
#explorer-end {
|
||||
// needs height so IntersectionObserver gets triggered
|
||||
height: 1px;
|
||||
height: 4px;
|
||||
// remove default margin from li
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@ -116,11 +116,6 @@ function addGlobalPageResources(
|
||||
document.dispatchEvent(event)`)
|
||||
}
|
||||
|
||||
componentResources.afterDOMLoaded.push(`
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js');
|
||||
}`)
|
||||
|
||||
let wsUrl = `ws://localhost:${ctx.argv.wsPort}`
|
||||
|
||||
if (ctx.argv.remoteDevHost) {
|
||||
|
||||
@ -7,4 +7,3 @@ export { Assets } from "./assets"
|
||||
export { Static } from "./static"
|
||||
export { ComponentResources } from "./componentResources"
|
||||
export { NotFoundPage } from "./404"
|
||||
export { Offline } from "./offline"
|
||||
|
||||
@ -1,97 +0,0 @@
|
||||
import { QuartzEmitterPlugin } from "../types"
|
||||
import { FilePath, FullSlug } from "../../util/path"
|
||||
import { FullPageLayout } from "../../cfg"
|
||||
import { sharedPageComponents } from "../../../quartz.layout"
|
||||
import OfflineFallbackPage from "../../components/pages/OfflineFallbackPage"
|
||||
import BodyConstructor from "../../components/Body"
|
||||
import { pageResources, renderPage } from "../../components/renderPage"
|
||||
import { defaultProcessedContent } from "../vfile"
|
||||
import { QuartzComponentProps } from "../../components/types"
|
||||
|
||||
export const Offline: QuartzEmitterPlugin = () => {
|
||||
const opts: FullPageLayout = {
|
||||
...sharedPageComponents,
|
||||
pageBody: OfflineFallbackPage(),
|
||||
beforeBody: [],
|
||||
left: [],
|
||||
right: [],
|
||||
}
|
||||
|
||||
const { head: Head, pageBody, footer: Footer } = opts
|
||||
const Body = BodyConstructor()
|
||||
|
||||
return {
|
||||
name: "OfflineSupport",
|
||||
getQuartzComponents() {
|
||||
return [Head, Body, pageBody, Footer]
|
||||
},
|
||||
async emit({ cfg }, _content, resources, emit): Promise<FilePath[]> {
|
||||
const manifest = {
|
||||
short_name: cfg.configuration.pageTitle,
|
||||
name: cfg.configuration.pageTitle,
|
||||
description: cfg.configuration.description,
|
||||
background_color: cfg.configuration.theme.colors.lightMode.light,
|
||||
theme_color: cfg.configuration.theme.colors.lightMode.light,
|
||||
display: "minimal-ui",
|
||||
icons: [
|
||||
{
|
||||
src: "static/icon.svg",
|
||||
sizes: "any",
|
||||
purpose: "maskable",
|
||||
},
|
||||
{
|
||||
src: "static/icon.svg",
|
||||
sizes: "any",
|
||||
purpose: "any",
|
||||
},
|
||||
],
|
||||
start_url:
|
||||
cfg.configuration.baseUrl == undefined ? "/" : `https://${cfg.configuration.baseUrl}/`,
|
||||
}
|
||||
|
||||
const serviceWorker =
|
||||
"importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js');" +
|
||||
"const {pageCache, imageCache, staticResourceCache, googleFontsCache, offlineFallback} = workbox.recipes;" +
|
||||
"pageCache(); googleFontsCache(); staticResourceCache(); imageCache(); offlineFallback();"
|
||||
|
||||
const slug = "offline" as FullSlug
|
||||
|
||||
const url = new URL(`https://${cfg.configuration.baseUrl ?? "example.com"}`)
|
||||
const path = url.pathname as FullSlug
|
||||
const externalResources = pageResources(path, resources)
|
||||
const [tree, vfile] = defaultProcessedContent({
|
||||
slug,
|
||||
text: "Offline",
|
||||
description: "You're offline and this page hasn't been cached yet.",
|
||||
frontmatter: { title: "Offline", tags: [] },
|
||||
})
|
||||
|
||||
const componentData: QuartzComponentProps = {
|
||||
fileData: vfile.data,
|
||||
externalResources,
|
||||
cfg: cfg.configuration,
|
||||
children: [],
|
||||
tree,
|
||||
allFiles: [],
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
emit({
|
||||
content: JSON.stringify(manifest),
|
||||
slug: "manifest" as FullSlug,
|
||||
ext: ".json",
|
||||
}),
|
||||
emit({
|
||||
content: serviceWorker,
|
||||
slug: "sw" as FullSlug,
|
||||
ext: ".js",
|
||||
}),
|
||||
emit({
|
||||
content: renderPage(slug, componentData, opts, externalResources),
|
||||
slug,
|
||||
ext: ".html",
|
||||
}),
|
||||
])
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
|
||||
<g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M990 1852 c-30 -20 -147 -97 -260 -171 -113 -74 -207 -136 -209 -138
|
||||
-2 -1 20 -93 49 -203 29 -110 51 -202 49 -204 -2 -2 -35 3 -72 11 -37 8 -69
|
||||
14 -71 12 -1 -2 -24 -66 -50 -141 l-47 -137 124 -175 125 -174 -40 -66 -40
|
||||
-67 26 -32 c13 -18 36 -45 49 -62 20 -24 23 -34 16 -60 -15 -50 -13 -52 74
|
||||
-65 54 -8 89 -19 103 -32 21 -19 26 -19 126 -5 97 13 111 13 192 -4 l86 -19
|
||||
57 28 c52 27 58 33 77 87 20 56 24 60 90 96 60 32 74 46 103 96 18 32 33 61
|
||||
33 65 0 3 -37 20 -82 36 -67 24 -82 34 -80 49 2 10 47 154 99 321 l94 303 -46
|
||||
138 -46 138 -89 47 c-89 47 -90 48 -90 85 0 36 -6 43 -142 159 -79 67 -145
|
||||
122 -148 121 -3 0 -30 -17 -60 -37z m60 0 c0 -4 18 -91 40 -192 22 -101 40
|
||||
-192 40 -201 0 -11 -15 -22 -42 -31 l-43 -15 -5 -202 -5 -202 -84 -55 c-46
|
||||
-30 -86 -53 -88 -51 -2 3 -58 522 -75 710 -3 24 13 41 122 137 120 105 140
|
||||
119 140 102z m163 -121 c96 -83 107 -96 107 -126 l0 -33 -90 -22 c-50 -12 -92
|
||||
-21 -94 -19 -1 2 -15 65 -30 139 -15 74 -30 146 -33 160 -7 29 -21 39 140 -99z
|
||||
m-333 16 c-20 -17 -53 -47 -75 -66 l-39 -34 38 -373 c21 -205 36 -380 33 -388
|
||||
-10 -25 -21 -20 -89 38 l-63 54 -75 277 c-62 232 -72 278 -60 285 8 5 92 61
|
||||
185 124 94 63 172 115 175 115 3 0 -11 -14 -30 -32z m423 -279 c-8 -46 -16
|
||||
-84 -18 -87 -6 -5 -169 21 -178 29 -5 4 4 11 19 14 24 6 26 10 21 46 -5 39 -4
|
||||
40 31 49 21 5 53 14 72 19 70 20 69 22 53 -70z m122 39 l80 -43 37 -115 c21
|
||||
-62 38 -117 38 -121 0 -12 -29 -9 -124 15 l-90 22 -31 52 -32 53 16 90 c8 49
|
||||
18 90 21 90 3 0 41 -20 85 -43z m-124 -168 c8 -12 24 -36 34 -55 l18 -34 -57
|
||||
-203 c-32 -111 -61 -205 -65 -210 -4 -4 -20 25 -37 64 -28 69 -31 72 -81 93
|
||||
l-53 21 0 191 0 191 113 -19 c87 -15 116 -24 128 -39z m184 -121 c55 -12 101
|
||||
-22 103 -23 4 -3 -189 -619 -197 -627 -7 -8 -102 -28 -131 -28 -17 0 -17 4 2
|
||||
67 l21 68 -22 60 -21 60 60 210 c72 249 67 235 77 235 4 0 53 -10 108 -22z
|
||||
m-901 -171 c50 -45 119 -107 154 -136 34 -30 62 -57 62 -60 -1 -3 -19 -18 -41
|
||||
-33 -34 -24 -49 -28 -110 -28 -66 0 -79 4 -161 47 -49 26 -87 52 -85 57 2 6
|
||||
21 62 42 124 21 61 40 112 43 112 3 0 46 -37 96 -83z m41 62 c11 -11 36 -91
|
||||
30 -98 -3 -2 -34 24 -70 59 l-66 62 48 -7 c26 -3 52 -11 58 -16z m478 -129
|
||||
l46 -20 -36 -61 c-32 -53 -53 -73 -182 -163 l-145 -103 -56 15 c-30 8 -59 18
|
||||
-64 23 -13 12 59 99 122 148 52 39 260 181 267 181 1 0 23 -9 48 -20z m111
|
||||
-170 c25 -63 46 -121 46 -129 0 -24 -64 -251 -70 -251 -4 0 -27 90 -53 200
|
||||
l-46 200 32 54 c18 30 35 52 39 48 3 -4 27 -59 52 -122z m-605 -85 c18 -25 29
|
||||
-49 26 -55 -3 -5 5 -47 19 -92 18 -59 21 -77 10 -63 -37 47 -234 324 -234 328
|
||||
0 2 33 -13 73 -34 53 -27 82 -51 106 -84z m471 80 c0 -3 20 -92 45 -197 25
|
||||
-106 45 -200 45 -210 0 -16 -12 -18 -139 -18 -101 0 -142 3 -148 13 -4 6 -25
|
||||
59 -45 117 -28 82 -34 108 -25 117 18 19 251 182 260 183 4 0 7 -2 7 -5z
|
||||
m-397 -64 c-24 -39 -33 -39 -62 -2 l-24 31 53 0 52 0 -19 -29z m61 -115 c37
|
||||
-11 39 -14 72 -106 19 -52 37 -103 39 -112 5 -14 -5 -12 -67 11 -81 31 -80 31
|
||||
-116 158 l-20 73 26 -7 c15 -3 44 -11 66 -17z m642 -118 c-3 -17 -8 -33 -10
|
||||
-35 -2 -3 -27 6 -56 18 -54 23 -55 35 -5 42 76 11 78 10 71 -25z m89 10 c64
|
||||
-24 59 -33 -23 -44 -48 -6 -52 -5 -52 14 0 20 9 52 15 52 2 0 29 -10 60 -22z
|
||||
m-814 -30 c27 -33 23 -43 -20 -56 -59 -18 -62 -15 -33 33 15 25 28 45 30 45 2
|
||||
0 12 -10 23 -22z m647 -9 c60 -25 60 -25 -42 -64 l-64 -24 16 60 c9 33 21 58
|
||||
27 55 5 -2 34 -14 63 -27z m228 -36 c-31 -58 -30 -57 -75 -28 -23 16 -40 29
|
||||
-38 31 5 5 122 32 125 29 2 -2 -3 -16 -12 -32z m-863 -74 c-10 -29 -19 -56
|
||||
-21 -59 -5 -6 -72 70 -72 80 0 7 101 40 107 36 1 -1 -5 -27 -14 -57z m176 5
|
||||
c3 -3 1 -8 -5 -12 -6 -4 -49 -35 -96 -69 -47 -35 -88 -63 -91 -63 -4 0 34 153
|
||||
48 188 3 9 21 6 72 -13 37 -14 69 -28 72 -31z m520 24 c-1 -18 -4 -45 -8 -60
|
||||
l-6 -27 -62 28 c-35 15 -65 30 -68 33 -6 6 111 57 133 58 7 0 12 -12 11 -32z
|
||||
m72 10 c22 -12 39 -25 39 -29 0 -10 -90 -62 -97 -56 -6 7 7 107 14 107 3 0 23
|
||||
-10 44 -22z m-346 -58 c-22 -10 -63 -28 -92 -39 l-52 -20 -26 33 c-14 18 -25
|
||||
36 -25 39 0 4 53 7 118 6 l117 -1 -40 -18z m-198 -17 c36 -47 36 -51 -14 -87
|
||||
-27 -20 -51 -36 -54 -36 -4 0 5 32 19 70 15 39 28 70 31 70 2 0 10 -8 18 -17z
|
||||
m256 4 c-61 -97 -96 -147 -102 -147 -4 0 -26 19 -49 43 l-43 43 88 36 c97 40
|
||||
118 45 106 25z m134 -14 c32 -15 59 -28 61 -29 2 -1 -2 -22 -8 -45 l-12 -44
|
||||
-24 30 c-42 52 -85 115 -80 115 3 0 32 -12 63 -27z m-464 -62 l-27 -73 -60 7
|
||||
c-59 6 -74 11 -65 19 28 24 173 126 175 123 2 -2 -8 -36 -23 -76z m371 -12 c4
|
||||
-45 10 -88 13 -96 6 -16 -16 -14 -100 11 l-38 11 53 82 c29 45 55 80 59 77 3
|
||||
-2 10 -40 13 -85z m116 -59 c0 -7 -65 -40 -79 -40 -5 0 -12 30 -15 68 -4 37
|
||||
-9 81 -12 97 -5 25 3 18 50 -44 31 -41 56 -77 56 -81z m-317 25 c21 -25 32
|
||||
-45 25 -45 -7 0 -42 -5 -78 -10 -35 -5 -66 -7 -68 -5 -6 5 68 105 77 105 4 0
|
||||
24 -20 44 -45z m-124 -24 c-21 -28 -49 -42 -49 -23 0 8 63 62 68 57 2 -2 -6
|
||||
-17 -19 -34z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.0 KiB |
@ -446,7 +446,7 @@ video {
|
||||
|
||||
ul.overflow,
|
||||
ol.overflow {
|
||||
max-height: 300;
|
||||
max-height: 400;
|
||||
overflow-y: auto;
|
||||
|
||||
// clearfix
|
||||
|
||||
Loading…
Reference in New Issue
Block a user