Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Commit

Permalink
update type
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshixmk committed Oct 29, 2020
1 parent bcb6a50 commit efab96e
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 13 deletions.
14 changes: 9 additions & 5 deletions deps.ts
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 };
2 changes: 1 addition & 1 deletion src/Gagic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colors, fs, path, React } from "../deps.ts";
import { Application, send } from "https://deno.land/x/oak@v6.2.0/mod.ts";
import { Application, send } from "https://deno.land/x/oak@v6.3.1/mod.ts";

import {
getGagicConfigPath,
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/out.tsx
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 {
Expand All @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/themes/docs/_head.tsx
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";

Expand All @@ -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>
Expand All @@ -39,7 +38,7 @@ const Head: GagicLayout<{
/>
<link rel="stylesheet" href={`${config.root}assets/index.css`} />
<script>{scriptSetIsDark}</script>
</Helmet>
</ReactHelmet.Helmet>
{head}
</head>
);
Expand Down
94 changes: 94 additions & 0 deletions src/types/react-helmet/v6.1.0/react-helmet.d.ts
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;

0 comments on commit efab96e

Please sign in to comment.