Bot releases are hidden (Show)
Preview: https://aleph-yew.deno.dev/
Source Code: https://github.com/alephjs/aleph.js/tree/main/examples/yew-app
unocss
config in build
sectioneager
property for middleware (eager middleware allow you to handle the static file/code transpile requests)_app.vue
and _404.vue
#466applyUnoCSS
functionβ€οΈ Huge thanks to @linbingquan @pipiduck @kt3k
Preview: https://aleph-vue.deno.dev/
Source Code: https://github.com/alephjs/aleph.js/tree/main/examples/vue-app
β€οΈ Huge thanks to @linbingquan
Data
, and now you don't need to return Response
object in date getter/actions. return new Response(JSON.string({}), { headers: [["content-type": "application/json"]] })
is so painful, we like web standards, but sometimes it is so formalism.https://user-images.githubusercontent.com/2883484/167751094-77a61ca2-34e4-48a8-9931-bab19259732c.mov
serve({
...
onError: (error, cause) => {
if (cause.by === "ssr" && error instanceof ApiErrorn && error.code === "NotFound") {
return Response.redirect("/", 302);
}
},
});
Cache-Control
or Etag
header for requests automatically)CSSStyleSheet
to manage module CSS rules)build
modeπ 1.0.0-alpha.27: https://aleph-hello-zay950jqmpy0.deno.dev/ (25 JS files loaded in 65.6kb without polyfill)
π 1.0.0-alpha.28: https://aleph-hello.deno.dev/ (5 JS files loaded in 57.2kb with compat polyfill)
breaking change: renamed atomicCSS
to unocss
of server config
, we are looking for supporting aleph.js server config in unocss official vscode extension: https://github.com/unocss/unocss/pull/903
serve({
config: {
unocss: {
presets: [ ... ],
},
},
});
Hi, long time! We finally got some progress on the new architecture rewrite! Please have a look at the demo apps deployed to Deno Deploy with the new architecture (1.0.0-alpha.20):
You can find the source code here: https://github.com/alephjs/aleph.js/tree/main/examples
Currently, we are working on the new architecture docs https://github.com/alephjs/alephjs.org/pull/58, will publish a draft very soon, see you then!
import { useData } from "aleph/react";
import "../style/index.css";
let count = 0;
export const data = {
get: (req: Request) => {
return new Response(JSON.stringify({ count }));
},
post: async (req: Request) => {
const { action } = await req.json();
if (action === "increase") {
count++;
} else if (action === "decrease") {
count--;
}
return new Response(JSON.stringify({ count }));
},
};
export default function Index() {
const { data, isLoading, isMutating, mutation } = useData<{ count: number }>();
return (
<div className="counter">
<span>Counter:</span>
{isLoading && <em>...</em>}
{!isLoading && <strong>{data?.count}</strong>}
<button
disabled={Boolean(isMutating)}
onClick={() => mutation.post({ action: "decrease" }, "replace")}
>-</button>
<button
disabled={Boolean(isMutating)}
onClick={() => mutation.post({ action: "increase" }, "replace")}
>+</button>
</div>
);
}
// server.tsx
import { renderToString } from "react-dom/server";
import { Router } from "aleph/react";
import { serve } from "aleph/server";
serve({
config: {
routeFiles: "./routes/**/*.tsx",
atomicCSS: {
presets: [presetWindi()]
}
},
middlewares: [
new Session({ cookieName: "session" }),
new GithubAuth({ accessToken: "xxx" })
],
fetch: (req, ctx) => {
ctx.session.get("username");
},
ssr: (ctx) => {
return renderToString(<Router ssrContext={ctx} />);
},
});
index.html
as the client entry
jsx/ts/ts
for browsers on-demanddeno.json
after init command with types that works in Deno and the browser (fix #405)
{
"compilerOptions": {
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
"dom.asynciterable",
"deno.ns",
"deno.unstable"
]
}
}
fastTransform
in prod mode (fix https://github.com/alephjs/esm.sh/issues/181)build
subprocessuseDeno
and ssr.props
to access Request
(close #22, #364, #401)
export default function Page() {
const isLogined = useDeno(req => {
return req.headers.get('Auth') === 'XXX'
}, { revalidate: true })
return (
<p>isLogined: {isLogined}</p>
)
}
with ssr.props
options:
export const ssr: SSROptions = {
props: req => {
return {
$revalidate: true,
username: req.params.username,
logined: req.headers.get('Auth') === 'XXX'
}
}
}
export default <Config> {
plugins: [
markdown({
highlight: {
provider: 'highlight.js',
theme: 'github'
}
}),
]
}
css.cache
config to true
by defaultfile://path/mod.ts?foo=bar#tag
lang
attribute of the <html>
tag generated by SSG (#399) @calmeryHuge thanks to @calmery
json-loader
offical pluginjsFile
on windows (#389)renderListener
callback (#393) @TjeuKayimexistsFile
usage (#394) @getspookyfastTransform
function using esbuild to transpile remote non-jsx modules instead of swc--no-check
flag in install script@import
is not workingCache-Control
to public, max-age=0, must-revalidate
vercel.json
in init
commandupgrade
commanduseDeno
rendering unstablePlugin
systemssr
options for pages
import type { SSROptions, Router } = 'aleph/types.ts'
export const ssr: SSROptions = {
props: async (router: Router) => ({ ... }),
paths: async () => [ ... ], // static paths for dynamic route
}
export default function Index(ssrProps) {
return (
<div>ssr props: {ssrProps}</div>
)
}
import React from "https://esm.sh/react";
export default function App() {
return (
<>
<link rel="stylesheet" href="../style/app.module.css" />
<h1 className="$title $bold">Hi :)</h1>
<p className="$intro">Welcome!</p>
</>
);
}
useDeno
was updated)aleph.config.ts
(fix #323).css
files in ./public
folder (fix #304)minDenoVersion
to 1.10.1
Fallback
component for dynamic hockey
option for useDeno
withDeno
hoc Β· breaking
srcDir
configureduseDeno
(fix #301)Huge thanks to @noverby @kamchy @hyakt