folder and tag descriptions, re-enable relative pathing
This commit is contained in:
parent
2a17431460
commit
974b0da308
@ -23,9 +23,12 @@ function FolderContent(props: QuartzComponentProps) {
|
|||||||
allFiles: allPagesInFolder
|
allFiles: allPagesInFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const desc = props.fileData.description
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
|
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
|
||||||
return <div class="popover-hint">
|
return <div class="popover-hint">
|
||||||
|
{desc && <p>{desc}</p>}
|
||||||
<article>{content}</article>
|
<article>{content}</article>
|
||||||
<p>{allPagesInFolder.length} items under this folder.</p>
|
<p>{allPagesInFolder.length} items under this folder.</p>
|
||||||
<div>
|
<div>
|
||||||
|
@ -17,9 +17,12 @@ function TagContent(props: QuartzComponentProps) {
|
|||||||
allFiles: allPagesWithTag
|
allFiles: allPagesWithTag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const desc = props.fileData.description
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
|
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
|
||||||
return <div class="popover-hint">
|
return <div class="popover-hint">
|
||||||
|
{desc && <p>{desc}</p>}
|
||||||
<article>{content}</article>
|
<article>{content}</article>
|
||||||
<p>{allPagesWithTag.length} items with this tag.</p>
|
<p>{allPagesWithTag.length} items with this tag.</p>
|
||||||
<div>
|
<div>
|
||||||
|
@ -60,8 +60,7 @@ export function relativeToRoot(slug: string, fp: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function relative(src: string, dest: string): string {
|
export function relative(src: string, dest: string): string {
|
||||||
return "./" + path.relative(src, dest)
|
return path.relative(src, dest)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const QUARTZ = "quartz"
|
export const QUARTZ = "quartz"
|
||||||
|
@ -31,7 +31,9 @@ export const Description: QuartzTransformerPlugin<Partial<Options> | undefined>
|
|||||||
let sentenceIdx = 0
|
let sentenceIdx = 0
|
||||||
const len = opts.descriptionLength
|
const len = opts.descriptionLength
|
||||||
while (finalDesc.length < len) {
|
while (finalDesc.length < len) {
|
||||||
finalDesc += sentences[sentenceIdx] + '.'
|
const sentence = sentences[sentenceIdx]
|
||||||
|
if (!sentence) break
|
||||||
|
finalDesc += sentence + '.'
|
||||||
sentenceIdx++
|
sentenceIdx++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { QuartzTransformerPlugin } from "../types"
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
import { clientSideSlug, relativeToRoot, slugify, trimPathSuffix } from "../../path"
|
import { clientSideSlug, relative, relativeToRoot, slugify, trimPathSuffix } from "../../path"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { visit } from 'unist-util-visit'
|
import { visit } from 'unist-util-visit'
|
||||||
import isAbsoluteUrl from "is-absolute-url"
|
import isAbsoluteUrl from "is-absolute-url"
|
||||||
@ -31,8 +31,7 @@ export const CrawlLinks: QuartzTransformerPlugin<Partial<Options> | undefined> =
|
|||||||
const transformLink = (target: string) => {
|
const transformLink = (target: string) => {
|
||||||
const targetSlug = slugify(decodeURI(target).trim())
|
const targetSlug = slugify(decodeURI(target).trim())
|
||||||
if (opts.markdownLinkResolution === 'relative' && !path.isAbsolute(targetSlug)) {
|
if (opts.markdownLinkResolution === 'relative' && !path.isAbsolute(targetSlug)) {
|
||||||
// TODO
|
return './' + relative(curSlug, targetSlug)
|
||||||
// return './' + relative(curSlug, targetSlug)
|
|
||||||
} else {
|
} else {
|
||||||
return './' + relativeToRoot(curSlug, targetSlug)
|
return './' + relativeToRoot(curSlug, targetSlug)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user