xanix 1.0.11 → 1.0.12

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.
@@ -1,14 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createRequire } from "node:module";
4
- import { fileURLToPath } from "node:url";
5
- const __dirname = fileURLToPath(import.meta.url);
6
4
  const require = createRequire(import.meta.url);
7
5
  const VIRTUAL_ID = "virtual:xanix-document";
8
6
  const RESOLVED_ID = "\0virtual:xanix-document";
9
7
  export default function xanixDocument() {
10
8
  const root = process.cwd();
11
- const userDocument = path.resolve(root, "Document.tsx");
9
+ const userDocument = path.resolve(root, "document.tsx");
12
10
  const baseDocument = require.resolve("../../../../../dist/components/BaseDocument.js");
13
11
  return {
14
12
  name: "xanix-document",
@@ -6,7 +6,8 @@ const Head = ({ children }) => {
6
6
  const { title, meta, pageId, props, params, pageData } = useDocument();
7
7
  if (__XANIX_CLIENT__) {
8
8
  useEffect(() => {
9
- document.title = title || "";
9
+ if (title)
10
+ document.title = title;
10
11
  meta?.forEach(({ name, content }) => {
11
12
  let element = document.querySelector(`meta[name="${name}"]`);
12
13
  if (!element) {
@@ -29,7 +30,7 @@ const Head = ({ children }) => {
29
30
  return null;
30
31
  }
31
32
  if (__XANIX_SERVER__) {
32
- return (_jsxs("head", { children: [_jsx("title", { children: title }), meta?.map(({ name, content }) => (_jsx("meta", { name: name, content: content }, name))), children, _jsx("script", { id: pageId, dangerouslySetInnerHTML: {
33
+ return (_jsxs("head", { children: [title && _jsx("title", { children: title }), meta?.map(({ name, content }) => (_jsx("meta", { name: name, content: content }, name))), children, _jsx("script", { id: pageId, dangerouslySetInnerHTML: {
33
34
  __html: `window.XANIX_DOCUMENT = ${JSON.stringify({
34
35
  pageId,
35
36
  props,
@@ -28,7 +28,7 @@ function createXanixServer({ mode }) {
28
28
  });
29
29
  app.use((req, res, next) => {
30
30
  let data = {
31
- title: null,
31
+ title: "",
32
32
  meta: [],
33
33
  };
34
34
  if (!req.page) {
@@ -51,7 +51,7 @@ export default async function xanixPage({ pageId, req, res, Component, props, })
51
51
  renderToString(_jsx(Document, { document: {
52
52
  pageId,
53
53
  props,
54
- title: title ?? entry.name.replaceAll("-", " "),
54
+ title,
55
55
  meta,
56
56
  params: req.params,
57
57
  request: req,
@@ -64,7 +64,7 @@ export default async function xanixPage({ pageId, req, res, Component, props, })
64
64
  return JSON.stringify({
65
65
  pageId,
66
66
  props,
67
- title: title ?? entry.name.replaceAll("-", " "),
67
+ title,
68
68
  meta,
69
69
  params: req.params,
70
70
  request: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xanix",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",