mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-15 18:25:37 +02:00
✨ feat: Add support for MDX (#104)
This is an attempt to create our docs and blogs website
This commit is contained in:
24
apps/docs/src/entry.cloudflare-pages.tsx
Normal file
24
apps/docs/src/entry.cloudflare-pages.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* WHAT IS THIS FILE?
|
||||
*
|
||||
* It's the entry point for Cloudflare Pages when building for production.
|
||||
*
|
||||
* Learn more about the Cloudflare Pages integration here:
|
||||
* - https://qwik.dev/docs/deployments/cloudflare-pages/
|
||||
*
|
||||
*/
|
||||
import {
|
||||
createQwikCity,
|
||||
type PlatformCloudflarePages,
|
||||
} from "@builder.io/qwik-city/middleware/cloudflare-pages";
|
||||
import qwikCityPlan from "@qwik-city-plan";
|
||||
import { manifest } from "@qwik-client-manifest";
|
||||
import render from "./entry.ssr";
|
||||
|
||||
declare global {
|
||||
interface QwikCityPlatform extends PlatformCloudflarePages {}
|
||||
}
|
||||
|
||||
const fetch = createQwikCity({ render, qwikCityPlan, manifest });
|
||||
|
||||
export { fetch };
|
||||
17
apps/docs/src/entry.dev.tsx
Normal file
17
apps/docs/src/entry.dev.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* WHAT IS THIS FILE?
|
||||
*
|
||||
* Development entry point using only client-side modules:
|
||||
* - Do not use this mode in production!
|
||||
* - No SSR
|
||||
* - No portion of the application is pre-rendered on the server.
|
||||
* - All of the application is running eagerly in the browser.
|
||||
* - More code is transferred to the browser than in SSR mode.
|
||||
* - Optimizer/Serialization/Deserialization code is not exercised!
|
||||
*/
|
||||
import { render, type RenderOptions } from "@builder.io/qwik";
|
||||
import Root from "./root";
|
||||
|
||||
export default function (opts: RenderOptions) {
|
||||
return render(document, <Root />, opts);
|
||||
}
|
||||
21
apps/docs/src/entry.preview.tsx
Normal file
21
apps/docs/src/entry.preview.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* WHAT IS THIS FILE?
|
||||
*
|
||||
* It's the bundle entry point for `npm run preview`.
|
||||
* That is, serving your app built in production mode.
|
||||
*
|
||||
* Feel free to modify this file, but don't remove it!
|
||||
*
|
||||
* Learn more about Vite's preview command:
|
||||
* - https://vitejs.dev/config/preview-options.html#preview-options
|
||||
*
|
||||
*/
|
||||
import { createQwikCity } from "@builder.io/qwik-city/middleware/node";
|
||||
import qwikCityPlan from "@qwik-city-plan";
|
||||
// make sure qwikCityPlan is imported before entry
|
||||
import render from "./entry.ssr";
|
||||
|
||||
/**
|
||||
* The default export is the QwikCity adapter used by Vite preview.
|
||||
*/
|
||||
export default createQwikCity({ render, qwikCityPlan });
|
||||
33
apps/docs/src/entry.ssr.tsx
Normal file
33
apps/docs/src/entry.ssr.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* WHAT IS THIS FILE?
|
||||
*
|
||||
* SSR entry point, in all cases the application is rendered outside the browser, this
|
||||
* entry point will be the common one.
|
||||
*
|
||||
* - Server (express, cloudflare...)
|
||||
* - npm run start
|
||||
* - npm run preview
|
||||
* - npm run build
|
||||
*
|
||||
*/
|
||||
import {
|
||||
renderToStream,
|
||||
type RenderToStreamOptions,
|
||||
} from "@builder.io/qwik/server";
|
||||
import { manifest } from "@qwik-client-manifest";
|
||||
import Root from "./root";
|
||||
|
||||
export default function (opts: RenderToStreamOptions) {
|
||||
return renderToStream(<Root />, {
|
||||
manifest,
|
||||
...opts,
|
||||
// Use container attributes to set attributes on the html tag.
|
||||
containerAttributes: {
|
||||
lang: "en-us",
|
||||
...opts.containerAttributes,
|
||||
},
|
||||
serverData: {
|
||||
...opts.serverData,
|
||||
},
|
||||
});
|
||||
}
|
||||
0
apps/docs/src/global.css
Normal file
0
apps/docs/src/global.css
Normal file
45
apps/docs/src/root.tsx
Normal file
45
apps/docs/src/root.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { component$ } from "@builder.io/qwik";
|
||||
import {
|
||||
QwikCityProvider,
|
||||
RouterOutlet,
|
||||
ServiceWorkerRegister,
|
||||
} from "@builder.io/qwik-city";
|
||||
import { RouterHead } from "@nestri/ui";
|
||||
import { isDev } from "@builder.io/qwik/build";
|
||||
|
||||
import "@nestri/ui/globals.css";
|
||||
import { Fonts } from "@nestri/ui";
|
||||
|
||||
export default component$(() => {
|
||||
/**
|
||||
* The root of a QwikCity site always start with the <QwikCityProvider> component,
|
||||
* immediately followed by the document's <head> and <body>.
|
||||
*
|
||||
* Don't remove the `<head>` and `<body>` elements.
|
||||
*/
|
||||
|
||||
return (
|
||||
<Fonts>
|
||||
<QwikCityProvider>
|
||||
<head>
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fafafa" />
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0a0a0a" />
|
||||
<meta charset="utf-8" />
|
||||
{!isDev && (
|
||||
<link
|
||||
rel="manifest"
|
||||
href={`${import.meta.env.BASE_URL}manifest.json`}
|
||||
/>
|
||||
)}
|
||||
<RouterHead />
|
||||
</head>
|
||||
<body
|
||||
class="bg-gray-50 text-primary-950 dark:bg-gray-950 dark:text-primary-50 font-body flex min-h-[100dvh] flex-col overflow-x-hidden antialiased"
|
||||
lang="en">
|
||||
<RouterOutlet />
|
||||
{!isDev && <ServiceWorkerRegister />}
|
||||
</body>
|
||||
</QwikCityProvider>
|
||||
</Fonts>
|
||||
);
|
||||
});
|
||||
25
apps/docs/src/routes/index.tsx
Normal file
25
apps/docs/src/routes/index.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { component$ } from "@builder.io/qwik";
|
||||
import type { DocumentHead } from "@builder.io/qwik-city";
|
||||
|
||||
export default component$(() => {
|
||||
return (
|
||||
<>
|
||||
<h1>Hi 👋</h1>
|
||||
<div>
|
||||
Can't wait to see what you build with qwik!
|
||||
<br />
|
||||
Happy coding.
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
export const head: DocumentHead = {
|
||||
title: "Welcome to Qwik",
|
||||
meta: [
|
||||
{
|
||||
name: "description",
|
||||
content: "Qwik site description",
|
||||
},
|
||||
],
|
||||
};
|
||||
17
apps/docs/src/routes/layout.tsx
Normal file
17
apps/docs/src/routes/layout.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { component$, Slot } from "@builder.io/qwik";
|
||||
import type { RequestHandler } from "@builder.io/qwik-city";
|
||||
|
||||
export const onGet: RequestHandler = async ({ cacheControl }) => {
|
||||
// Control caching for this request for best performance and to reduce hosting costs:
|
||||
// https://qwik.dev/docs/caching/
|
||||
cacheControl({
|
||||
// Always serve a cached response by default, up to a week stale
|
||||
staleWhileRevalidate: 60 * 60 * 24 * 7,
|
||||
// Max once every 5 seconds, revalidate on the server to get a fresh version of this page
|
||||
maxAge: 5,
|
||||
});
|
||||
};
|
||||
|
||||
export default component$(() => {
|
||||
return <Slot />;
|
||||
});
|
||||
18
apps/docs/src/routes/service-worker.ts
Normal file
18
apps/docs/src/routes/service-worker.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* WHAT IS THIS FILE?
|
||||
*
|
||||
* The service-worker.ts file is used to have state of the art prefetching.
|
||||
* https://qwik.dev/qwikcity/prefetching/overview/
|
||||
*
|
||||
* Qwik uses a service worker to speed up your site and reduce latency, ie, not used in the traditional way of offline.
|
||||
* You can also use this file to add more functionality that runs in the service worker.
|
||||
*/
|
||||
import { setupServiceWorker } from "@builder.io/qwik-city/service-worker";
|
||||
|
||||
setupServiceWorker();
|
||||
|
||||
addEventListener("install", () => self.skipWaiting());
|
||||
|
||||
addEventListener("activate", () => self.clients.claim());
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope;
|
||||
7
apps/docs/src/routes/test/index.mdx
Normal file
7
apps/docs/src/routes/test/index.mdx
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Hello World Title
|
||||
---
|
||||
|
||||
# Hello World Title
|
||||
|
||||
This is a simple hello world component.
|
||||
Reference in New Issue
Block a user