Skip to content

Commit dab8c58

Browse files
committed
docs
1 parent 27be9c0 commit dab8c58

File tree

5 files changed

+112
-23
lines changed

5 files changed

+112
-23
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ___
1818
- `qbt_with_qemu` - default: `yes` - if this is set to `no` abd cross compiling then the modules of `icu_host_deps` `qtbase_host_deps` `qttools_host_deps` are added to the installation to bootstrap required host versions.
1919
- `qbt_host_deps` - default: `no` - if this is set to `yes` the script will pull in prebuilt host dependencies from here - <https://github.com/userdocs/qbt-host-deps>
2020
- `iconv` is no longer installed when using libtorrent `v2` as it was only ever a dependency of libtorrent `v1.2`
21+
2122
> [!NOTE]
2223
> `qbt_host_deps` will always be mirrored to the latest release version.
2324

docs/package-lock.json

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"@astrojs/starlight": "^0.35.0",
13+
"@astrojs/starlight": "^0.35.1",
1414
"@expressive-code/plugin-collapsible-sections": "^0.41.1",
15-
"astro": "^5.11.2",
15+
"astro": "^5.12.4",
1616
"gray-matter": "^4.0.3",
1717
"sharp": "^0.32.5",
1818
"starlight-image-zoom": "^0.9.0"
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
export interface Props {
3+
content: string;
4+
}
5+
6+
const { content } = Astro.props;
7+
8+
function processCallouts(htmlContent: string): string {
9+
// Define callout types and mapping
10+
const CALLOUT_TYPES = "NOTE|TIP|WARNING|IMPORTANT|CAUTION";
11+
const CALLOUT_MAP: Record<string, string> = {
12+
NOTE: "note",
13+
TIP: "tip",
14+
WARNING: "caution",
15+
IMPORTANT: "note",
16+
CAUTION: "danger",
17+
};
18+
19+
// Helper function to generate Starlight aside HTML
20+
const createAside = (type: string, content: string): string => {
21+
const starlightType = CALLOUT_MAP[type.toUpperCase()] ?? "note";
22+
return `<div class="starlight-aside starlight-aside--${starlightType}"><p class="starlight-aside__title">${type}</p><div class="starlight-aside__content"><p>${content}</p></div></div>`;
23+
};
24+
25+
// Helper function to clean HTML content
26+
const cleanHtmlContent = (match: string): string =>
27+
match
28+
.replace(/<blockquote[^>]*>/gi, "")
29+
.replace(/<\/blockquote>/gi, "")
30+
.replace(
31+
new RegExp(`<p>\\s*\\[!(${CALLOUT_TYPES})\\]\\s*<\\/p>`, "gi"),
32+
"",
33+
)
34+
.replace(new RegExp(`\\[!(${CALLOUT_TYPES})\\]`, "gi"), "")
35+
.replace(/<p>(.*?)<\/p>/gs, "$1 ")
36+
.replace(/<(?!code|\/code)[^>]*>/g, "") // Preserve <code> tags
37+
.replace(/\s+/g, " ")
38+
.trim();
39+
40+
// Helper function to clean markdown content
41+
const cleanMarkdownContent = (content: string): string =>
42+
content
43+
.split("\n")
44+
.map((line: string) => line.replace(/^>\s*/, "").trim())
45+
.filter((line: string) => line.length > 0)
46+
.join(" ");
47+
48+
let processedContent = htmlContent;
49+
50+
// Process blockquote-based callouts
51+
processedContent = processedContent.replace(
52+
new RegExp(
53+
`<blockquote[^>]*>[\\s\\S]*?\\[!(${CALLOUT_TYPES})\\][\\s\\S]*?<\\/blockquote>`,
54+
"gi",
55+
),
56+
(match: string) => {
57+
const typeMatch = match.match(
58+
new RegExp(`\\[!(${CALLOUT_TYPES})\\]`, "i"),
59+
);
60+
const type = typeMatch?.[1] ?? "NOTE";
61+
const cleanContent = cleanHtmlContent(match);
62+
return createAside(type, cleanContent);
63+
},
64+
);
65+
66+
// Process markdown-style callouts
67+
processedContent = processedContent.replace(
68+
new RegExp(
69+
`>\\s*\\[!(${CALLOUT_TYPES})\\]\\s*\\n((?:>\\s*.*(?:\\n|$))*)`,
70+
"gim",
71+
),
72+
(match: string, type: string, content: string) => {
73+
const cleanContent = cleanMarkdownContent(content);
74+
return createAside(type, cleanContent);
75+
},
76+
);
77+
78+
return processedContent;
79+
}
80+
81+
const processedContent = processCallouts(content);
82+
---
83+
84+
<div set:html={processedContent} />

docs/src/pages/changelog.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
3+
import CalloutProcessor from "../components/CalloutProcessor.astro";
34
import * as myPost from "../../../changelog.md";
45
56
const headings = myPost.getHeadings().map((heading) => ({
67
depth: heading.depth,
78
slug: heading.slug,
89
text: heading.text,
910
}));
11+
12+
const content = await myPost.compiledContent();
1013
---
1114

1215
<StarlightPage frontmatter={{ title: "Script Change Log" }} headings={headings}>
13-
<article set:html={myPost.compiledContent()} />
16+
<CalloutProcessor content={content} />
1417
</StarlightPage>

0 commit comments

Comments
 (0)