@ox-content/vite-plugin 3.0.0-alpha.14 → 3.0.0-alpha.15
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/index.cjs +31 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +20 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -7
- package/dist/index.mjs.map +1 -1
- package/dist/styles/twitter-full.css +71 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -8669,18 +8669,39 @@ async function renderSingleSatoriPage(entry, templateFn, options, cacheDir, root
|
|
|
8669
8669
|
/**
|
|
8670
8670
|
* Serve and copy KaTeX CSS/fonts only when the optional `katex` package exists.
|
|
8671
8671
|
*/
|
|
8672
|
+
/** Font formats KaTeX ships, newest first. */
|
|
8673
|
+
const FONT_FORMATS = {
|
|
8674
|
+
woff2: [".woff2"],
|
|
8675
|
+
all: [
|
|
8676
|
+
".woff2",
|
|
8677
|
+
".woff",
|
|
8678
|
+
".ttf"
|
|
8679
|
+
]
|
|
8680
|
+
};
|
|
8672
8681
|
/**
|
|
8673
|
-
* Copies `katex.min.css` and
|
|
8682
|
+
* Copies `katex.min.css` and the requested font formats into the SSG output.
|
|
8674
8683
|
* Returns an empty list when KaTeX is not installed.
|
|
8684
|
+
*
|
|
8685
|
+
* The `.ttf` and `.woff` sets are three quarters of the font bytes and no
|
|
8686
|
+
* browser that can run the rest of the site needs them: `@font-face` lists
|
|
8687
|
+
* `woff2` first and stops at the first format it supports. `formats: "all"`
|
|
8688
|
+
* brings them back.
|
|
8675
8689
|
*/
|
|
8676
|
-
async function copyKatexAssets(outDir) {
|
|
8690
|
+
async function copyKatexAssets(outDir, formats = "woff2") {
|
|
8677
8691
|
const dist = resolveKatexDist();
|
|
8678
8692
|
if (!dist) return [];
|
|
8679
8693
|
const dest = (0, node_path.join)(outDir, KATEX_ASSET_DIR);
|
|
8680
8694
|
await (0, node_fs_promises.mkdir)((0, node_path.join)(dest, "fonts"), { recursive: true });
|
|
8681
8695
|
const cssDest = (0, node_path.join)(dest, "katex.min.css");
|
|
8682
8696
|
await (0, node_fs_promises.copyFile)((0, node_path.join)(dist, "katex.min.css"), cssDest);
|
|
8683
|
-
|
|
8697
|
+
const wanted = FONT_FORMATS[formats] ?? FONT_FORMATS.woff2;
|
|
8698
|
+
await (0, node_fs_promises.cp)((0, node_path.join)(dist, "fonts"), (0, node_path.join)(dest, "fonts"), {
|
|
8699
|
+
recursive: true,
|
|
8700
|
+
filter: (source) => {
|
|
8701
|
+
const extension = (0, node_path.extname)(source);
|
|
8702
|
+
return extension === "" || wanted.includes(extension);
|
|
8703
|
+
}
|
|
8704
|
+
});
|
|
8684
8705
|
return [cssDest];
|
|
8685
8706
|
}
|
|
8686
8707
|
/** Dev-server middleware that serves `/__ox_katex__/*` from `katex/dist`. */
|
|
@@ -16983,7 +17004,7 @@ async function buildSsg(options, root) {
|
|
|
16983
17004
|
});
|
|
16984
17005
|
await applyDocumentationVersions(generatedPages, context, errors);
|
|
16985
17006
|
await writeGeneratedPages(generatedPages, context, generatedFiles, listedPages, outputPages, errors);
|
|
16986
|
-
if (options.math?.enabled) generatedFiles.push(...await copyKatexAssets(outDir));
|
|
17007
|
+
if (options.math?.enabled && generatedPages.some((page) => page.html.includes("__ox_katex__"))) generatedFiles.push(...await copyKatexAssets(outDir, options.math.fontFormats));
|
|
16987
17008
|
generatedFiles.push(...await require_vitepress.writeSelfHostedThemeFonts({
|
|
16988
17009
|
fonts: ssgOptions.theme?.fonts ?? {},
|
|
16989
17010
|
outDir,
|
|
@@ -18740,15 +18761,18 @@ function resolveEmojiShortcodeOptions(options) {
|
|
|
18740
18761
|
function resolveMathOptions(options) {
|
|
18741
18762
|
if (!options) return {
|
|
18742
18763
|
enabled: false,
|
|
18743
|
-
onError: "literal"
|
|
18764
|
+
onError: "literal",
|
|
18765
|
+
fontFormats: "woff2"
|
|
18744
18766
|
};
|
|
18745
18767
|
if (options === true) return {
|
|
18746
18768
|
enabled: true,
|
|
18747
|
-
onError: "literal"
|
|
18769
|
+
onError: "literal",
|
|
18770
|
+
fontFormats: "woff2"
|
|
18748
18771
|
};
|
|
18749
18772
|
return {
|
|
18750
18773
|
enabled: options.enabled ?? true,
|
|
18751
|
-
onError: options.onError ?? "literal"
|
|
18774
|
+
onError: options.onError ?? "literal",
|
|
18775
|
+
fontFormats: options.fontFormats ?? "woff2"
|
|
18752
18776
|
};
|
|
18753
18777
|
}
|
|
18754
18778
|
function resolveAttrsOptions(options) {
|