retypeset-odyssey 0.1.2 → 0.1.4
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/README.md +37 -8
- package/package.json +1 -1
- package/src/utils/description.ts +12 -3
package/README.md
CHANGED
|
@@ -17,12 +17,13 @@ Other deltas from upstream: trilingual content support (zh / en / ja) with `.en.
|
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
- Built with Astro
|
|
20
|
+
- Built with Astro 6 and UnoCSS
|
|
21
21
|
- SEO, Sitemap, OpenGraph (with generated cards), RSS, MDX, LaTeX, Mermaid, TOC
|
|
22
|
-
- i18n with route-level language switching
|
|
22
|
+
- i18n with route-level language switching and per-language tagline / collection-intro overrides
|
|
23
23
|
- Light / Dark mode with view transitions
|
|
24
24
|
- Pagefind full-text search
|
|
25
25
|
- Responsive, typography-first layout
|
|
26
|
+
- Folder-based content collections — drop a new folder under `content/` and you get list + detail routes for free
|
|
26
27
|
|
|
27
28
|
## Usage A — Standalone (fork & clone)
|
|
28
29
|
|
|
@@ -49,12 +50,14 @@ Set up your own minimal Astro project that consumes this theme. One install, one
|
|
|
49
50
|
"build": "astro build"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"astro": "^
|
|
53
|
-
"retypeset-odyssey": "
|
|
53
|
+
"astro": "^6.3.7",
|
|
54
|
+
"retypeset-odyssey": "^0.1.3"
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
(You can also pin to the GitHub tarball with `"retypeset-odyssey": "github:lifeodyssey/retypeset-odyssey"` if you want to track an unreleased branch.)
|
|
60
|
+
|
|
58
61
|
```ts
|
|
59
62
|
// astro.config.ts
|
|
60
63
|
import { defineConfig } from 'astro/config'
|
|
@@ -69,17 +72,39 @@ export default defineConfig({
|
|
|
69
72
|
# retypeset.config.yaml — at project root. Any subset of keys; the rest fall back to defaults.
|
|
70
73
|
site:
|
|
71
74
|
title: My Blog
|
|
72
|
-
subtitle
|
|
75
|
+
# `subtitle` accepts either a single string (used for all languages) or a
|
|
76
|
+
# per-language map. The map form is recommended for multilingual sites.
|
|
77
|
+
subtitle:
|
|
78
|
+
en: A journey through ideas
|
|
79
|
+
zh: 一段关于想法的旅程
|
|
80
|
+
ja: アイデアの旅
|
|
73
81
|
author: Your Name
|
|
74
82
|
url: https://your-domain.com
|
|
75
83
|
global:
|
|
76
84
|
locale: en
|
|
77
|
-
moreLocales: []
|
|
85
|
+
moreLocales: [] # for multilingual sites add e.g. [zh, ja]
|
|
78
86
|
footer:
|
|
79
87
|
links:
|
|
80
88
|
- name: RSS
|
|
81
89
|
url: /atom.xml
|
|
82
90
|
startYear: 2024
|
|
91
|
+
|
|
92
|
+
# Per-collection settings. The built-in `posts`, `notes`, `journals`
|
|
93
|
+
# collections are enabled by default. Set `enabled: false` to drop one.
|
|
94
|
+
# `intro` is an optional per-language tagline shown under the collection
|
|
95
|
+
# title on its list page (e.g. /notes, /journals); if you omit it the
|
|
96
|
+
# generic fallback from src/i18n/ui.ts is used instead.
|
|
97
|
+
collections:
|
|
98
|
+
notes:
|
|
99
|
+
intro:
|
|
100
|
+
en: My notes
|
|
101
|
+
zh: 我的笔记
|
|
102
|
+
ja: 私のノート
|
|
103
|
+
journals:
|
|
104
|
+
intro:
|
|
105
|
+
en: Personal diary entries
|
|
106
|
+
zh: 个人日记
|
|
107
|
+
ja: 個人的な日記
|
|
83
108
|
```
|
|
84
109
|
|
|
85
110
|
```ts
|
|
@@ -116,12 +141,16 @@ pnpm build # → dist/
|
|
|
116
141
|
|
|
117
142
|
### Configuration reference
|
|
118
143
|
|
|
119
|
-
The full schema lives in [`src/config-schema.ts`](./src/config-schema.ts) and the defaults in [`default-config.yaml`](./default-config.yaml). Top-level groups: `site`, `color`, `global`, `comment`, `seo`, `footer`, `preload`. Any field you do not set in your YAML falls back to the default. Validation errors surface at `astro build` time with a clear path into the YAML.
|
|
144
|
+
The full schema lives in [`src/config-schema.ts`](./src/config-schema.ts) and the defaults in [`default-config.yaml`](./default-config.yaml). Top-level groups: `site`, `color`, `global`, `comment`, `seo`, `footer`, `preload`, `collections`. Any field you do not set in your YAML falls back to the default. Validation errors surface at `astro build` time with a clear path into the YAML.
|
|
145
|
+
|
|
146
|
+
### Folder-based collections
|
|
147
|
+
|
|
148
|
+
Drop any folder under `content/` (e.g. `content/tech/`) and the integration will auto-discover it, generate `/tech` as the list page and `/tech/<slug>` as detail pages — no code change needed. Folders prefixed with `_` or `.` are ignored, so `content/_drafts/` is a natural place to stash in-progress work. Disable a folder by setting `collections.<name>.enabled: false`, and give it a per-language tagline with `collections.<name>.intro.{zh,en,ja}` just like the built-ins.
|
|
120
149
|
|
|
121
150
|
## Customization
|
|
122
151
|
|
|
123
152
|
- **Site config**: edit `default-config.yaml` (standalone) or write your own `retypeset.config.yaml` next to `astro.config.ts` (package consumers). Any subset of keys is allowed; the rest fall back to the defaults.
|
|
124
|
-
- **About pages**: place markdown in `
|
|
153
|
+
- **About pages**: place markdown in `content/about/about-{zh|en|ja}.md` (the `lang` field in the frontmatter picks which language each file belongs to).
|
|
125
154
|
- **Static assets** (favicon, OG logo, fonts): standalone users edit `public/`; package consumers inherit from the installed theme.
|
|
126
155
|
|
|
127
156
|
## Migrating from Hexo
|
package/package.json
CHANGED
package/src/utils/description.ts
CHANGED
|
@@ -34,10 +34,19 @@ const htmlEntityMap: Record<string, string> = {
|
|
|
34
34
|
' ': ' ',
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// Cleans text by removing HTML tags and normalizing whitespace
|
|
37
|
+
// Cleans text by removing HTML tags and normalizing whitespace.
|
|
38
|
+
// Before stripping tags, inserts a middle-dot separator between adjacent
|
|
39
|
+
// list items so excerpts of pre-`<!-- more -->` lists still read as a list
|
|
40
|
+
// once flattened to a single paragraph. Without this, `<li>A</li><li>B</li>`
|
|
41
|
+
// flattens to whitespace-joined `A B` and the excerpt loses its structure.
|
|
38
42
|
function cleanTextContent(text: string): string {
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
let cleanText = text
|
|
44
|
+
// Adjacent list items → middle-dot separator
|
|
45
|
+
.replace(/<\/li>\s*<li[^>]*>/gi, '</li> · <li>')
|
|
46
|
+
// <br /> behaves like a space
|
|
47
|
+
.replace(/<br\s*\/?>/gi, ' ')
|
|
48
|
+
// Remove HTML tags
|
|
49
|
+
.replace(/<[^>]*>/g, '')
|
|
41
50
|
|
|
42
51
|
// Decode HTML entities
|
|
43
52
|
Object.entries(htmlEntityMap).forEach(([entity, char]) => {
|