11import { component$ , useContextProvider , useStore } from '@qwik.dev/core' ;
22import { Insights } from '@qwik.dev/core/insights' ;
3- import {
4- RouterOutlet ,
5- ServiceWorkerRegister ,
6- useDocumentHead ,
7- useLocation ,
8- useQwikRouter ,
9- } from '@qwik.dev/router' ;
10- import RealMetricsOptimization from './components/real-metrics-optimization/real-metrics-optimization' ;
11- import { Social } from './components/router-head/social' ;
12- import { Vendor } from './components/router-head/vendor' ;
3+ import { RouterOutlet , useQwikRouter } from '@qwik.dev/router' ;
4+ import { RouterHead } from './components/router-head/router-head' ;
135import { InjectThemeScript } from './components/theme-toggle' ;
14- import { BUILDER_PUBLIC_API_KEY } from './constants' ;
156import { GlobalStore , type SiteStore } from './context' ;
7+
168import './global.css' ;
179
1810export const uwu = /*javascript*/ `
@@ -50,8 +42,6 @@ export const uwu = /*javascript*/ `
5042
5143export default component$ ( ( ) => {
5244 useQwikRouter ( ) ;
53- const head = useDocumentHead ( ) ;
54- const { url } = useLocation ( ) ;
5545
5646 const store = useStore < SiteStore > ( {
5747 headerMenuOpen : false ,
@@ -62,55 +52,11 @@ export default component$(() => {
6252
6353 useContextProvider ( GlobalStore , store ) ;
6454
65- const title = head . title
66- ? `${ head . title } 📚 Qwik Documentation`
67- : `Qwik - Framework reimagined for the edge` ;
68- const description =
69- head . meta . find ( ( m ) => m . name === 'description' ) ?. content ||
70- `No hydration, auto lazy-loading, edge-optimized, and fun 🎉!` ;
71-
72- const OGImage = {
73- imageURL : '' ,
74- ogImgTitle : '' ,
75- ogImgSubTitle : '' as string | undefined ,
76-
77- get URL ( ) {
78- //turn the title into array with [0] -> Title [1] -> subTitle
79- const arrayedTitle = title . split ( ' | ' ) ;
80- const ogImageUrl = new URL ( 'https://opengraphqwik.vercel.app/api/og?level=1' ) ;
81-
82- // biggerTitle
83- this . ogImgTitle = arrayedTitle [ 0 ] ;
84- //smallerTitle
85- this . ogImgSubTitle = arrayedTitle [ 1 ]
86- ? arrayedTitle [ 1 ] . replace ( ' 📚 Qwik Documentation' , '' )
87- : undefined ;
88-
89- //decide whether or not to show dynamic OGimage or use docs default social card
90- if ( this . ogImgSubTitle == undefined || this . ogImgTitle == undefined ) {
91- this . imageURL = new URL ( `/logos/social-card.jpg` , url ) . href ;
92-
93- return this . imageURL ;
94- } else {
95- ogImageUrl . searchParams . set ( 'title' , this . ogImgTitle ) ;
96- ogImageUrl . searchParams . set ( 'subtitle' , this . ogImgSubTitle ) ;
97- // ogImageUrl.searchParams.set('level', this.routeLevel.toString());
98-
99- this . imageURL = ogImageUrl . toString ( ) ;
100-
101- return this . imageURL ;
102- }
103- } ,
104- } ;
105-
10655 return (
10756 < >
10857 < head >
10958 < meta charset = "utf-8" />
11059
111- < title > { title } </ title >
112- < meta name = "description" content = { description } />
113- < link rel = "canonical" href = { head . frontmatter ?. canonical || url . href } />
11460 < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />
11561 < meta name = "apple-mobile-web-app-title" content = "Qwik" />
11662 < meta name = "application-name" content = "Qwik" />
@@ -121,38 +67,11 @@ export default component$(() => {
12167 < link rel = "apple-touch-icon" sizes = "180x180" href = "/favicons/apple-touch-icon.png" />
12268 < link rel = "icon" href = "/favicons/favicon.svg" type = "image/svg+xml" />
12369
124- { import . meta. env . PROD && (
125- < >
126- < Social title = { title } description = { description } href = { url . href } ogImage = { OGImage . URL } />
127- < Vendor />
128- </ >
129- ) }
130-
131- { /* The below are tags that were collected from all the `head` exports in the current route. */ }
132- { head . meta
133- // Skip description because that was already added at the top
134- . filter ( ( s ) => s . name !== 'description' )
135- . map ( ( m , key ) => (
136- < meta key = { key } { ...m } />
137- ) ) }
138-
139- { head . links . map ( ( l , key ) => (
140- < link key = { key } { ...l } />
141- ) ) }
142-
143- { head . styles . map ( ( s , key ) => (
144- < style key = { key } { ...s . props } dangerouslySetInnerHTML = { s . style } />
145- ) ) }
146-
147- { head . scripts . map ( ( s , key ) => (
148- < script key = { key } { ...s . props } dangerouslySetInnerHTML = { s . script } />
149- ) ) }
70+ < RouterHead />
15071
15172 < InjectThemeScript />
15273 < script dangerouslySetInnerHTML = { uwu } />
15374
154- < ServiceWorkerRegister />
155-
15675 < script dangerouslySetInnerHTML = { `(${ collectSymbols } )()` } />
15776 < Insights />
15877 </ head >
@@ -164,7 +83,6 @@ export default component$(() => {
16483 >
16584 { /* This renders the current route, including all Layout components. */ }
16685 < RouterOutlet />
167- < RealMetricsOptimization builderApiKey = { BUILDER_PUBLIC_API_KEY } />
16886 </ body >
16987 </ >
17088 ) ;
0 commit comments