@inglorious/ssx 2.3.2 → 2.4.0
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 +26 -7
- package/bin/ssx.js +4 -14
- package/package.json +15 -15
- package/src/build/build.test.js +13 -8
- package/src/build/index.js +3 -33
- package/src/build/manifest.js +0 -2
- package/src/build/manifest.test.js +1 -3
- package/src/build/metadata.js +0 -3
- package/src/build/pages.js +0 -1
- package/src/build/pages.test.js +1 -4
- package/src/build/public.js +0 -1
- package/src/build/public.test.js +0 -8
- package/src/build/sitemap.js +0 -1
- package/src/build/styles.js +110 -0
- package/src/build/styles.test.js +134 -0
- package/src/build/vite-config.js +4 -3
- package/src/client.js +0 -2
- package/src/dev/index.js +3 -7
- package/src/dev/vite-config.js +0 -1
- package/src/render/html.js +1 -6
- package/src/render/index.js +0 -1
- package/src/render/layout.js +26 -11
- package/src/render/layout.test.js +19 -1
- package/src/router/index.js +5 -18
- package/src/router/router.test.js +0 -16
- package/src/scripts/app.js +0 -1
- package/src/scripts/app.test.js +0 -1
- package/src/serve/index.js +4 -1
- package/src/serve/serve.test.js +77 -0
- package/src/ssr/index.js +0 -2
- package/src/ssr/render-request.test.js +0 -2
- package/src/store/store.test.js +0 -2
- package/src/utils/config.js +1 -1
- package/src/utils/config.test.js +0 -2
- package/src/utils/i18n.js +0 -3
- package/src/utils/i18n.test.js +0 -1
- package/src/utils/markdown.js +1 -6
- package/src/utils/page-head.js +0 -4
- package/src/utils/page-head.test.js +0 -1
- package/src/utils/page-options.test.js +1 -1
package/src/utils/config.js
CHANGED
package/src/utils/config.test.js
CHANGED
|
@@ -9,8 +9,6 @@ describe("loadConfig", () => {
|
|
|
9
9
|
let rootDir
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
|
-
// Inside the package: Vitest's module loader only imports files under
|
|
13
|
-
// the project root.
|
|
14
12
|
rootDir = mkdtempSync(path.join(import.meta.dirname, ".tmp-config-"))
|
|
15
13
|
mkdirSync(path.join(rootDir, "src"))
|
|
16
14
|
})
|
package/src/utils/i18n.js
CHANGED
|
@@ -10,7 +10,6 @@ export function getLocaleFromPath(
|
|
|
10
10
|
return defaultLocale
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
// Scripts written right to left, by their ISO 15924 code.
|
|
14
13
|
const RTL_SCRIPTS = new Set([
|
|
15
14
|
"Adlm",
|
|
16
15
|
"Arab",
|
|
@@ -39,12 +38,10 @@ export function getTextDirection(locale) {
|
|
|
39
38
|
const { script } = new Intl.Locale(locale).maximize()
|
|
40
39
|
return RTL_SCRIPTS.has(script) ? "rtl" : "ltr"
|
|
41
40
|
} catch {
|
|
42
|
-
// Not a valid language tag.
|
|
43
41
|
return "ltr"
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
// The entity of an app that translates with @inglorious/i18n, by that package's convention.
|
|
48
45
|
const TRANSLATOR_ID = "i18n"
|
|
49
46
|
|
|
50
47
|
/**
|
package/src/utils/i18n.test.js
CHANGED
package/src/utils/markdown.js
CHANGED
|
@@ -8,7 +8,6 @@ import texmath from "markdown-it-texmath"
|
|
|
8
8
|
|
|
9
9
|
export function renderMarkdown(markdown) {
|
|
10
10
|
const md = createMarkdownRenderer()
|
|
11
|
-
// gray-matter gives an error on the client, so we are going to use a simpler way to extract content
|
|
12
11
|
const content = markdown.replace(/^---[\s\S]*?---\n/, "")
|
|
13
12
|
return md.render(content)
|
|
14
13
|
}
|
|
@@ -23,7 +22,6 @@ export function markdownPlugin(options = {}) {
|
|
|
23
22
|
async transform(code, id) {
|
|
24
23
|
if (!id.endsWith(".md")) return
|
|
25
24
|
|
|
26
|
-
// prevents importing gray-matter on the client
|
|
27
25
|
const matter = (await import("gray-matter")).default
|
|
28
26
|
const { content, data } = matter(code)
|
|
29
27
|
const htmlContent = md.render(content)
|
|
@@ -73,11 +71,10 @@ function createMarkdownRenderer() {
|
|
|
73
71
|
console.error(err)
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
return ""
|
|
74
|
+
return ""
|
|
77
75
|
},
|
|
78
76
|
})
|
|
79
77
|
|
|
80
|
-
// Add LaTeX support
|
|
81
78
|
md.use(texmath, {
|
|
82
79
|
engine: katex,
|
|
83
80
|
delimiters: "dollars",
|
|
@@ -89,8 +86,6 @@ function createMarkdownRenderer() {
|
|
|
89
86
|
((tokens, idx, options, env, self) =>
|
|
90
87
|
self.renderToken(tokens, idx, options, env, self))
|
|
91
88
|
|
|
92
|
-
// Render mermaid fences as standalone blocks (not nested in <pre><code>),
|
|
93
|
-
// avoiding invalid HTML that can cause hydration mismatches.
|
|
94
89
|
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
|
|
95
90
|
const token = tokens[idx]
|
|
96
91
|
const lang = token.info?.trim().split(/\s+/)[0]
|
package/src/utils/page-head.js
CHANGED
|
@@ -73,7 +73,6 @@ function readPageHead(store, modules) {
|
|
|
73
73
|
meta: getPageOption("meta", DEFAULT_OPTIONS),
|
|
74
74
|
}
|
|
75
75
|
} catch {
|
|
76
|
-
// Metadata computed from entity data throws until that data arrives.
|
|
77
76
|
return null
|
|
78
77
|
}
|
|
79
78
|
}
|
|
@@ -91,8 +90,6 @@ function applyHead(head, previous) {
|
|
|
91
90
|
root.dir = head.dir
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
// Only tags named by this page or the previous one are touched, so those the
|
|
95
|
-
// layout writes on its own stay as they are.
|
|
96
93
|
const names = new Set([
|
|
97
94
|
...Object.keys(previous?.meta ?? {}),
|
|
98
95
|
...Object.keys(head.meta),
|
|
@@ -103,7 +100,6 @@ function applyHead(head, previous) {
|
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
function applyMeta(name, content) {
|
|
106
|
-
// The server writes Open Graph style names, such as og:image, as `property`.
|
|
107
103
|
const attribute = name.includes(":") ? "property" : "name"
|
|
108
104
|
let tag = [...document.head.querySelectorAll("meta")].find(
|
|
109
105
|
(meta) => meta.getAttribute(attribute) === name,
|
|
@@ -63,7 +63,6 @@ describe("syncPageHead", () => {
|
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// Navigates the way the router does: the history entry first, then the state change.
|
|
67
66
|
const navigate = (store, route, path) => {
|
|
68
67
|
window.history.pushState(null, "", path)
|
|
69
68
|
store.notify("#router:navigate", { route, path })
|
|
@@ -39,7 +39,7 @@ describe("createGetPageOption", () => {
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
it("should use defaults when metadata is missing", () => {
|
|
42
|
-
const module = {}
|
|
42
|
+
const module = {}
|
|
43
43
|
|
|
44
44
|
const getOption = createGetPageOption(mockStore, module, mockEntity)
|
|
45
45
|
const defaults = { title: "Default Title" }
|