@hagicode/hagilight-core 0.9.5-dev.108.1.97fe2ae → 0.9.5-dev.109.1.aafdacc
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/dist/seo.js +13 -0
- package/package.json +1 -1
package/dist/seo.js
CHANGED
|
@@ -30,7 +30,14 @@ export function extractSeoDescription(body) {
|
|
|
30
30
|
return undefined;
|
|
31
31
|
const text = body
|
|
32
32
|
.replace(/^```[\s\S]*?^```/gmu, ' ')
|
|
33
|
+
// A table of contents is navigation, not a summary: drop the heading and its link list.
|
|
34
|
+
.replace(/^#{1,6}\s*(?:table of contents|contents|toc|目录|目錄)\s*$(?:\n\s*(?:[-*+]|\d+\.)\s.*$|\n\s*$)*/gimu, ' ')
|
|
33
35
|
.replace(/^import\s.+;?\s*$/gmu, ' ')
|
|
36
|
+
// Document furniture is not a summary: metadata lines (Last updated, Version, Status, ...),
|
|
37
|
+
// horizontal rules and table rows.
|
|
38
|
+
.replace(/^\s*(?:>\s*)*(?:[-*]\s+)?[_*]{0,2}(?:last updated|updated|version|status|date|audience|refs?|source of truth|owner|authors?)(?::[_*]{0,2}|[_*]{0,2}:)[^\n]*$/gimu, ' ')
|
|
39
|
+
.replace(/^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/gmu, ' ')
|
|
40
|
+
.replace(/^\s*\|.*\|\s*$/gmu, ' ')
|
|
34
41
|
.replace(/!\[([^\]]*)\]\([^)]*\)/gu, '$1')
|
|
35
42
|
.replace(/\[([^\]]+)\]\([^)]*\)/gu, '$1')
|
|
36
43
|
.replace(/<[^>]*>/gu, ' ')
|
|
@@ -123,6 +130,9 @@ export function resolveSeoImageUrl(value, { site, basePath = '/' } = {}) {
|
|
|
123
130
|
export function composeSeoHead(head, metadata, explicitHead = []) {
|
|
124
131
|
const explicit = explicitMetaKeys(explicitHead);
|
|
125
132
|
const values = [
|
|
133
|
+
// Starlight emits `<meta name="description">` from the site-wide description for pages without
|
|
134
|
+
// their own, while og/twitter carry the page excerpt. Keep all three in step.
|
|
135
|
+
['name:description', metadata.description],
|
|
126
136
|
['property:og:title', metadata.title],
|
|
127
137
|
['property:og:description', metadata.description],
|
|
128
138
|
['property:og:image', metadata.image],
|
|
@@ -136,6 +146,9 @@ export function composeSeoHead(head, metadata, explicitHead = []) {
|
|
|
136
146
|
const key = metaKey(entry);
|
|
137
147
|
if (!key || !generatedKeys.has(key))
|
|
138
148
|
return true;
|
|
149
|
+
// Never drop an existing description when there is nothing to replace it with.
|
|
150
|
+
if (key === 'name:description' && metadata.description === undefined)
|
|
151
|
+
return true;
|
|
139
152
|
if (explicit.has(key)) {
|
|
140
153
|
if (seen.has(key))
|
|
141
154
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagilight-core",
|
|
3
|
-
"version": "0.9.5-dev.
|
|
3
|
+
"version": "0.9.5-dev.109.1.aafdacc",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared TypeScript utilities, components, and assets for HagiCode Astro and Starlight sites",
|
|
6
6
|
"repository": {
|