reallysimpledocs 1.0.5 → 1.0.6

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 CHANGED
@@ -28,6 +28,9 @@ export default defineConfig({
28
28
  site: {
29
29
  title: "Acme Docs",
30
30
  description: "Documentation for Acme.",
31
+ url: "https://docs.example.com",
32
+ favicon: "favicon.svg",
33
+ socialImage: "social.png",
31
34
  },
32
35
  }),
33
36
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reallysimpledocs",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.js",
@@ -20,7 +20,7 @@
20
20
  "build": "rm -rf dist && astro build",
21
21
  "preview": "astro preview",
22
22
  "smoke:consumer": "node scripts/smoke-consumer.mjs",
23
- "check": "npm run build && npm pack --dry-run && npm run smoke:consumer"
23
+ "check": "npm run build && node scripts/assert-site-output.mjs && npm pack --dry-run && npm run smoke:consumer"
24
24
  },
25
25
  "dependencies": {
26
26
  "@astrojs/markdown-remark": "^7.2.0",
@@ -41,6 +41,7 @@
41
41
  "tailwindcss": ">=4.1.17 <5"
42
42
  },
43
43
  "devDependencies": {
44
+ "@astrojs/sitemap": "^3.6.0",
44
45
  "astro": "^6.4.6",
45
46
  "basecoat-css": "^1.0.0-beta.6",
46
47
  "htmx.org": "^2.0.10",
@@ -65,6 +65,7 @@ function addHeadingAnchor(node, slugger) {
65
65
  if (!id) return;
66
66
  node.properties.id = id;
67
67
  node.properties.tabIndex ??= -1;
68
+ if (hasElement(node, "a")) return;
68
69
  node.children = [
69
70
  {
70
71
  type: "element",
@@ -97,6 +98,11 @@ function nodeText(node) {
97
98
  return node.children.map(nodeText).join("");
98
99
  }
99
100
 
101
+ function hasElement(node, tagName) {
102
+ if (isElement(node, tagName)) return true;
103
+ return Array.isArray(node?.children) && node.children.some((child) => hasElement(child, tagName));
104
+ }
105
+
100
106
  function isElement(node, tagName) {
101
107
  return node?.type === "element" && node.tagName === tagName;
102
108
  }
@@ -9,7 +9,9 @@
9
9
 
10
10
  > h2,
11
11
  > h3,
12
- > h4 {
12
+ > h4,
13
+ > h5,
14
+ > h6 {
13
15
  @apply sm:text-lg my-6 scroll-m-18 font-semibold tracking-tight;
14
16
 
15
17
  > a.header-anchor {
@@ -11,9 +11,9 @@ const metaTitle = pagePath === "/" ? `${site.title} | ${metaDescription}` : `${t
11
11
  const siteUrl = Astro.site?.toString().replace(/\/$/, "") || site.url || "";
12
12
  const absoluteUrl = `${siteUrl}${pagePath}`;
13
13
  const assetsBase = config.assetsBase || "/assets";
14
- const favicon = site.assets?.favicon || site.favicon || "";
15
- const appleTouchIcon = site.assets?.appleTouchIcon || site.appleTouchIcon || "";
16
- const socialImage = site.assets?.socialImage || site.socialImage || "";
14
+ const favicon = site.favicon || "";
15
+ const appleTouchIcon = site.appleTouchIcon || "";
16
+ const socialImage = site.socialImage || "";
17
17
  const assetPath = (value) => {
18
18
  const path = String(value || "");
19
19
  if (!path || path.startsWith("http") || path.startsWith("/")) return path;
@@ -102,7 +102,8 @@ export async function renderDoc(config, page) {
102
102
  const headingText = plainText(tokens);
103
103
  const id = slugger.slug(headingText);
104
104
  if (depth > 1 && depth < 4) headings.push({ depth, id, text: headingText });
105
- return `<h${depth} id="${id}" tabindex="-1"><a class="header-anchor" href="#${id}">${text}</a></h${depth}>`;
105
+ const content = hasTokenType(tokens, "link") ? text : `<a class="header-anchor" href="#${id}">${text}</a>`;
106
+ return `<h${depth} id="${id}" tabindex="-1">${content}</h${depth}>`;
106
107
  };
107
108
 
108
109
  const tokens = marked.lexer(content);
@@ -432,6 +433,10 @@ function plainText(tokens) {
432
433
  .join("");
433
434
  }
434
435
 
436
+ function hasTokenType(tokens, type) {
437
+ return tokens.some((token) => token.type === type || (token.tokens && hasTokenType(token.tokens, type)));
438
+ }
439
+
435
440
  function tokensText(tokens) {
436
441
  return tokens
437
442
  .map((token) => {