Skip to content

Commit

Permalink
docs: update qwik-city (QwikDev#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley authored Aug 2, 2022
1 parent 0513687 commit 498d052
Showing 343 changed files with 1,926 additions and 1,387 deletions.
7 changes: 3 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -16,9 +16,8 @@ tsdoc-metadata.json
*.mp4
scripts/**/*
*.tsbuildinfo
packages/docs/src/pages/examples/**/*
packages/docs/src/pages/tutorial/**/*
packages/docs/src/routes/examples/**/*
packages/docs/src/routes/tutorial/**/*
packages/docs/src/repl/apps/examples/**/*
packages/docs/src/repl/apps/tutorial/**/*
packages/docs/src/repl/apps/examples/**/*
starters/apps/base
vite.config.ts
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -23,6 +23,6 @@ build
build
node_modules
tsconfig.tsbuildinfo
packages/docs/src/pages/**/*.mdx
packages/docs/src/routes/**/*.mdx
packages/docs/server/
starters/**/*.js
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
"preinstall": "yarn node scripts/tools/preinstall-script.js"
},
"devDependencies": {
"@builder.io/partytown": "0.6.2",
"@builder.io/partytown": "^0.6.4",
"@builder.io/qwik-dom": "2.1.18",
"@microsoft/api-extractor": "7.28.5",
"@napi-rs/cli": "2.6.2",
@@ -62,6 +62,7 @@
"@types/node": "latest",
"@types/node-fetch": "2.6.2",
"@types/path-browserify": "1.0.0",
"@types/prettier": "^2.6.3",
"@types/semver": "7.3.10",
"@typescript-eslint/eslint-plugin": "5.30.7",
"@typescript-eslint/parser": "5.30.7",
@@ -78,6 +79,7 @@
"execa": "6.1.0",
"express": "4.18.1",
"headers-polyfill": "^3.0.10",
"monaco-editor": "^0.33.0",
"mri": "1.2.0",
"node-fetch": "3.2.9",
"path-browserify": "1.0.1",
15 changes: 8 additions & 7 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -9,18 +9,18 @@
"build.client": "vite build",
"build.ssr": "vite build --ssr src/entry.cloudflare.tsx",
"build.qwikcity": "cd ../qwik-city && yarn build",
"dev": "vite --force",
"dev.ssr": "vite --mode ssr",
"dev": "node --inspect ../../node_modules/vite/bin/vite.js --force",
"dev.ssr": "node --inspect ../../node_modules/vite/bin/vite.js --mode ssr --force",
"dev.debug": "node --inspect-brk ../../node_modules/vite/bin/vite.js --mode ssr --force",
"serve": "wrangler pages dev ./dist",
"start": "yarn dev",
"fmt": "prettier --write .",
"fmt.check": "prettier --check ."
},
"devDependencies": {
"@builder.io/partytown": "^0.6.1",
"@builder.io/qwik": "0.0.33",
"@builder.io/qwik-city": "0.0.13",
"@builder.io/partytown": "^0.6.4",
"@builder.io/qwik": "0.0.39-dev20220801194759",
"@builder.io/qwik-city": "0.0.29",
"@cloudflare/kv-asset-handler": "0.2.0",
"autoprefixer": "10.4.7",
"fflate": "^0.7.3",
@@ -29,16 +29,17 @@
"prism-themes": "1.9.0",
"prismjs": "^1.28.0",
"tailwindcss": "3.1.6",
"typescript": "4.7.4",
"uvu": "0.5.6",
"vite": "2.9.14",
"vite": "3.0.2",
"wrangler": "beta"
},
"author": "Builder.io Team",
"bugs": {
"url": "https://github.com/BuilderIO/qwik"
},
"engines": {
"node": ">=14"
"node": ">=16"
},
"license": "MIT",
"private": true
5 changes: 5 additions & 0 deletions packages/docs/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/chat https://discord.gg/bNVSQmPzqy 302
/docs /docs/overview 301
/examples /examples/introduction/hello-world 301
/guide /docs/overview 301
/tutorial /tutorial/welcome/overview 301
28 changes: 0 additions & 28 deletions packages/docs/src/components/app/app.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions packages/docs/src/components/body/body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { component$, Host, useContextProvider, useStore } from '@builder.io/qwik';
import { Content } from '@builder.io/qwik-city';
import { GlobalStore, SiteStore } from '../../context';

export const Body = component$(
() => {
const store = useStore<SiteStore>({
headerMenuOpen: false,
sideMenuOpen: false,
});
useContextProvider(GlobalStore, store);

return (
<Host
class={{
'header-open': store.headerMenuOpen,
'menu-open': store.sideMenuOpen,
}}
>
<Content />
</Host>
);
},
{ tagName: 'body' }
);
99 changes: 45 additions & 54 deletions packages/docs/src/components/content-nav/content-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,73 +1,36 @@
import { usePage, usePageIndex, PageIndex } from '@builder.io/qwik-city';
import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
import { ContentMenu, useContent, useLocation } from '@builder.io/qwik-city';
import { component$, Host, useStyles$ } from '@builder.io/qwik';
import styles from './content-nav.css?inline';

export const ContentNav = component$(
() => {
useScopedStyles$(styles);
useStyles$(styles);

const page = usePage();
const pageIndex = usePageIndex()!;
const { menu } = useContent();
const { pathname } = useLocation();

let prevText: string | undefined;
let prevHref: string | undefined;
let nextText: string | undefined;
let nextHref: string | undefined;

if (page && pageIndex) {
const pageOrder: PageIndex[] = [];

const readIndex = (i: PageIndex) => {
pageOrder.push(i);
if (i.items) {
for (const item of i.items) {
readIndex(item);
}
}
};
readIndex(pageIndex);
if (!menu) {
return null;
}

const current = pageOrder.findIndex(
(p) => p.href === new URL(page.url, 'https://qwik.builder.io/').pathname
);
if (current > -1) {
let prev = pageOrder[current - 1];
if (prev && prev.href) {
prevText = prev.text;
prevHref = prev.href;
} else {
prev = pageOrder[current - 2];
if (prev && prev.href) {
prevText = prev.text;
prevHref = prev.href;
}
}
const items = flattenMenu(menu);

const next = pageOrder[current + 1];
if (next) {
nextText = next.text;
if (next.href) {
nextHref = next.href;
} else if (pageOrder[current + 2]?.href) {
nextHref = pageOrder[current + 2].href;
}
}
}
}
const prev = getNav(items, pathname, -1);
const next = getNav(items, pathname, 1);

return (
<Host class="content-nav border-t border-slate-300 flex flex-wrap py-4">
<div class="flex-1">
{prevText && prevHref ? (
<a class="px-3 py-1 prev" href={prevHref}>
{prevText}
{prev ? (
<a class="px-3 py-1 prev" href={prev.href}>
{prev.text}
</a>
) : null}
</div>
<div class="flex-1 text-right">
{nextText && nextHref ? (
<a class="px-3 py-1 next" href={nextHref}>
{nextText}
{next ? (
<a class="px-3 py-1 next" href={next.href}>
{next.text}
</a>
) : null}
</div>
@@ -76,3 +39,31 @@ export const ContentNav = component$(
},
{ tagName: 'nav' }
);

export const getNav = (items: ContentMenu[], currentPathname: string, direction: -1 | 1) => {
const currentIndex = items.findIndex((p) => p.href === currentPathname);
if (currentIndex > -1) {
let item = items[currentIndex + direction];
if (item && item.href) {
return item;
}
item = items[currentIndex + direction + direction];
if (item && item.href) {
return item;
}
}
};

export const flattenMenu = (menu: ContentMenu) => {
const items: ContentMenu[] = [];
const readMenu = (m: ContentMenu) => {
items.push(m);
if (m.items) {
for (const item of m.items) {
readMenu(item);
}
}
};
readMenu(menu);
return items;
};
4 changes: 2 additions & 2 deletions packages/docs/src/components/footer/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
import { component$, Host, useStyles$ } from '@builder.io/qwik';
import styles from './footer.css?inline';

export const Footer = component$(
() => {
useScopedStyles$(styles);
useStyles$(styles);

return (
<Host class="pt-8 pb-12 px-2 flex flex-wrap justify-center sm:justify-between text-sm">
101 changes: 38 additions & 63 deletions packages/docs/src/components/head/head.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,39 @@
import { partytownSnippet } from '@builder.io/partytown/integration';

export const Head = () => (
<>
<meta charSet="utf-8" />

<title>Qwik</title>
<meta name="viewport" content="width=device-width" />

<link rel="dns-prefetch" href="https://cdn.jsdelivr.net/" />
<link rel="dns-prefetch" href="https://cdn.builder.io/" />

<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png" />
<link rel="icon" href="/favicons/favicon.svg" type="image/svg+xml" />

<meta name="apple-mobile-web-app-title" content="Qwik" />
<meta name="application-name" content="Qwik" />
<meta name="apple-mobile-web-app-title" content="MyApp" />
<meta name="theme-color" content="#0093ee" />
<link rel="manifest" href="/app.webmanifest" />

<meta name="twitter:site" content="@QwikDev" />
<meta name="twitter:creator" content="@QwikDev" />
<meta name="twitter:card" content="summary_large_image" />

<meta property="fb:app_id" content="676395883130092" />

<meta property="og:url" content="https://qwik.builder.io/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Qwik" />
<meta property="og:description" content="Qwik is Framework reimagined for the edge" />
<meta
property="og:image"
content="https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F56f46c6818704d47957a587157e2444f?width=1200"
/>
<meta
property="og:image:alt"
content="Image of Qwik Framework Logo, Framework reimagined for the edge. Code snippet npm init qwik@latest"
/>
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="QwikDev" />

<script
innerHTML={partytownSnippet({
forward: ['dataLayer.push'],
})}
/>
<script
type="text/partytown"
innerHTML={`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-NR2STLN');`}
/>

<script
type="text/partytown"
src="https://cdn.jsdelivr.net/npm/@builder.io/persist-attribution@0.0.1-beta-2/dist/persist-attribution.min.js"
id="persist-attribution-init"
data-send-page-view-events="true"
/>
</>
import { component$ } from '@builder.io/qwik';
import { useDocumentHead, useLocation } from '@builder.io/qwik-city';
import { Manifest } from './manifest';
import { Social } from './social';
import { Vendor } from './vendor';

export const Head = component$(
() => {
const head = useDocumentHead();
const loc = useLocation();

return (
<>
<meta charSet="utf-8" />

<title>{head.title ? `${head.title} - Qwik` : `Qwik`}</title>
<link rel="canonical" href={loc.href} />
<meta name="viewport" content="width=device-width" />

<Manifest />
<Social loc={loc} head={head} />
<Vendor />

{head.meta.map((m) => (
<meta {...m} />
))}

{head.links.map((l) => (
<link {...l} />
))}

{head.styles.map((s) => (
<style {...s.props} dangerouslySetInnerHTML={s.style} />
))}
</>
);
},
{ tagName: 'head' }
);
Loading

0 comments on commit 498d052

Please sign in to comment.