quartz/quartz.layout.ts
2025-03-13 01:52:00 +08:00

95 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PageLayout, SharedLayout } from "./quartz/cfg"
import * as Component from "./quartz/components"
// components shared across all pages
export const sharedPageComponents: SharedLayout = {
head: Component.Head(),
header: [], 
afterBody: [Component.RecentNotes({ 
title: "最近更新",
showTags: false,
limit: 4,
filter: (f) => { 
if (f.filePath?.endsWith("index.md")) {
return false
}
return true
},
sort: (f1, f2) => {
if (f1.dates && f2.dates) {
if (Math.abs(f2.dates.modified.getDay() - f1.dates.modified.getDay())<=3) {
return f2.dates.created.getTime() - f1.dates.created.getTime() 
}
return f2.dates.modified.getTime() - f1.dates.modified.getTime() 
} else if (f1.dates && !f2.dates) {
return -1
}
return 1
}
})], 
footer: Component.Footer({
links: {
GitHub: "https://github.com/jackyzha0/quartz",
"Scroll to top ↑": "#",
},
}),
}
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = { 
beforeBody: [
Component.ArticleTitle(),  
Component.ContentMeta(),
Component.TagList(),
],
left: [
Component.PageTitle(), 
Component.MobileOnly(Component.Spacer()),
Component.Flex({
components: [
{
Component: Component.Search(), 
grow: true,
},
{ Component: Component.Darkmode() },
],
}),
],
right: [
Component.DesktopOnly(Component.TableOfContents()),
Component.Graph(),  
], 
afterBody: [   
Component.Backlinks(),  
Component.Comments({    
provider: 'giscus',
options: { 
// from data-repo  
repo: 'enneaa/giscus',  
// from data-repo-id 
repoId: 'R_kgDOOHb7aw',  
// from data-category  
category: 'Announcements',  
// from data-category-id   
categoryId: 'DIC_kwDOOHb7a84Cn6os',      
themeUrl: "https://enneaaa.netlify.app/static/giscus", 
lightTheme: "light-theme",
darkTheme: "dark-theme",  
inputPosition: "top",
}
}),
],
}
// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
beforeBody: [Component.ArticleTitle(), Component.ContentMeta()], 
left: [
Component.PageTitle(),
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.Darkmode(),
],
right: [],
}