getfilepress 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { PageData } from './$types';
|
|
3
|
-
import { PostCard } from '@filepress/core';
|
|
3
|
+
import { PostCard, tagDisplayLabel } from '@filepress/core';
|
|
4
4
|
import config from '$site-config';
|
|
5
5
|
|
|
6
6
|
let { data }: { data: PageData } = $props();
|
|
7
|
+
const heading = $derived(tagDisplayLabel(config.topics, data.tag));
|
|
7
8
|
</script>
|
|
8
9
|
|
|
9
10
|
<svelte:head>
|
|
10
|
-
<title>{
|
|
11
|
-
<meta name="description" content="Posts tagged {
|
|
11
|
+
<title>{heading} — {config.title}</title>
|
|
12
|
+
<meta name="description" content="Posts tagged {heading} on {config.title}." />
|
|
12
13
|
</svelte:head>
|
|
13
14
|
|
|
14
15
|
<header class="post-header">
|
|
15
|
-
<
|
|
16
|
-
<h1>{data.tag}</h1>
|
|
16
|
+
<h1>{heading}</h1>
|
|
17
17
|
</header>
|
|
18
18
|
|
|
19
19
|
<ul class="post-list">
|
|
@@ -34,3 +34,17 @@ export function readingMinutes(body: string, wordsPerMinute = 228): number {
|
|
|
34
34
|
export function formatReadingTime(minutes: number): string {
|
|
35
35
|
return minutes === 1 ? '1 min read' : `${minutes} min read`;
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
/** Display name for a tag: curated topic label, else title-cased slug. */
|
|
39
|
+
export function tagDisplayLabel(
|
|
40
|
+
topics: Array<{ label: string; tag: string }>,
|
|
41
|
+
tag: string
|
|
42
|
+
): string {
|
|
43
|
+
const curated = topics.find((topic) => topic.tag === tag)?.label.trim();
|
|
44
|
+
if (curated) return curated;
|
|
45
|
+
return tag
|
|
46
|
+
.split('-')
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
49
|
+
.join(' ');
|
|
50
|
+
}
|
|
@@ -32,6 +32,6 @@ export type {
|
|
|
32
32
|
|
|
33
33
|
export { isPathMountHref } from './paths-shared';
|
|
34
34
|
|
|
35
|
-
export { formatDate, formatReadingTime, readingMinutes } from './format';
|
|
35
|
+
export { formatDate, formatReadingTime, readingMinutes, tagDisplayLabel } from './format';
|
|
36
36
|
|
|
37
37
|
export type { PostMeta, PostSource, RenderedPost, RawFrontmatter } from './content/types';
|