Files
zulip/starlight_help/src/components/ZulipTip.astro
Shubham Padia 3e60b16ac1 starlight_help: Move help-beta over to starlight_help.
We are starting the cutover process and starlight_help is the directory
we have agreed on to place our new help center project. We do not want
to use `starlight_help` as the URL for the project, but this commit
changes the url from `help-beta` to `starlight_help` temporarily since
we can only change URL once we get rid of the current help center
project. That will be done in a future commit.
2025-08-08 11:59:29 -07:00

63 lines
1.9 KiB
Plaintext

---
import assert from "node:assert/strict";
import type {Element} from "hast";
import {fromHtml} from "hast-util-from-html";
import {toHtml} from "hast-util-to-html";
import lightbulb_svg from "../../../web/shared/icons/lightbulb.svg?raw";
const lightbulb_icon_fragment = fromHtml(lightbulb_svg, {fragment: true});
const lightbulb_icon_first_child = lightbulb_icon_fragment.children[0]!;
assert.ok(
lightbulb_icon_first_child.type === "element" &&
lightbulb_icon_first_child.tagName === "svg",
);
lightbulb_icon_first_child.properties.class =
"zulip-unplugin-icon aside-icon-lightbulb";
let prefix_element_list = [
lightbulb_icon_first_child,
{
type: "element",
tagName: "strong",
properties: {},
children: [
{
type: "text",
// Whitespace before the text to ensure space between
// this text and the preceding icon.
value: " Tip: ",
},
],
} as Element,
];
const tree = fromHtml(await Astro.slots.render("default"), {fragment: true});
const first_element = tree.children[0];
assert.ok(first_element?.type === "element");
// This is currently happening only in one case, for _ImportSelfHostedServerTips.mdx
// where the tip contains an unordered list. Just placing the element as is without
// a paragraph does not look good in that case.
if (first_element.tagName !== "p") {
prefix_element_list = [
{
type: "element",
tagName: "p",
properties: {},
children: [...prefix_element_list],
} as Element,
];
}
first_element.children = [...prefix_element_list, ...first_element.children];
tree.children[0] = first_element;
---
<aside aria-label="Tip" class=`starlight-aside starlight-aside--tip`>
<div class="starlight-aside__content">
<Fragment set:html={toHtml(tree)} />
</div>
</aside>