Compare commits

...

2 commits

Author SHA1 Message Date
4a1e2a81e8 prettier js ts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-09-09 10:31:05 -03:00
426d355765 package: build-bun 2023-09-09 10:30:11 -03:00
6 changed files with 25 additions and 25 deletions

View file

@ -47,7 +47,7 @@ export default () => {
const tema = random(temas);
const adjetivo = random(adjetivos)[tipo[1]];
return li(tipo[0], " ", adjetivo, " sobre ", tema);
})
}),
),
h2("Tipos de obra"),
ol(...tipos.map((t) => li(t[0]))),
@ -59,7 +59,7 @@ export default () => {
{
href: "https://gitea.nulo.in/Nulo/sitio/src/branch/ANTIFASCISTA/Men%C3%BA%20art%C3%ADstico.gen.js",
},
"Código"
)
"Código",
),
);
};

View file

@ -28,12 +28,12 @@ export default async () => {
target: "_blank",
rel: "noopener",
},
item.title
item.title,
),
// TODO: format date
" via ",
a({ href: relativeLink(link), rel: "noopener" }, title)
)
a({ href: relativeLink(link), rel: "noopener" }, title),
),
);
}
@ -53,19 +53,19 @@ function parseFeed(feedUrl, rawFeed) {
const feedDom = getElementsByTagName(
(n) => n === "rss" || n === "feed" || n === "rdf:RDF",
dom.childNodes,
false
false,
)[0];
const linksDom = getElementsByTagName(
(t) => ["link", "atom:link"].includes(t),
feedDom.childNodes,
false
false,
);
const linkDom = linksDom.find(
(d) =>
d.attribs.rel === "alternate" ||
// https://datatracker.ietf.org/doc/html/rfc4287#section-4.2.7.2
// >If the "rel" attribute is not present, the link element MUST be interpreted as if the link relation type is "alternate".
!("rel" in d.attribs)
!("rel" in d.attribs),
);
const feedUrll = new URL(feedUrl);

View file

@ -79,7 +79,7 @@ await compilePageList(config, pageList);
async function compileFile(
config: Config,
sourceFileName: string
sourceFileName: string,
): Promise<{ contentHtml: string; image?: Image }> {
if (extname(sourceFileName) === ".md") {
const { html: contentHtml, image } = await compileMarkdownHtml(config, sourceFileName);
@ -106,8 +106,8 @@ async function compilePage(config: Config, sourceFileName: string) {
{ itemscope: "", itemtype: "https://schema.org/Article" },
...(isIndex ? [] : generateHeader(name, sourceFileName, fileConnections.length > 0, image)),
main({ itemprop: "articleBody", "data-pagefind-body": "" }, raw(contentHtml)),
...generateConnectionsSection(fileConnections)
)
...generateConnectionsSection(fileConnections),
),
);
const outputPath = join(config.buildPath, name + ".html");
@ -125,7 +125,7 @@ type Image = {
async function compileMarkdownHtml(
config: Config,
sourceFileName: string
sourceFileName: string,
): Promise<{ html: string; image?: Image }> {
let markdown = await readFile(join(config.sourcePath, sourceFileName), "utf-8");
@ -230,11 +230,11 @@ function parseName(name: string): TitleMetadata {
function dateishToElement(
dateish: Dateish,
{ itemprop, upper }: { itemprop?: string; upper?: boolean } = {}
{ itemprop, upper }: { itemprop?: string; upper?: boolean } = {},
): VirtualElement {
return time(
{ datetime: dateishToString(dateish), ...(itemprop ? { itemprop } : {}) },
formatDate(dateish, upper)
formatDate(dateish, upper),
);
}
@ -261,7 +261,7 @@ function generateHeader(
name: string,
sourceCodePath: string,
linkConexiones = false,
image?: Image
image?: Image,
): Renderable[] {
const parsedTitle = parseName(name);
return [
@ -285,16 +285,16 @@ function generateHeader(
dateishToElement(parsedTitle.date, {
itemprop: "datePublished",
upper: true,
})
}),
),
]),
a(
{
href: `https://gitea.nulo.in/Nulo/sitio/commits/branch/ANTIFASCISTA/${sourceCodePath}`,
},
"Historial"
"Historial",
),
...(linkConexiones ? [" / ", a({ href: "#conexiones" }, "Conexiones")] : [])
...(linkConexiones ? [" / ", a({ href: "#conexiones" }, "Conexiones")] : []),
),
];
}
@ -305,7 +305,7 @@ function generateConnectionsSection(fileConnections: Connection[]): Renderable[]
section(
{ id: "conexiones" },
h2(`⥆ Conexiones (${fileConnections.length})`),
ul(...fileConnections.map(({ linker }) => li(internalLink(linker))))
ul(...fileConnections.map(({ linker }) => li(internalLink(linker)))),
),
]
: [];
@ -321,8 +321,8 @@ async function compilePageList(config: Config, pageList: { src: string }[]) {
...pageList
.map(({ src: name }) => basename(name, extname(name)))
.sort((a, b) => a.localeCompare(b, "es", { sensitivity: "base" }))
.map((name) => li(internalLink(name)))
)
.map((name) => li(internalLink(name))),
),
);
await writeFile(outputPath, html);
}

View file

@ -17,7 +17,7 @@ if (process.argv[2] === "refresh") {
const res = await fetch(url);
const txt = await res.text();
await writeFile(join("cached-feeds/", `${name}.xml`), txt);
})
}),
);
}

View file

@ -6,6 +6,7 @@
"main": "index.js",
"scripts": {
"build": "esbuild compilar.ts *.js --target=node18 --outdir=build-js --sourcemap && node --enable-source-maps --trace-uncaught build-js/compilar.js && pagefind --source build",
"build-bun": "bun build compilar.ts --target bun > build-js/bun.js && bun build-js/bun.js && pagefind --source build",
"check": "tsc",
"refresh-feeds": "node feeds.js refresh"
},

View file

@ -13,8 +13,7 @@ buttonEl.addEventListener("click", (event) => {
} else {
interval = setInterval(() => {
guitaEl.dataset.guita =
parseFloat(guitaEl.dataset.guita) +
(porHoraEl.value / 60 / 60) * personasEl.value;
parseFloat(guitaEl.dataset.guita) + (porHoraEl.value / 60 / 60) * personasEl.value;
guitaEl.textContent = `$ ${parseFloat(guitaEl.dataset.guita).toFixed(2)}`;
}, 1000);
buttonEl.textContent = "Parar";