This repository has been archived by the owner on Dec 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
export * as fs from "https://deno.land/std@0.74.0/fs/mod.ts"; | ||
export * as path from "https://deno.land/std@0.74.0/path/mod.ts"; | ||
export * as colors from "https://deno.land/std@0.74.0/fmt/colors.ts"; | ||
export * as asserts from "https://deno.land/std@0.74.0/testing/asserts.ts"; | ||
export * as fs from "https://deno.land/std@0.75.0/fs/mod.ts"; | ||
export * as path from "https://deno.land/std@0.75.0/path/mod.ts"; | ||
export * as colors from "https://deno.land/std@0.75.0/fmt/colors.ts"; | ||
export * as asserts from "https://deno.land/std@0.75.0/testing/asserts.ts"; | ||
|
||
// @deno-types="./src/types/react/v16.14.0/react.d.ts" | ||
import React from "https://dev.jspm.io/[email protected]"; | ||
// @deno-types="./src/types/react-dom/v16.14.0/react-dom.d.ts" | ||
import ReactDOM from "https://dev.jspm.io/[email protected]"; | ||
// @deno-types="./src/types/react-dom/v16.14.0/server.d.ts" | ||
import ReactDOMServer from "https://dev.jspm.io/[email protected]/server.js"; | ||
// @deno-types="./src/types/react-helmet/v6.1.0/react-helmet.d.ts" | ||
import ReactHelmet from "https://esm.sh/[email protected]"; | ||
|
||
(window as any).React = React; | ||
(window as any).ReactDOM = ReactDOM; | ||
|
||
export { React, ReactDOM, ReactDOMServer }; | ||
export { React, ReactDOM, ReactDOMServer, ReactHelmet }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { fs, path, ReactDOMServer } from "../../deps.ts"; | ||
import ReactHelmet from "https://dev.jspm.io/[email protected]"; | ||
import ReactHelmet from "../../deps.ts"; | ||
|
||
import type { GagicPlugin } from "../Gagic.ts"; | ||
import { | ||
|
@@ -20,8 +20,8 @@ const out: GagicPlugin = { | |
} | ||
const fullFilePath = path.resolve(gagic.config.outDir, outputPath); | ||
(window as any).pageProps = pageProps; | ||
let htmlString = (ReactDOMServer as any).renderToString(content); | ||
const helmet = (ReactHelmet as any).renderStatic(); | ||
let htmlString = ReactDOMServer.renderToString(content); | ||
const helmet = ReactHelmet.Helmet.renderStatic(); | ||
const helmetString = [ | ||
"meta", | ||
"title", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { React } from "../../../deps.ts"; | ||
import ReactHelmet from "https://dev.jspm.io/[email protected]"; | ||
const { Helmet } = ReactHelmet; | ||
import { ReactHelmet } from "../../../deps.ts"; | ||
|
||
import type { GagicLayout } from "../../Gagic.ts"; | ||
|
||
|
@@ -16,7 +15,7 @@ const Head: GagicLayout<{ | |
`; | ||
return ( | ||
<head> | ||
<Helmet> | ||
<ReactHelmet.Helmet> | ||
<meta charSet="utf-8" /> | ||
<meta httpEquiv="x-ua-compatible" content="ie=edge" /> | ||
<title> | ||
|
@@ -39,7 +38,7 @@ const Head: GagicLayout<{ | |
/> | ||
<link rel="stylesheet" href={`${config.root}assets/index.css`} /> | ||
<script>{scriptSetIsDark}</script> | ||
</Helmet> | ||
</ReactHelmet.Helmet> | ||
{head} | ||
</head> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Type definitions for react-helmet 5.0 | ||
// Project: https://github.com/nfl/react-helmet | ||
// Definitions by: Evan Bremer <https://github.com/evanbb> | ||
// Isman Usoh <https://github.com/isman-usoh> | ||
// François Nguyen <https://github.com/lith-light-g> | ||
// Kok Sam <https://github.com/sammkj> | ||
// Yui T. <https://github.com/yuit> | ||
// Yamagishi Kazutoshi <https://github.com/ykzts> | ||
// Justin Hall <https://github.com/wKovacs64> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.8 | ||
|
||
import { React } from '../../../../deps.ts'; | ||
|
||
interface OtherElementAttributes { | ||
[key: string]: string | number | boolean | null | undefined; | ||
} | ||
|
||
type HtmlProps = JSX.IntrinsicElements['html'] & OtherElementAttributes; | ||
|
||
type BodyProps = JSX.IntrinsicElements['body'] & OtherElementAttributes; | ||
|
||
type LinkProps = JSX.IntrinsicElements['link']; | ||
|
||
type MetaProps = JSX.IntrinsicElements['meta']; | ||
|
||
export interface HelmetTags { | ||
baseTag: Array<any>; | ||
linkTags: Array<HTMLLinkElement>; | ||
metaTags: Array<HTMLMetaElement>; | ||
noscriptTags: Array<any>; | ||
scriptTags: Array<HTMLScriptElement>; | ||
styleTags: Array<HTMLStyleElement>; | ||
} | ||
|
||
export interface HelmetProps { | ||
async?: boolean; | ||
base?: any; | ||
bodyAttributes?: BodyProps; | ||
defaultTitle?: string; | ||
defer?: boolean; | ||
encodeSpecialCharacters?: boolean; | ||
htmlAttributes?: HtmlProps; | ||
onChangeClientState?: (newState: any, addedTags: HelmetTags, removedTags: HelmetTags) => void; | ||
link?: LinkProps[]; | ||
meta?: MetaProps[]; | ||
noscript?: Array<any>; | ||
script?: Array<any>; | ||
style?: Array<any>; | ||
title?: string; | ||
titleAttributes?: Object; | ||
titleTemplate?: string; | ||
} | ||
|
||
export class Helmet extends React.Component<HelmetProps> { | ||
static peek(): HelmetData; | ||
static rewind(): HelmetData; | ||
static renderStatic(): HelmetData; | ||
static canUseDOM: boolean; | ||
} | ||
|
||
export interface HelmetData { | ||
base: HelmetDatum; | ||
bodyAttributes: HelmetHTMLBodyDatum; | ||
htmlAttributes: HelmetHTMLElementDatum; | ||
link: HelmetDatum; | ||
meta: HelmetDatum; | ||
noscript: HelmetDatum; | ||
script: HelmetDatum; | ||
style: HelmetDatum; | ||
title: HelmetDatum; | ||
titleAttributes: HelmetDatum; | ||
} | ||
|
||
export interface HelmetDatum { | ||
toString(): string; | ||
toComponent(): React.Component<any>; | ||
} | ||
|
||
export interface HelmetHTMLBodyDatum { | ||
toString(): string; | ||
toComponent(): React.HTMLAttributes<HTMLBodyElement>; | ||
} | ||
|
||
export interface HelmetHTMLElementDatum { | ||
toString(): string; | ||
toComponent(): React.HTMLAttributes<HTMLHtmlElement>; | ||
} | ||
|
||
export const peek: () => HelmetData; | ||
export const rewind: () => HelmetData; | ||
export const renderStatic: () => HelmetData; | ||
export const canUseDOM: boolean; | ||
export default Helmet; |