The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs + chore: cleanup custom sort ordering for folder + tag listings, add docs

+43 -24
+1 -1
docs/features/folder and tag listings.md
··· 30 30 31 31 ## Customization 32 32 33 - The folder listings are a functionality of the [[FolderPage]] plugin, the tag listings of the [[TagPage]] plugin. See the plugin pages for customization options. 33 + Quartz allows you to define a custom sort ordering for content on both page types. The folder listings are a functionality of the [[FolderPage]] plugin, the tag listings of the [[TagPage]] plugin. See the plugin pages for customization options.
+4 -2
docs/plugins/FolderPage.md
··· 11 11 > [!note] 12 12 > For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page. 13 13 14 - This plugin has no configuration options. 14 + The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `FolderContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/FolderContent.tsx`). 15 15 16 - The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `FolderContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/FolderContent.tsx`). 16 + This plugin accepts the following configuration options: 17 + 18 + - `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order. 17 19 18 20 ## API 19 21
+4 -2
docs/plugins/TagPage.md
··· 9 9 > [!note] 10 10 > For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page. 11 11 12 - This plugin has no configuration options. 12 + The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `TagContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/TagContent.tsx`). 13 13 14 - The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `TagContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/TagContent.tsx`). 14 + This plugin accepts the following configuration options: 15 + 16 + - `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order. 15 17 16 18 ## API 17 19
+4 -4
quartz/components/PageList.tsx
··· 4 4 import { QuartzComponent, QuartzComponentProps } from "./types" 5 5 import { GlobalConfiguration } from "../cfg" 6 6 7 - export function byDateAndAlphabetical( 8 - cfg: GlobalConfiguration, 9 - ): (f1: QuartzPluginData, f2: QuartzPluginData) => number { 7 + export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number 8 + 9 + export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn { 10 10 return (f1, f2) => { 11 11 if (f1.dates && f2.dates) { 12 12 // sort descending ··· 27 27 28 28 type Props = { 29 29 limit?: number 30 - sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number 30 + sort?: SortFn 31 31 } & QuartzComponentProps 32 32 33 33 export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
+2 -3
quartz/components/pages/FolderContent.tsx
··· 2 2 import path from "path" 3 3 4 4 import style from "../styles/listPage.scss" 5 - import { PageList } from "../PageList" 5 + import { PageList, SortFn } from "../PageList" 6 6 import { stripSlashes, simplifySlug } from "../../util/path" 7 7 import { Root } from "hast" 8 8 import { htmlToJsx } from "../../util/jsx" 9 9 import { i18n } from "../../i18n" 10 - import { QuartzPluginData } from "../../plugins/vfile" 11 10 12 11 interface FolderContentOptions { 13 12 /** 14 13 * Whether to display number of folders 15 14 */ 16 15 showFolderCount: boolean 17 - sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number 16 + sort?: SortFn 18 17 } 19 18 20 19 const defaultOptions: FolderContentOptions = {
+18 -6
quartz/components/pages/TagContent.tsx
··· 1 1 import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types" 2 2 import style from "../styles/listPage.scss" 3 - import { PageList } from "../PageList" 3 + import { PageList, SortFn } from "../PageList" 4 4 import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path" 5 5 import { QuartzPluginData } from "../../plugins/vfile" 6 6 import { Root } from "hast" 7 7 import { htmlToJsx } from "../../util/jsx" 8 8 import { i18n } from "../../i18n" 9 9 10 - export default ((opts?: { sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number }) => { 11 - const numPages = 10 10 + interface TagContentOptions { 11 + sort?: SortFn 12 + numPages: number 13 + } 14 + 15 + const defaultOptions: TagContentOptions = { 16 + numPages: 10, 17 + } 18 + 19 + export default ((opts?: Partial<TagContentOptions>) => { 20 + const options: TagContentOptions = { ...defaultOptions, ...opts } 21 + 12 22 const TagContent: QuartzComponent = (props: QuartzComponentProps) => { 13 23 const { tree, fileData, allFiles, cfg } = props 14 24 const slug = fileData.slug ··· 72 82 <div class="page-listing"> 73 83 <p> 74 84 {i18n(cfg.locale).pages.tagContent.itemsUnderTag({ count: pages.length })} 75 - {pages.length > numPages && ( 85 + {pages.length > options.numPages && ( 76 86 <> 77 87 {" "} 78 88 <span> 79 - {i18n(cfg.locale).pages.tagContent.showingFirst({ count: numPages })} 89 + {i18n(cfg.locale).pages.tagContent.showingFirst({ 90 + count: options.numPages, 91 + })} 80 92 </span> 81 93 </> 82 94 )} 83 95 </p> 84 - <PageList limit={numPages} {...listProps} sort={opts?.sort} /> 96 + <PageList limit={options.numPages} {...listProps} sort={opts?.sort} /> 85 97 </div> 86 98 </div> 87 99 )
+5 -3
quartz/plugins/emitters/folderPage.tsx
··· 21 21 import { i18n } from "../../i18n" 22 22 import DepGraph from "../../depgraph" 23 23 24 - export const FolderPage: QuartzEmitterPlugin< 25 - Partial<FullPageLayout> & { sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number } 26 - > = (userOpts) => { 24 + interface FolderPageOptions extends FullPageLayout { 25 + sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number 26 + } 27 + 28 + export const FolderPage: QuartzEmitterPlugin<Partial<FolderPageOptions>> = (userOpts) => { 27 29 const opts: FullPageLayout = { 28 30 ...sharedPageComponents, 29 31 ...defaultListPageLayout,
+5 -3
quartz/plugins/emitters/tagPage.tsx
··· 18 18 import { i18n } from "../../i18n" 19 19 import DepGraph from "../../depgraph" 20 20 21 - export const TagPage: QuartzEmitterPlugin< 22 - Partial<FullPageLayout> & { sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number } 23 - > = (userOpts) => { 21 + interface TagPageOptions extends FullPageLayout { 22 + sort?: (f1: QuartzPluginData, f2: QuartzPluginData) => number 23 + } 24 + 25 + export const TagPage: QuartzEmitterPlugin<Partial<TagPageOptions>> = (userOpts) => { 24 26 const opts: FullPageLayout = { 25 27 ...sharedPageComponents, 26 28 ...defaultListPageLayout,