@dogsbay/site-files 0.2.0-beta.168 → 0.2.0-beta.170
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/blog-order.d.ts +29 -0
- package/dist/blog-order.js +46 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A blog's posts in llms.txt (and llms-full.txt): newest first, as the blog's index lists them,
|
|
3
|
+
* when the site has no nav file and no post sets its own order. The ONE rule, for the Astro build
|
|
4
|
+
* (format-astro) and dogsbay-ssg (plans/ssg-astro-parity.md there): an auto nav lists posts by
|
|
5
|
+
* title or file name, which is no blog's order. Browser/Worker-safe.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The nav with its posts reordered: each post takes the place of the one before it in `rank`
|
|
9
|
+
* order (lower first), so other entries keep their places, and each folder is ordered on its own.
|
|
10
|
+
* `rank` names a post's place in the post list (newest first) and is undefined for anything else.
|
|
11
|
+
* Each host matches its own nav entries to posts (format-astro by href, dogsbay-ssg by slug).
|
|
12
|
+
*/
|
|
13
|
+
export declare function postsNewestFirst<N extends {
|
|
14
|
+
children?: readonly N[];
|
|
15
|
+
}>(nav: readonly N[], rank: (entry: N) => number | undefined): N[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether an author ordered the pages in front matter, by a key an auto nav sorts by: then the nav's
|
|
18
|
+
* order is theirs and stands. `sidebar.order` (format-dogsbay-md's auto nav, the key docs/dogsbay-md.md
|
|
19
|
+
* documents) and `order` / `weight` (dogsbay-ssg's). Not `sidebar_position` (Docusaurus): no auto nav
|
|
20
|
+
* sorts by it, so counting it would keep a nav in file-name or title order, which is neither the
|
|
21
|
+
* author's order nor newest first.
|
|
22
|
+
*/
|
|
23
|
+
export declare function authorOrdered(frontmatters: Iterable<Record<string, unknown> | undefined>): boolean;
|
|
24
|
+
/** Whether llms.txt lists the posts newest first: a blog, with no nav file, whose posts set no order. */
|
|
25
|
+
export declare function postsInDateOrder(o: {
|
|
26
|
+
blog: boolean;
|
|
27
|
+
navFromFile: boolean;
|
|
28
|
+
frontmatters: Iterable<Record<string, unknown> | undefined>;
|
|
29
|
+
}): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A blog's posts in llms.txt (and llms-full.txt): newest first, as the blog's index lists them,
|
|
3
|
+
* when the site has no nav file and no post sets its own order. The ONE rule, for the Astro build
|
|
4
|
+
* (format-astro) and dogsbay-ssg (plans/ssg-astro-parity.md there): an auto nav lists posts by
|
|
5
|
+
* title or file name, which is no blog's order. Browser/Worker-safe.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The nav with its posts reordered: each post takes the place of the one before it in `rank`
|
|
9
|
+
* order (lower first), so other entries keep their places, and each folder is ordered on its own.
|
|
10
|
+
* `rank` names a post's place in the post list (newest first) and is undefined for anything else.
|
|
11
|
+
* Each host matches its own nav entries to posts (format-astro by href, dogsbay-ssg by slug).
|
|
12
|
+
*/
|
|
13
|
+
export function postsNewestFirst(nav, rank) {
|
|
14
|
+
const walk = (items) => {
|
|
15
|
+
const posts = items.filter((n) => rank(n) !== undefined).sort((a, b) => rank(a) - rank(b));
|
|
16
|
+
let i = 0;
|
|
17
|
+
return items.map((n) => {
|
|
18
|
+
const placed = rank(n) !== undefined ? posts[i++] : n;
|
|
19
|
+
return placed.children?.length ? { ...placed, children: walk(placed.children) } : placed;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return walk(nav);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether an author ordered the pages in front matter, by a key an auto nav sorts by: then the nav's
|
|
26
|
+
* order is theirs and stands. `sidebar.order` (format-dogsbay-md's auto nav, the key docs/dogsbay-md.md
|
|
27
|
+
* documents) and `order` / `weight` (dogsbay-ssg's). Not `sidebar_position` (Docusaurus): no auto nav
|
|
28
|
+
* sorts by it, so counting it would keep a nav in file-name or title order, which is neither the
|
|
29
|
+
* author's order nor newest first.
|
|
30
|
+
*/
|
|
31
|
+
export function authorOrdered(frontmatters) {
|
|
32
|
+
for (const fm of frontmatters) {
|
|
33
|
+
if (!fm)
|
|
34
|
+
continue;
|
|
35
|
+
const sidebar = fm.sidebar;
|
|
36
|
+
if (fm.order != null || fm.weight != null)
|
|
37
|
+
return true;
|
|
38
|
+
if (sidebar && typeof sidebar === "object" && sidebar.order != null)
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
/** Whether llms.txt lists the posts newest first: a blog, with no nav file, whose posts set no order. */
|
|
44
|
+
export function postsInDateOrder(o) {
|
|
45
|
+
return o.blog && !o.navFromFile && !authorOrdered(o.frontmatters);
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/site-files",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.170",
|
|
4
4
|
"description": "robots.txt, _headers, llms.txt, sitemaps, redirects and JSON-LD for docs sites; shared by the dogsbay Astro pipeline and dogsbay-ssg, Worker-safe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|