Skip to content

Commit

Permalink
feat: add favicon to options
Browse files Browse the repository at this point in the history
  • Loading branch information
magne4000 committed Sep 25, 2023
1 parent cb170b2 commit e941cf6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions vike-solid/renderer/+config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export default {
description: {
env: "server-only",
},
favicon: {
env: 'server-only'
},
lang: {
env: "server-only",
},
Expand All @@ -64,6 +67,7 @@ declare global {
Layout?: Component;
title?: string | ((pageContext: PageContext) => string);
description?: string;
favicon?: string
/**
* @default 'en'
*/
Expand Down
16 changes: 6 additions & 10 deletions vike-solid/renderer/+onRenderHtml.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
export default onRenderHtml;
import {
generateHydrationScript,
renderToStream,
renderToString,
} from "solid-js/web";
import {
escapeInject,
dangerouslySkipEscape,
stampPipe,
} from "vike/server";
import { generateHydrationScript, renderToStream, renderToString } from "solid-js/web";
import { dangerouslySkipEscape, escapeInject, stampPipe } from "vike/server";
import { getTitle } from "./getTitle";
import { getPageElement } from "./getPageElement";
import type { PageContext } from "vike/types";
Expand All @@ -30,6 +22,9 @@ async function onRenderHtml(pageContext: PageContext) {
</PageContextProvider>
));

const favicon = pageContext.config.favicon;
const faviconTag = !favicon ? '' : escapeInject`<link rel="icon" href="${favicon}" />`;

const { pipe } = renderToStream(() =>
!pageContext.Page ? (
<></> // the ssr config flag is false
Expand All @@ -47,6 +42,7 @@ async function onRenderHtml(pageContext: PageContext) {
<head>
<meta charset="UTF-8" />
${titleTag}
${faviconTag}
${descriptionTag}
${dangerouslySkipEscape(headHtml)}
${dangerouslySkipEscape(generateHydrationScript())}
Expand Down

0 comments on commit e941cf6

Please sign in to comment.