Skip to content

Commit 8a89aa8

Browse files
committed
Update dependencies and code to fix issue #15
1 parent c6039a2 commit 8a89aa8

12 files changed

Lines changed: 118 additions & 87 deletions

File tree

‎.eslintignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ tsconfig.tsbuildinfo
3131
vite.config.ts
3232
*.spec.tsx
3333
*.spec.ts
34+
.netlify
35+
pnpm-lock.yaml
36+
package-lock.json
37+
yarn.lock
38+
server

‎.eslintrc.cjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ module.exports = {
3636
"no-case-declarations": "off",
3737
"no-console": "off",
3838
"@typescript-eslint/no-unused-vars": ["error"],
39+
"@typescript-eslint/consistent-type-imports": "warn",
40+
"@typescript-eslint/no-unnecessary-condition": "warn",
3941
},
4042
};

‎.prettierignore‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1-
# Files Prettier should not format
21
**/*.log
32
**/.DS_Store
43
*.
4+
.vscode/settings.json
5+
.history
6+
.yarn
7+
bazel-*
8+
bazel-bin
9+
bazel-out
10+
bazel-qwik
11+
bazel-testlogs
512
dist
13+
dist-dev
14+
lib
15+
lib-types
16+
etc
17+
external
618
node_modules
19+
temp
20+
tsc-out
21+
tsdoc-metadata.json
22+
target
23+
output
24+
rollup.config.js
25+
build
26+
.cache
27+
.vscode
28+
.rollup.cache
29+
dist
30+
tsconfig.tsbuildinfo
31+
vite.config.ts
32+
*.spec.tsx
33+
*.spec.ts
34+
.netlify
35+
pnpm-lock.yaml
36+
package-lock.json
37+
yarn.lock
38+
server

‎adapters/static/vite.config.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { staticAdapter } from '@builder.io/qwik-city/adapters/static/vite';
2-
import { extendConfig } from '@builder.io/qwik-city/vite';
3-
import baseConfig from '../../vite.config';
1+
import { staticAdapter } from "@builder.io/qwik-city/adapters/static/vite";
2+
import { extendConfig } from "@builder.io/qwik-city/vite";
3+
import baseConfig from "../../vite.config";
44

55
import { SITE } from "../../src/config.mjs";
66

@@ -9,7 +9,7 @@ export default extendConfig(baseConfig, () => {
99
build: {
1010
ssr: true,
1111
rollupOptions: {
12-
input: ['@qwik-city-plan'],
12+
input: ["@qwik-city-plan"],
1313
},
1414
},
1515
plugins: [

‎package.json‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build.preview": "vite build --ssr src/entry.preview.tsx",
1010
"build.server": "vite build -c adapters/static/vite.config.ts",
1111
"build.types": "tsc --incremental --noEmit",
12-
"deploy": "echo 'Run \"npm run qwik add\" to install a server adaptor'",
12+
"deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
1313
"dev": "vite --mode ssr",
1414
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
1515
"fmt": "prettier --write .",
@@ -20,10 +20,10 @@
2020
"qwik": "qwik"
2121
},
2222
"dependencies": {
23-
"@builder.io/qwik": "1.2.3",
24-
"@builder.io/qwik-city": "1.2.3",
25-
"@fontsource-variable/inter": "^5.0.3",
26-
"@unpic/qwik": "^0.0.20",
23+
"@builder.io/qwik": "1.2.6",
24+
"@builder.io/qwik-city": "1.2.6",
25+
"@fontsource-variable/inter": "^5.0.4",
26+
"@unpic/qwik": "^0.0.23",
2727
"gray-matter": "^4.0.3",
2828
"markdown-it": "^13.0.1",
2929
"node-fetch": "3.3.1"
@@ -34,16 +34,16 @@
3434
"@types/eslint": "8.40.2",
3535
"@types/markdown-it": "^12.2.3",
3636
"@types/node": "latest",
37-
"@typescript-eslint/eslint-plugin": "5.60.1",
38-
"@typescript-eslint/parser": "5.60.1",
37+
"@typescript-eslint/eslint-plugin": "5.61.0",
38+
"@typescript-eslint/parser": "5.61.0",
3939
"autoprefixer": "10.4.14",
4040
"eslint": "8.44.0",
41-
"eslint-plugin-qwik": "1.2.3",
42-
"postcss": "^8.4.24",
43-
"prettier": "2.8.8",
41+
"eslint-plugin-qwik": "1.2.6",
42+
"postcss": "^8.4.25",
43+
"prettier": "3.0.0",
4444
"tailwindcss": "^3.3.2",
4545
"typescript": "5.1.6",
46-
"vite": "4.3.9",
46+
"vite": "4.4.1",
4747
"vite-tsconfig-paths": "4.2.0"
4848
},
4949
"engines": {

‎src/entry.dev.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* - More code is transferred to the browser than in SSR mode.
1010
* - Optimizer/Serialization/Deserialization code is not exercised!
1111
*/
12-
import { render, RenderOptions } from "@builder.io/qwik";
12+
import { render, type RenderOptions } from "@builder.io/qwik";
1313
import Root from "./root";
1414

1515
export default function (opts: RenderOptions) {

‎src/entry.preview.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
*
1212
*/
1313
import { createQwikCity } from "@builder.io/qwik-city/middleware/node";
14-
import render from "./entry.ssr";
1514
import qwikCityPlan from "@qwik-city-plan";
15+
import render from "./entry.ssr";
1616

1717
/**
18-
* The default export is the QwikCity adaptor used by Vite preview.
18+
* The default export is the QwikCity adapter used by Vite preview.
1919
*/
2020
export default createQwikCity({ render, qwikCityPlan });

‎src/entry.ssr.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* WHAT IS THIS FILE?
33
*
4-
* SSR entry point, in all cases the application is render outside the browser, this
4+
* SSR entry point, in all cases the application is rendered outside the browser, this
55
* entry point will be the common one.
66
*
77
* - Server (express, cloudflare...)
@@ -10,7 +10,10 @@
1010
* - npm run build
1111
*
1212
*/
13-
import { renderToStream, RenderToStreamOptions } from "@builder.io/qwik/server";
13+
import {
14+
renderToStream,
15+
type RenderToStreamOptions,
16+
} from "@builder.io/qwik/server";
1417
import { manifest } from "@qwik-client-manifest";
1518
import Root from "./root";
1619

@@ -26,4 +29,4 @@ export default function (opts: RenderToStreamOptions) {
2629
...opts.containerAttributes,
2730
},
2831
});
29-
}
32+
}

‎src/root.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export default component$(() => {
3333
/> */}
3434
<RouterHead />
3535
<DarkThemeLauncher />
36+
<ServiceWorkerRegister />
3637
</head>
3738
<body class="text-gray-900 dark:text-slate-300 tracking-tight bg-white dark:bg-gray-900 antialiased">
3839
<RouterOutlet />
39-
<ServiceWorkerRegister />
4040
</body>
4141
</QwikCityProvider>
4242
);

‎src/routes/blog/[slug]/index.tsx‎

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { component$, Resource } from "@builder.io/qwik";
1+
import { component$ } from "@builder.io/qwik";
22
import { routeLoader$ } from "@builder.io/qwik-city";
33

44
import type { DocumentHead, StaticGenerateHandler } from "@builder.io/qwik-city";
@@ -8,68 +8,63 @@ import md from "markdown-it";
88

99
import { fetchPosts, findPostBySlug } from "~/utils/posts";
1010

11-
export const useGetPostBySlug = routeLoader$(async ({ params, status }): Promise<Post> => {
11+
export const useGetPostBySlug = routeLoader$(async ({ params, status }) => {
1212
const post = await findPostBySlug(params.slug);
1313

1414
if (!post) {
15-
status(404);
15+
return status(404);
1616
}
1717

1818
return post as Post;
1919
});
2020

2121
export default component$(() => {
22-
const data = useGetPostBySlug();
22+
const signal = useGetPostBySlug();
23+
24+
const post = signal.value as Post;
2325

2426
return (
25-
<Resource
26-
value={data}
27-
onPending={() => <div>Loading...</div>}
28-
onRejected={() => <div>Error</div>}
29-
onResolved={(post: Post) => (
30-
<section class="mx-auto py-8 sm:py-16 lg:py-20">
31-
<article>
32-
<header class={post?.image ? "text-center" : ""}>
33-
<p class="mx-auto max-w-3xl px-4 sm:px-6">
34-
<time dateTime={String(post.publishDate.getTime())}>
35-
{post.publishDate.toLocaleDateString("en-us", {
36-
year: "numeric",
37-
month: "short",
38-
day: "numeric",
39-
timeZone: "UTC",
40-
})}
41-
</time>
42-
{/* ~{" "} {Math.ceil(post.readingTime)} min read */}
43-
</p>
44-
<h1 class="leading-tighter font-heading mx-auto mb-8 max-w-3xl px-4 text-4xl font-bold tracking-tighter sm:px-6 md:text-5xl">
45-
{post.title}
46-
</h1>
47-
{post.image ? (
48-
<img
49-
src={post.image}
50-
class="mx-auto mt-4 mb-6 max-w-full bg-gray-400 dark:bg-slate-700 sm:rounded-md lg:max-w-6xl"
51-
sizes="(max-width: 900px) 400px, 900px"
52-
alt={post.excerpt}
53-
loading="eager"
54-
width={900}
55-
height={480}
56-
/>
57-
) : (
58-
<div class="mx-auto max-w-3xl px-4 sm:px-6">
59-
<div class="border-t dark:border-slate-700" />
60-
</div>
61-
)}
62-
</header>
63-
<div
64-
class="prose-md prose-headings:font-heading prose-headings:leading-tighter container prose prose-lg mx-auto mt-8 max-w-3xl px-6 prose-headings:font-bold prose-headings:tracking-tighter prose-a:text-primary-600 prose-img:rounded-md prose-img:shadow-lg dark:prose-invert dark:prose-headings:text-slate-300 dark:prose-a:text-primary-400 sm:px-6 lg:prose-xl"
65-
dangerouslySetInnerHTML={md({
66-
html: true,
67-
}).render(post.content)}
27+
<section class="mx-auto py-8 sm:py-16 lg:py-20">
28+
<article>
29+
<header class={post?.image ? "text-center" : ""}>
30+
<p class="mx-auto max-w-3xl px-4 sm:px-6">
31+
<time dateTime={String(post.publishDate.getTime())}>
32+
{post.publishDate.toLocaleDateString("en-us", {
33+
year: "numeric",
34+
month: "short",
35+
day: "numeric",
36+
timeZone: "UTC",
37+
})}
38+
</time>
39+
{/* ~{" "} {Math.ceil(post.readingTime)} min read */}
40+
</p>
41+
<h1 class="leading-tighter font-heading mx-auto mb-8 max-w-3xl px-4 text-4xl font-bold tracking-tighter sm:px-6 md:text-5xl">
42+
{post.title}
43+
</h1>
44+
{post.image ? (
45+
<img
46+
src={post.image}
47+
class="mx-auto mt-4 mb-6 max-w-full bg-gray-400 dark:bg-slate-700 sm:rounded-md lg:max-w-6xl"
48+
sizes="(max-width: 900px) 400px, 900px"
49+
alt={post.excerpt}
50+
loading="eager"
51+
width={900}
52+
height={480}
6853
/>
69-
</article>
70-
</section>
71-
)}
72-
/>
54+
) : (
55+
<div class="mx-auto max-w-3xl px-4 sm:px-6">
56+
<div class="border-t dark:border-slate-700" />
57+
</div>
58+
)}
59+
</header>
60+
<div
61+
class="prose-md prose-headings:font-heading prose-headings:leading-tighter container prose prose-lg mx-auto mt-8 max-w-3xl px-6 prose-headings:font-bold prose-headings:tracking-tighter prose-a:text-primary-600 prose-img:rounded-md prose-img:shadow-lg dark:prose-invert dark:prose-headings:text-slate-300 dark:prose-a:text-primary-400 sm:px-6 lg:prose-xl"
62+
dangerouslySetInnerHTML={md({
63+
html: true,
64+
}).render(post.content)}
65+
/>
66+
</article>
67+
</section>
7368
);
7469
});
7570

@@ -82,7 +77,7 @@ export const onStaticGenerate: StaticGenerateHandler = async () => {
8277
};
8378

8479
export const head: DocumentHead = ({ resolveValue }) => {
85-
const post = resolveValue(useGetPostBySlug);
80+
const post = resolveValue(useGetPostBySlug) as Post;
8681

8782
return {
8883
title: `${post.title} — Qwind`,

0 commit comments

Comments
 (0)