Remove service worker, fix rendering
This commit is contained in:
parent
c4f5133531
commit
9224378866
|
@ -72,7 +72,6 @@ module.exports = {
|
||||||
resolve: `gatsby-source-filesystem`,
|
resolve: `gatsby-source-filesystem`,
|
||||||
options: {
|
options: {
|
||||||
name: `watcher`,
|
name: `watcher`,
|
||||||
// In dev mode, watch all the source files. Otherwise, point it at a meaningless directory
|
|
||||||
path: `${__dirname}/.cache/gatsby-source-git/`,
|
path: `${__dirname}/.cache/gatsby-source-git/`,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -164,5 +163,14 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
`gatsby-plugin-remove-serviceworker`,
|
`gatsby-plugin-remove-serviceworker`,
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
// {
|
||||||
|
// resolve: `gatsby-plugin-offline`,
|
||||||
|
// options: {
|
||||||
|
// precachePages: [`/en/4/developer_guides/**`],
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
>>>>>>> Remove service worker, fix rendering
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const Layout = require('./src/components/Layout').default;
|
const Layout = require('./src/components/Layout').default;
|
||||||
const NodeProvider = require('./src/components/NodeProvider').default;
|
const NodeProvider = require('./src/components/NodeProvider').default;
|
||||||
|
const { setCurrentPath } = require('./src/utils/nodes');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the node provider (static query of all documents)
|
* Applies the node provider (static query of all documents)
|
||||||
|
@ -16,7 +17,7 @@ exports.wrapPageElement = ({ element, props }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.onRenderBody = ({ setPostBodyComponents, setHeadComponents }) => {
|
exports.onRenderBody = ({ setPostBodyComponents, setHeadComponents, pathname }) => {
|
||||||
// Rules that cannot be touched by purgecss because they come in from client side rendering
|
// Rules that cannot be touched by purgecss because they come in from client side rendering
|
||||||
setHeadComponents([
|
setHeadComponents([
|
||||||
<style key='prism-css' type="text/css" dangerouslySetInnerHTML={{
|
<style key='prism-css' type="text/css" dangerouslySetInnerHTML={{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { StatelessComponent, useState, useEffect, ReactNode } from "react";
|
import React, { StatelessComponent, useState, ReactNode } from "react";
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
import useHierarchy from '../hooks/useHierarchy';
|
import useHierarchy from '../hooks/useHierarchy';
|
||||||
|
@ -9,11 +9,13 @@ interface LayoutProps {
|
||||||
slug: string;
|
slug: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const Layout: StatelessComponent<LayoutProps> = ({ children }) => {
|
const Layout: StatelessComponent<LayoutProps> = ({ children, pageContext: { slug } }) => {
|
||||||
const { setCurrentPath } = useHierarchy();
|
const { setCurrentPath } = useHierarchy();
|
||||||
const [isToggled, setSidebarOpen] = useState(false);
|
const [isToggled, setSidebarOpen] = useState(false);
|
||||||
const handleNavigate = () => setSidebarOpen(false);
|
const handleNavigate = () => setSidebarOpen(false);
|
||||||
|
|
||||||
|
setCurrentPath(slug);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header handleSidebarToggle={() => setSidebarOpen(!isToggled)} />
|
<Header handleSidebarToggle={() => setSidebarOpen(!isToggled)} />
|
||||||
|
|
|
@ -56,6 +56,7 @@ const NodeProvider: StatelessComponent<{}> = ({ children, pageContext: { slug }
|
||||||
getNodes,
|
getNodes,
|
||||||
getParent,
|
getParent,
|
||||||
getSiblings,
|
getSiblings,
|
||||||
|
setCurrentPath,
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</NodeContext.Provider>
|
</NodeContext.Provider>
|
||||||
|
|
|
@ -12,7 +12,7 @@ interface NodeFunctions {
|
||||||
getHomePage(): SilverstripeDocument|null;
|
getHomePage(): SilverstripeDocument|null;
|
||||||
getNavChildren(node: SilverstripeDocument): SilverstripeDocument[];
|
getNavChildren(node: SilverstripeDocument): SilverstripeDocument[];
|
||||||
getCurrentVersion(): string;
|
getCurrentVersion(): string;
|
||||||
setCurrentNode(slug: string): undefined;
|
setCurrentPath(slug: string): undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useHierarchy = (): NodeFunctions => {
|
const useHierarchy = (): NodeFunctions => {
|
||||||
|
|
|
@ -5,11 +5,11 @@ import { SingleFileQuery } from '../types';
|
||||||
|
|
||||||
const Template: StatelessComponent<SingleFileQuery> = (result): ReactElement => {
|
const Template: StatelessComponent<SingleFileQuery> = (result): ReactElement => {
|
||||||
const currentNode = result.data.silverstripeDocument;
|
const currentNode = result.data.silverstripeDocument;
|
||||||
const { title, slug } = currentNode;
|
const { title } = currentNode;
|
||||||
const { html } = currentNode.watchFile;
|
const { html } = currentNode.watchFile;
|
||||||
const { relativePath, gitRemote } = currentNode.parent.parent;
|
const { relativePath, gitRemote } = currentNode.parent.parent;
|
||||||
const { ref, href } = gitRemote;
|
const { ref, href } = gitRemote;
|
||||||
console.log('rendering the template for ', slug, html.substring(0, 25));
|
|
||||||
return (
|
return (
|
||||||
<DocsPage
|
<DocsPage
|
||||||
title={title}
|
title={title}
|
||||||
|
|
Loading…
Reference in New Issue