perf: give offering to lighthouse gods
fix lighthouse suggestions to get all greens fix fragments wrappers not dissolving
This commit is contained in:
commit
287f2e3c17
3 changed files with 37 additions and 13 deletions
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow:
|
|
@ -10,6 +10,7 @@ import {
|
|||
renderSync,
|
||||
walkSync,
|
||||
} from "ultrahtml";
|
||||
import { querySelectorAll } from "ultrahtml/selector";
|
||||
import { parseScript } from "esprima";
|
||||
import config from "../mcfly.config";
|
||||
|
||||
|
@ -74,7 +75,6 @@ async function insertRegistry(
|
|||
|
||||
// insert registry script to head
|
||||
if (usedCustomElements.length > 0) {
|
||||
console.log(">>> usedCustomElements", usedCustomElements);
|
||||
const registryScript = await buildRegistry(usedCustomElements, type);
|
||||
walkSync(ast, (node) => {
|
||||
if (node.type === ELEMENT_NODE && node.name === "head") {
|
||||
|
@ -217,28 +217,30 @@ function removeComments(script: string) {
|
|||
async function useFragments(html: string) {
|
||||
const fragmentFiles = await getFiles("html");
|
||||
|
||||
const availableFragments = fragmentFiles.map((key) => {
|
||||
const availableFragments = fragmentFiles.reduce((acc, key) => {
|
||||
return {
|
||||
key: key.replace(".html", ""),
|
||||
text: "",
|
||||
...acc,
|
||||
[key.replace(".html", "")]: "",
|
||||
};
|
||||
});
|
||||
}, {});
|
||||
const ast = parse(html);
|
||||
|
||||
for (const fragment of availableFragments) {
|
||||
fragment.text = await useStorage().getItem(
|
||||
"assets:components:" + fragment.key + ".html"
|
||||
// building fragment<name, text> map
|
||||
for (const key in availableFragments) {
|
||||
let text: string = await useStorage().getItem(
|
||||
"assets:components:" + key + ".html"
|
||||
);
|
||||
availableFragments[key] = text.replace(/\n/g, "").replace(/\s+/g, " ");
|
||||
}
|
||||
|
||||
walkSync(ast, (node) => {
|
||||
const usedFragment = availableFragments.find(
|
||||
(fragment) => fragment.key === node.name
|
||||
const selector = Object.keys(availableFragments).find(
|
||||
(name) => name === node.name
|
||||
);
|
||||
|
||||
if (node.type === ELEMENT_NODE && !!usedFragment) {
|
||||
const value = replaceSlots(usedFragment.text, node);
|
||||
node.children.push(parse(value));
|
||||
if (node.type === ELEMENT_NODE && !!selector) {
|
||||
const index = node.parent.children.indexOf(node);
|
||||
node.parent.children[index] = parse(availableFragments[selector]);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -3,5 +3,25 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>McFly: Back to the Basics. Into the Future.</title>
|
||||
<link rel="stylesheet" href="./reset.css" />
|
||||
<meta name="generator" content="McFly v0.0.0-super-experimental" />
|
||||
<meta name="theme-color" content="#3054bf" />
|
||||
<meta
|
||||
name="description"
|
||||
content="McFly is a full-stack no-framework framework that assists developers in leveraging the web platform."
|
||||
/>
|
||||
<meta name="author" content="Ayo Ayco" />
|
||||
<meta name="origin" content="https://mc-fly.vercel.app/" />
|
||||
<!-- Open Graph data -->
|
||||
<meta property="og:site_name" content="McFly" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://mc-fly.vercel.app" />
|
||||
<meta
|
||||
property="og:title"
|
||||
content="McFly: Back to the Basics. Into the Future. 😱"
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content="McFly is a full-stack no-framework framework that assists developers in leveraging the web platform."
|
||||
/>
|
||||
<slot />
|
||||
</head>
|
||||
|
|
Loading…
Reference in a new issue