Skip to content

Commit

Permalink
🏷️ kastro: Toward html support removal
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Sep 18, 2024
1 parent 8199f05 commit 8e91d5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
7 changes: 0 additions & 7 deletions kastro/compiler/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,6 @@ const compileComponent = (name, props, globals) => {
: import(process.cwd() + "/" + markup).then((mod) => mod.default(contextVars)))
.then((markupContent) => {
parser.end(markupContent);
if (css && !css.startsWith("/")) css = "/" + css;
if (css && !globals.SharedCss.has(css)
&& !globals.PageCss.has(css))
globals.PageCss.add(css);
if (latexVar)
globals.PageCss.add("/lib/kastro/sayfa/latex.css");

return Promise.all(htmlParts).then((parts) => parts.join(""));
})
);
Expand Down
33 changes: 17 additions & 16 deletions kastro/compiler/jsx-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { KapalıTag, tagYaz } from "../../util/html";
import { LangCode } from "../crate";
import { getGlobals } from "./pageGlobals";

/** @const {string} */
const Fragment = "";

/**
* @param {!Array<*>} children
* @param {LangCode} lang
Expand Down Expand Up @@ -30,25 +33,23 @@ const jsx = (name, props = {}) => {
props = resolveProps(props, globals.Lang);

const nameType = typeof name;
if (nameType != "function") {
const { children, ...prop } = props;
if (nameType == "object") { // `{@link name}` is a placeholder dom element
prop.id = name.id;
name = name.name;
}
return mergeChildren([].concat(children || []), globals.Lang)
.then((childStr) => name == Fragment
? childStr
: (childStr || !KapalıTag[name])
? tagYaz(name, prop, false) + childStr + `</${name}>`
: tagYaz(name, prop, true)
)
if (nameType == "fuction")
return name({ ...props, ...globals });

const { children, ...prop } = props;
if (nameType == "object") { // `{@link name}` is a placeholder dom element
prop.id = name.id;
name = name.name;
}
return name({ ...props, ...globals });
return mergeChildren([].concat(children || []), globals.Lang)
.then((childStr) => name == Fragment
? childStr
: (childStr || !KapalıTag[name])
? tagYaz(name, prop, false) + childStr + `</${name}>`
: tagYaz(name, prop, true)
)
}

const Fragment = "";

const jsxs = (name, props) => {
const globals = getGlobals();
props = resolveProps(props, globals.Lang);
Expand Down
2 changes: 2 additions & 0 deletions kastro/compiler/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const compilePage = async (componentName, pageGlobals) => {
initGlobals(pageGlobals);
return compileComponent(componentName, {}, pageGlobals)
.then((html) => {
pageGlobals.PageCss = pageGlobals.PageCss.difference(pageGlobals.SharedCss);
console.log(pageGlobals);
html = "<!DOCTYPE html>" +
html.replace("</head>", getStyleSheet(pageGlobals) + "</head>");

Expand Down

0 comments on commit 8e91d5a

Please sign in to comment.