Update page titles to not show "index"
This commit is contained in:
parent
c2108c4f83
commit
3d95f73093
8
.gitignore
vendored
8
.gitignore
vendored
@ -23,3 +23,11 @@ pnpm-debug.log*
|
||||
# Direnv junk
|
||||
.direnv/*
|
||||
*/.direnv/*
|
||||
|
||||
# Bot thing
|
||||
blog-bot.json
|
||||
|
||||
public/*
|
||||
quartz/public
|
||||
public
|
||||
.quartz-cache
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"syncToken": "s15_108_10_8_22_1_32_28_0_1_1",
|
||||
"syncToken": "s75_2959_24_27_45_1_44_40_0_1_1",
|
||||
"filter": null,
|
||||
"appserviceUsers": {},
|
||||
"appserviceTransactions": {},
|
||||
|
||||
1222
pnpm-lock.yaml
generated
1222
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,11 @@
|
||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||
import { classNames } from "../util/lang"
|
||||
import { deslugify } from "../util/path"
|
||||
|
||||
const ArticleTitle: QuartzComponent = ({ fileData, displayClass }: QuartzComponentProps) => {
|
||||
const title = fileData.frontmatter?.title
|
||||
if (title) {
|
||||
return <h1 class={classNames(displayClass, "article-title")}>{title}</h1>
|
||||
return <h1 class={classNames(displayClass, "article-title")}>{title == 'index' ? deslugify(fileData.slug!, 2) : title}</h1>
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { FullSlug, isFolderPath, resolveRelative } from "../util/path"
|
||||
import { deslugify, FullSlug, isFolderPath, resolveRelative } from "../util/path"
|
||||
import { QuartzPluginData } from "../plugins/vfile"
|
||||
import { Date, getDate } from "./Date"
|
||||
import { QuartzComponent, QuartzComponentProps } from "./types"
|
||||
@ -79,7 +79,7 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
|
||||
<div class="desc">
|
||||
<h3>
|
||||
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
|
||||
{title}
|
||||
{title == "index" ? deslugify(page.slug!) : title}
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@ -4,7 +4,7 @@ import { classNames } from "../util/lang"
|
||||
import { i18n } from "../i18n"
|
||||
|
||||
const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {
|
||||
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
||||
const title = cfg?.pageTitle ?? fileData.slug
|
||||
const baseDir = pathToRoot(fileData.slug!)
|
||||
return (
|
||||
<h2 class={classNames(displayClass, "page-title")}>
|
||||
|
||||
@ -54,7 +54,7 @@ export function getFullSlug(window: Window): FullSlug {
|
||||
return res
|
||||
}
|
||||
|
||||
function sluggify(s: string): string {
|
||||
function sluggify(s: FullSlug): string {
|
||||
return s
|
||||
.split("/")
|
||||
.map((segment) =>
|
||||
@ -69,6 +69,17 @@ function sluggify(s: string): string {
|
||||
.replace(/\/$/, "")
|
||||
}
|
||||
|
||||
export function deslugify(slug: string, dirs?: number): string {
|
||||
const sliceStart = dirs === undefined ? -2 : -1 - dirs
|
||||
|
||||
return slug
|
||||
.split("/")
|
||||
.slice(sliceStart,-1)
|
||||
.join(": ")
|
||||
.replace(/-and-/g, "&")
|
||||
.replace(/-/g, " ")
|
||||
}
|
||||
|
||||
export function slugifyFilePath(fp: FilePath, excludeExt?: boolean): FullSlug {
|
||||
fp = stripSlashes(fp) as FilePath
|
||||
let ext = getFileExtension(fp)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user