Jacky Zhao
2023-07-05 974b0da3086d21aabf5ef1a3eefa50675c0d4e95
folder and tag descriptions, re-enable relative pathing
5 files modified
18 ■■■■■ changed files
quartz/components/pages/FolderContent.tsx 3 ●●●●● patch | view | raw | blame | history
quartz/components/pages/TagContent.tsx 3 ●●●●● patch | view | raw | blame | history
quartz/path.ts 3 ●●●● patch | view | raw | blame | history
quartz/plugins/transformers/description.ts 4 ●●● patch | view | raw | blame | history
quartz/plugins/transformers/links.ts 5 ●●●●● patch | view | raw | blame | history
quartz/components/pages/FolderContent.tsx
@@ -23,9 +23,12 @@
    allFiles: allPagesInFolder
  }
  const desc = props.fileData.description
  // @ts-ignore
  const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
  return <div class="popover-hint">
    {desc && <p>{desc}</p>}
    <article>{content}</article>
    <p>{allPagesInFolder.length} items under this folder.</p>
    <div>
quartz/components/pages/TagContent.tsx
@@ -17,9 +17,12 @@
      allFiles: allPagesWithTag
    }
    const desc = props.fileData.description
    // @ts-ignore
    const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: 'html' })
    return <div class="popover-hint">
      {desc && <p>{desc}</p>}
      <article>{content}</article>
      <p>{allPagesWithTag.length} items with this tag.</p>
      <div>
quartz/path.ts
@@ -60,8 +60,7 @@
}
export function relative(src: string, dest: string): string {
  return "./" + path.relative(src, dest)
  return path.relative(src, dest)
}
export const QUARTZ = "quartz"
quartz/plugins/transformers/description.ts
@@ -31,7 +31,9 @@
            let sentenceIdx = 0
            const len = opts.descriptionLength
            while (finalDesc.length < len) {
              finalDesc += sentences[sentenceIdx] + '.'
              const sentence = sentences[sentenceIdx]
              if (!sentence) break
              finalDesc += sentence + '.'
              sentenceIdx++
            }
quartz/plugins/transformers/links.ts
@@ -1,5 +1,5 @@
import { QuartzTransformerPlugin } from "../types"
import { clientSideSlug, relativeToRoot, slugify, trimPathSuffix } from "../../path"
import { clientSideSlug, relative, relativeToRoot, slugify, trimPathSuffix } from "../../path"
import path from "path"
import { visit } from 'unist-util-visit'
import isAbsoluteUrl from "is-absolute-url"
@@ -31,8 +31,7 @@
          const transformLink = (target: string) => {
            const targetSlug = slugify(decodeURI(target).trim())
            if (opts.markdownLinkResolution === 'relative' && !path.isAbsolute(targetSlug)) {
              // TODO
              // return './' + relative(curSlug, targetSlug)
              return './' + relative(curSlug, targetSlug)
            } else {
              return './' + relativeToRoot(curSlug, targetSlug)
            }