22 | Boiler Plate
23 |
24 | for react and tailwind.
25 |
26 |
27 | Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui
28 | lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat
29 | fugiat aliqua.
30 |
31 |
32 |
33 |
36 | Get started
37 |
38 |
39 |
40 |
43 | View Demo
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | );
53 | }
54 |
--------------------------------------------------------------------------------
/.cache/ensure-resources.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import loader, { PageResourceStatus } from "./loader"
3 | import shallowCompare from "shallow-compare"
4 |
5 | class EnsureResources extends React.Component {
6 | constructor(props) {
7 | super()
8 | const { location, pageResources } = props
9 | this.state = {
10 | location: { ...location },
11 | pageResources: pageResources || loader.loadPageSync(location.pathname),
12 | }
13 | }
14 |
15 | static getDerivedStateFromProps({ location }, prevState) {
16 | if (prevState.location.href !== location.href) {
17 | const pageResources = loader.loadPageSync(location.pathname)
18 | return {
19 | pageResources,
20 | location: { ...location },
21 | }
22 | }
23 |
24 | return {
25 | location: { ...location },
26 | }
27 | }
28 |
29 | loadResources(rawPath) {
30 | loader.loadPage(rawPath).then(pageResources => {
31 | if (pageResources && pageResources.status !== PageResourceStatus.Error) {
32 | this.setState({
33 | location: { ...window.location },
34 | pageResources,
35 | })
36 | } else {
37 | window.history.replaceState({}, ``, location.href)
38 | window.location = rawPath
39 | }
40 | })
41 | }
42 |
43 | shouldComponentUpdate(nextProps, nextState) {
44 | // Always return false if we're missing resources.
45 | if (!nextState.pageResources) {
46 | this.loadResources(nextProps.location.pathname)
47 | return false
48 | }
49 |
50 | // Check if the component or json have changed.
51 | if (this.state.pageResources !== nextState.pageResources) {
52 | return true
53 | }
54 | if (
55 | this.state.pageResources.component !== nextState.pageResources.component
56 | ) {
57 | return true
58 | }
59 |
60 | if (this.state.pageResources.json !== nextState.pageResources.json) {
61 | return true
62 | }
63 | // Check if location has changed on a page using internal routing
64 | // via matchPath configuration.
65 | if (
66 | this.state.location.key !== nextState.location.key &&
67 | nextState.pageResources.page &&
68 | (nextState.pageResources.page.matchPath ||
69 | nextState.pageResources.page.path)
70 | ) {
71 | return true
72 | }
73 | return shallowCompare(this, nextProps, nextState)
74 | }
75 |
76 | render() {
77 | if (process.env.NODE_ENV !== `production` && !this.state.pageResources) {
78 | throw new Error(
79 | `EnsureResources was not able to find resources for path: "${this.props.location.pathname}"
80 | This typically means that an issue occurred building components for that path.
81 | Run \`gatsby clean\` to remove any cached elements.`
82 | )
83 | }
84 |
85 | return this.props.children(this.state)
86 | }
87 | }
88 |
89 | export default EnsureResources
90 |
--------------------------------------------------------------------------------
/.cache/register-service-worker.js:
--------------------------------------------------------------------------------
1 | import { apiRunner } from "./api-runner-browser"
2 |
3 | if (
4 | window.location.protocol !== `https:` &&
5 | window.location.hostname !== `localhost`
6 | ) {
7 | console.error(
8 | `Service workers can only be used over HTTPS, or on localhost for development`
9 | )
10 | } else if (`serviceWorker` in navigator) {
11 | navigator.serviceWorker
12 | .register(`${__BASE_PATH__}/sw.js`)
13 | .then(function (reg) {
14 | reg.addEventListener(`updatefound`, () => {
15 | apiRunner(`onServiceWorkerUpdateFound`, { serviceWorker: reg })
16 | // The updatefound event implies that reg.installing is set; see
17 | // https://w3c.github.io/ServiceWorker/#service-worker-registration-updatefound-event
18 | const installingWorker = reg.installing
19 | console.log(`installingWorker`, installingWorker)
20 | installingWorker.addEventListener(`statechange`, () => {
21 | switch (installingWorker.state) {
22 | case `installed`:
23 | if (navigator.serviceWorker.controller) {
24 | // At this point, the old content will have been purged and the fresh content will
25 | // have been added to the cache.
26 |
27 | // We set a flag so Gatsby Link knows to refresh the page on next navigation attempt
28 | window.___swUpdated = true
29 | // We call the onServiceWorkerUpdateReady API so users can show update prompts.
30 | apiRunner(`onServiceWorkerUpdateReady`, { serviceWorker: reg })
31 |
32 | // If resources failed for the current page, reload.
33 | if (window.___failedResources) {
34 | console.log(`resources failed, SW updated - reloading`)
35 | window.location.reload()
36 | }
37 | } else {
38 | // At this point, everything has been precached.
39 | // It's the perfect time to display a "Content is cached for offline use." message.
40 | console.log(`Content is now available offline!`)
41 |
42 | // Post to service worker that install is complete.
43 | // Delay to allow time for the event listener to be added --
44 | // otherwise fetch is called too soon and resources aren't cached.
45 | apiRunner(`onServiceWorkerInstalled`, { serviceWorker: reg })
46 | }
47 | break
48 |
49 | case `redundant`:
50 | console.error(`The installing service worker became redundant.`)
51 | apiRunner(`onServiceWorkerRedundant`, { serviceWorker: reg })
52 | break
53 |
54 | case `activated`:
55 | apiRunner(`onServiceWorkerActive`, { serviceWorker: reg })
56 | break
57 | }
58 | })
59 | })
60 | })
61 | .catch(function (e) {
62 | console.error(`Error during service worker registration:`, e)
63 | })
64 | }
65 |
--------------------------------------------------------------------------------
/.cache/commonjs/register-service-worker.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var _apiRunnerBrowser = require("./api-runner-browser");
4 |
5 | if (window.location.protocol !== `https:` && window.location.hostname !== `localhost`) {
6 | console.error(`Service workers can only be used over HTTPS, or on localhost for development`);
7 | } else if (`serviceWorker` in navigator) {
8 | navigator.serviceWorker.register(`${__BASE_PATH__}/sw.js`).then(function (reg) {
9 | reg.addEventListener(`updatefound`, () => {
10 | (0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerUpdateFound`, {
11 | serviceWorker: reg
12 | }); // The updatefound event implies that reg.installing is set; see
13 | // https://w3c.github.io/ServiceWorker/#service-worker-registration-updatefound-event
14 |
15 | const installingWorker = reg.installing;
16 | console.log(`installingWorker`, installingWorker);
17 | installingWorker.addEventListener(`statechange`, () => {
18 | switch (installingWorker.state) {
19 | case `installed`:
20 | if (navigator.serviceWorker.controller) {
21 | // At this point, the old content will have been purged and the fresh content will
22 | // have been added to the cache.
23 | // We set a flag so Gatsby Link knows to refresh the page on next navigation attempt
24 | window.___swUpdated = true; // We call the onServiceWorkerUpdateReady API so users can show update prompts.
25 |
26 | (0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerUpdateReady`, {
27 | serviceWorker: reg
28 | }); // If resources failed for the current page, reload.
29 |
30 | if (window.___failedResources) {
31 | console.log(`resources failed, SW updated - reloading`);
32 | window.location.reload();
33 | }
34 | } else {
35 | // At this point, everything has been precached.
36 | // It's the perfect time to display a "Content is cached for offline use." message.
37 | console.log(`Content is now available offline!`); // Post to service worker that install is complete.
38 | // Delay to allow time for the event listener to be added --
39 | // otherwise fetch is called too soon and resources aren't cached.
40 |
41 | (0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerInstalled`, {
42 | serviceWorker: reg
43 | });
44 | }
45 |
46 | break;
47 |
48 | case `redundant`:
49 | console.error(`The installing service worker became redundant.`);
50 | (0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerRedundant`, {
51 | serviceWorker: reg
52 | });
53 | break;
54 |
55 | case `activated`:
56 | (0, _apiRunnerBrowser.apiRunner)(`onServiceWorkerActive`, {
57 | serviceWorker: reg
58 | });
59 | break;
60 | }
61 | });
62 | });
63 | }).catch(function (e) {
64 | console.error(`Error during service worker registration:`, e);
65 | });
66 | }
--------------------------------------------------------------------------------
/.cache/__tests__/find-path.js:
--------------------------------------------------------------------------------
1 | import { cleanPath, setMatchPaths, findMatchPath, findPath } from "../find-path"
2 |
3 | describe(`find-path`, () => {
4 | describe(`cleanPath`, () => {
5 | beforeEach(() => {
6 | global.__BASE_PATH__ = ``
7 | })
8 |
9 | it(`should strip out ? & # from a pathname`, () => {
10 | expect(cleanPath(`/mypath#anchor?gatsby=cool`)).toBe(`/mypath`)
11 | })
12 |
13 | it(`should convert a /index.html to root dir`, () => {
14 | expect(cleanPath(`/index.html`)).toBe(`/`)
15 | })
16 |
17 | it(`strip out a basePrefix`, () => {
18 | global.__BASE_PATH__ = `/blog`
19 | expect(cleanPath(`/blog/mypath`)).toBe(`/mypath`)
20 | })
21 | })
22 |
23 | describe(`findMatchPath`, () => {
24 | beforeEach(() => {
25 | // reset matchPaths
26 | setMatchPaths([])
27 | global.__BASE_PATH__ = ``
28 | })
29 |
30 | it(`should find a path when matchPath found`, () => {
31 | setMatchPaths([
32 | {
33 | matchPath: `/app/*`,
34 | path: `/app`,
35 | },
36 | ])
37 |
38 | expect(findMatchPath(`/app/dynamic-page#anchor?gatsby=cool`)).toBe(`/app`)
39 | })
40 |
41 | it(`should return null when no matchPathFound`, () => {
42 | setMatchPaths([
43 | {
44 | matchPath: `/app/*`,
45 | path: `/app`,
46 | },
47 | ])
48 |
49 | expect(findMatchPath(`/notanapp/dynamic-page`)).toBeNull()
50 | })
51 | })
52 |
53 | describe(`findPath`, () => {
54 | beforeEach(() => {
55 | // reset matchPaths
56 | setMatchPaths([])
57 | global.__BASE_PATH__ = ``
58 | })
59 |
60 | it(`should use matchPath if found`, () => {
61 | setMatchPaths([
62 | {
63 | matchPath: `/app/*`,
64 | path: `/app`,
65 | },
66 | ])
67 |
68 | expect(findPath(`/app/dynamic-page#anchor?gatsby=cool`)).toBe(`/app`)
69 | })
70 |
71 | it(`should return the cleaned up path when no matchPathFound`, () => {
72 | setMatchPaths([
73 | {
74 | matchPath: `/app/*`,
75 | path: `/app`,
76 | },
77 | ])
78 |
79 | expect(findPath(`/notanapp/my-page#anchor?gatsby=cool`)).toBe(
80 | `/notanapp/my-page`
81 | )
82 | })
83 |
84 | it(`should only process a request once`, () => {
85 | jest.resetModules()
86 | jest.mock(`@reach/router/lib/utils`)
87 | const findPath = require(`../find-path`).findPath
88 | const setMatchPaths = require(`../find-path`).setMatchPaths
89 | const match = require(`@reach/router/lib/utils`).match
90 |
91 | setMatchPaths([
92 | {
93 | matchPath: `/app/*`,
94 | path: `/app`,
95 | },
96 | ])
97 |
98 | expect(findPath(`/notanapp/my-page#anchor?gatsby=cool`)).toBe(
99 | `/notanapp/my-page`
100 | )
101 | expect(findPath(`/notanapp/my-page#anchor?gatsby=cool`)).toBe(
102 | `/notanapp/my-page`
103 | )
104 | expect(findPath(`/notanapp/my-page`)).toBe(`/notanapp/my-page`)
105 |
106 | expect(match).toHaveBeenCalledTimes(1)
107 | })
108 | })
109 | })
110 |
--------------------------------------------------------------------------------
/.cache/commonjs/find-path.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4 |
5 | exports.__esModule = true;
6 | exports.cleanPath = exports.findPath = exports.findMatchPath = exports.setMatchPaths = void 0;
7 |
8 | var _utils = require("@reach/router/lib/utils");
9 |
10 | var _stripPrefix = _interopRequireDefault(require("./strip-prefix"));
11 |
12 | var _normalizePagePath = _interopRequireDefault(require("./normalize-page-path"));
13 |
14 | const pathCache = new Map();
15 | let matchPaths = [];
16 |
17 | const trimPathname = rawPathname => {
18 | const pathname = decodeURIComponent(rawPathname); // Remove the pathPrefix from the pathname.
19 |
20 | const trimmedPathname = (0, _stripPrefix.default)(pathname, __BASE_PATH__) // Remove any hashfragment
21 | .split(`#`)[0] // Remove search query
22 | .split(`?`)[0];
23 | return trimmedPathname;
24 | };
25 | /**
26 | * Set list of matchPaths
27 | *
28 | * @param {Array<{path: string, matchPath: string}>} value collection of matchPaths
29 | */
30 |
31 |
32 | const setMatchPaths = value => {
33 | matchPaths = value;
34 | };
35 | /**
36 | * Return a matchpath url
37 | * if `match-paths.json` contains `{ "/foo*": "/page1", ...}`, then
38 | * `/foo?bar=far` => `/page1`
39 | *
40 | * @param {string} rawPathname A raw pathname
41 | * @return {string|null}
42 | */
43 |
44 |
45 | exports.setMatchPaths = setMatchPaths;
46 |
47 | const findMatchPath = rawPathname => {
48 | const trimmedPathname = cleanPath(rawPathname);
49 |
50 | for (const {
51 | matchPath,
52 | path
53 | } of matchPaths) {
54 | if ((0, _utils.match)(matchPath, trimmedPathname)) {
55 | return (0, _normalizePagePath.default)(path);
56 | }
57 | }
58 |
59 | return null;
60 | }; // Given a raw URL path, returns the cleaned version of it (trim off
61 | // `#` and query params), or if it matches an entry in
62 | // `match-paths.json`, its matched path is returned
63 | //
64 | // E.g. `/foo?bar=far` => `/foo`
65 | //
66 | // Or if `match-paths.json` contains `{ "/foo*": "/page1", ...}`, then
67 | // `/foo?bar=far` => `/page1`
68 |
69 |
70 | exports.findMatchPath = findMatchPath;
71 |
72 | const findPath = rawPathname => {
73 | const trimmedPathname = trimPathname(rawPathname);
74 |
75 | if (pathCache.has(trimmedPathname)) {
76 | return pathCache.get(trimmedPathname);
77 | }
78 |
79 | let foundPath = findMatchPath(trimmedPathname);
80 |
81 | if (!foundPath) {
82 | foundPath = cleanPath(rawPathname);
83 | }
84 |
85 | pathCache.set(trimmedPathname, foundPath);
86 | return foundPath;
87 | };
88 | /**
89 | * Clean a url and converts /index.html => /
90 | * E.g. `/foo?bar=far` => `/foo`
91 | *
92 | * @param {string} rawPathname A raw pathname
93 | * @return {string}
94 | */
95 |
96 |
97 | exports.findPath = findPath;
98 |
99 | const cleanPath = rawPathname => {
100 | const trimmedPathname = trimPathname(rawPathname);
101 | let foundPath = trimmedPathname;
102 |
103 | if (foundPath === `/index.html`) {
104 | foundPath = `/`;
105 | }
106 |
107 | foundPath = (0, _normalizePagePath.default)(foundPath);
108 | return foundPath;
109 | };
110 |
111 | exports.cleanPath = cleanPath;
--------------------------------------------------------------------------------
/.cache/commonjs/ensure-resources.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4 |
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6 |
7 | exports.__esModule = true;
8 | exports.default = void 0;
9 |
10 | var _react = _interopRequireDefault(require("react"));
11 |
12 | var _loader = _interopRequireWildcard(require("./loader"));
13 |
14 | var _shallowCompare = _interopRequireDefault(require("shallow-compare"));
15 |
16 | class EnsureResources extends _react.default.Component {
17 | constructor(props) {
18 | super();
19 | const {
20 | location,
21 | pageResources
22 | } = props;
23 | this.state = {
24 | location: { ...location
25 | },
26 | pageResources: pageResources || _loader.default.loadPageSync(location.pathname)
27 | };
28 | }
29 |
30 | static getDerivedStateFromProps({
31 | location
32 | }, prevState) {
33 | if (prevState.location.href !== location.href) {
34 | const pageResources = _loader.default.loadPageSync(location.pathname);
35 |
36 | return {
37 | pageResources,
38 | location: { ...location
39 | }
40 | };
41 | }
42 |
43 | return {
44 | location: { ...location
45 | }
46 | };
47 | }
48 |
49 | loadResources(rawPath) {
50 | _loader.default.loadPage(rawPath).then(pageResources => {
51 | if (pageResources && pageResources.status !== _loader.PageResourceStatus.Error) {
52 | this.setState({
53 | location: { ...window.location
54 | },
55 | pageResources
56 | });
57 | } else {
58 | window.history.replaceState({}, ``, location.href);
59 | window.location = rawPath;
60 | }
61 | });
62 | }
63 |
64 | shouldComponentUpdate(nextProps, nextState) {
65 | // Always return false if we're missing resources.
66 | if (!nextState.pageResources) {
67 | this.loadResources(nextProps.location.pathname);
68 | return false;
69 | } // Check if the component or json have changed.
70 |
71 |
72 | if (this.state.pageResources !== nextState.pageResources) {
73 | return true;
74 | }
75 |
76 | if (this.state.pageResources.component !== nextState.pageResources.component) {
77 | return true;
78 | }
79 |
80 | if (this.state.pageResources.json !== nextState.pageResources.json) {
81 | return true;
82 | } // Check if location has changed on a page using internal routing
83 | // via matchPath configuration.
84 |
85 |
86 | if (this.state.location.key !== nextState.location.key && nextState.pageResources.page && (nextState.pageResources.page.matchPath || nextState.pageResources.page.path)) {
87 | return true;
88 | }
89 |
90 | return (0, _shallowCompare.default)(this, nextProps, nextState);
91 | }
92 |
93 | render() {
94 | if (process.env.NODE_ENV !== `production` && !this.state.pageResources) {
95 | throw new Error(`EnsureResources was not able to find resources for path: "${this.props.location.pathname}"
96 | This typically means that an issue occurred building components for that path.
97 | Run \`gatsby clean\` to remove any cached elements.`);
98 | }
99 |
100 | return this.props.children(this.state);
101 | }
102 |
103 | }
104 |
105 | var _default = EnsureResources;
106 | exports.default = _default;
--------------------------------------------------------------------------------
/.cache/gatsby-browser-entry.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import PropTypes from "prop-types"
3 | import Link, {
4 | withPrefix,
5 | withAssetPrefix,
6 | navigate,
7 | push,
8 | replace,
9 | navigateTo,
10 | parsePath,
11 | } from "gatsby-link"
12 | import PageRenderer from "./public-page-renderer"
13 | import loader from "./loader"
14 |
15 | const prefetchPathname = loader.enqueue
16 |
17 | const StaticQueryContext = React.createContext({})
18 |
19 | function StaticQueryDataRenderer({ staticQueryData, data, query, render }) {
20 | const finalData = data
21 | ? data.data
22 | : staticQueryData[query] && staticQueryData[query].data
23 |
24 | return (
25 |
26 | {finalData && render(finalData)}
27 | {!finalData &&
"`;
6 |
7 | exports[`develop-static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`;
8 |
9 | exports[`static-entry onPreRenderHTML can be used to replace headComponents 1`] = `"
"`;
10 |
11 | exports[`static-entry onPreRenderHTML can be used to replace postBodyComponents 1`] = `"
div3
div2
div1
"`;
12 |
13 | exports[`static-entry onPreRenderHTML can be used to replace preBodyComponents 1`] = `"
div3
div2
div1
"`;
14 |
--------------------------------------------------------------------------------
/.cache/commonjs/root.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4 |
5 | exports.__esModule = true;
6 | exports.default = void 0;
7 |
8 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9 |
10 | var _react = _interopRequireDefault(require("react"));
11 |
12 | var _router = require("@reach/router");
13 |
14 | var _gatsbyReactRouterScroll = require("gatsby-react-router-scroll");
15 |
16 | var _navigation = require("./navigation");
17 |
18 | var _apiRunnerBrowser = require("./api-runner-browser");
19 |
20 | var _loader = _interopRequireDefault(require("./loader"));
21 |
22 | var _queryResultStore = require("./query-result-store");
23 |
24 | var _ensureResources = _interopRequireDefault(require("./ensure-resources"));
25 |
26 | var _errorOverlayHandler = require("./error-overlay-handler");
27 |
28 | // TODO: Remove entire block when we make fast-refresh the default
29 | // In fast-refresh, this logic is all moved into the `error-overlay-handler`
30 | if (window.__webpack_hot_middleware_reporter__ !== undefined && process.env.GATSBY_HOT_LOADER !== `fast-refresh`) {
31 | const overlayErrorID = `webpack`; // Report build errors
32 |
33 | window.__webpack_hot_middleware_reporter__.useCustomOverlay({
34 | showProblems(type, obj) {
35 | if (type !== `errors`) {
36 | (0, _errorOverlayHandler.clearError)(overlayErrorID);
37 | return;
38 | }
39 |
40 | (0, _errorOverlayHandler.reportError)(overlayErrorID, obj[0]);
41 | },
42 |
43 | clear() {
44 | (0, _errorOverlayHandler.clearError)(overlayErrorID);
45 | }
46 |
47 | });
48 | }
49 |
50 | (0, _navigation.init)(); // In gatsby v2 if Router is used in page using matchPaths
51 | // paths need to contain full path.
52 | // For example:
53 | // - page have `/app/*` matchPath
54 | // - inside template user needs to use `/app/xyz` as path
55 | // Resetting `basepath`/`baseuri` keeps current behaviour
56 | // to not introduce breaking change.
57 | // Remove this in v3
58 |
59 | const RouteHandler = props => /*#__PURE__*/_react.default.createElement(_router.BaseContext.Provider, {
60 | value: {
61 | baseuri: `/`,
62 | basepath: `/`
63 | }
64 | }, /*#__PURE__*/_react.default.createElement(_queryResultStore.PageQueryStore, props));
65 |
66 | class LocationHandler extends _react.default.Component {
67 | render() {
68 | const {
69 | location
70 | } = this.props;
71 |
72 | if (!_loader.default.isPageNotFound(location.pathname)) {
73 | return (/*#__PURE__*/_react.default.createElement(_ensureResources.default, {
74 | location: location
75 | }, locationAndPageResources => /*#__PURE__*/_react.default.createElement(_navigation.RouteUpdates, {
76 | location: location
77 | }, /*#__PURE__*/_react.default.createElement(_gatsbyReactRouterScroll.ScrollContext, {
78 | location: location,
79 | shouldUpdateScroll: _navigation.shouldUpdateScroll
80 | }, /*#__PURE__*/_react.default.createElement(_router.Router, {
81 | basepath: __BASE_PATH__,
82 | location: location,
83 | id: "gatsby-focus-wrapper"
84 | }, /*#__PURE__*/_react.default.createElement(RouteHandler, (0, _extends2.default)({
85 | path: encodeURI(locationAndPageResources.pageResources.page.matchPath || locationAndPageResources.pageResources.page.path)
86 | }, this.props, locationAndPageResources))))))
87 | );
88 | }
89 |
90 | const dev404PageResources = _loader.default.loadPageSync(`/dev-404-page`);
91 |
92 | const real404PageResources = _loader.default.loadPageSync(`/404.html`);
93 |
94 | let custom404;
95 |
96 | if (real404PageResources) {
97 | custom404 = /*#__PURE__*/_react.default.createElement(_queryResultStore.PageQueryStore, (0, _extends2.default)({}, this.props, {
98 | pageResources: real404PageResources
99 | }));
100 | }
101 |
102 | return (/*#__PURE__*/_react.default.createElement(_navigation.RouteUpdates, {
103 | location: location
104 | }, /*#__PURE__*/_react.default.createElement(_router.Router, {
105 | basepath: __BASE_PATH__,
106 | location: location,
107 | id: "gatsby-focus-wrapper"
108 | }, /*#__PURE__*/_react.default.createElement(RouteHandler, {
109 | path: location.pathname,
110 | location: location,
111 | pageResources: dev404PageResources,
112 | custom404: custom404
113 | })))
114 | );
115 | }
116 |
117 | }
118 |
119 | const Root = () => /*#__PURE__*/_react.default.createElement(_router.Location, null, locationContext => /*#__PURE__*/_react.default.createElement(LocationHandler, locationContext)); // Let site, plugins wrap the site e.g. for Redux.
120 |
121 |
122 | const WrappedRoot = (0, _apiRunnerBrowser.apiRunner)(`wrapRootElement`, {
123 | element: /*#__PURE__*/_react.default.createElement(Root, null)
124 | }, /*#__PURE__*/_react.default.createElement(Root, null), ({
125 | result,
126 | plugin
127 | }) => {
128 | return {
129 | element: result
130 | };
131 | }).pop();
132 |
133 | var _default = () => /*#__PURE__*/_react.default.createElement(_queryResultStore.StaticQueryStore, null, WrappedRoot);
134 |
135 | exports.default = _default;
--------------------------------------------------------------------------------
/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { 'Service-Worker': 'script' },
105 | })
106 | .then(response => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get('content-type');
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf('javascript') === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then(registration => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | 'No internet connection found. App is running in offline mode.'
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ('serviceWorker' in navigator) {
133 | navigator.serviceWorker.ready
134 | .then(registration => {
135 | registration.unregister();
136 | })
137 | .catch(error => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/.cache/production-app.js:
--------------------------------------------------------------------------------
1 | import { apiRunner, apiRunnerAsync } from "./api-runner-browser"
2 | import React from "react"
3 | import ReactDOM from "react-dom"
4 | import { Router, navigate, Location, BaseContext } from "@reach/router"
5 | import { ScrollContext } from "gatsby-react-router-scroll"
6 | import domReady from "@mikaelkristiansson/domready"
7 | import {
8 | shouldUpdateScroll,
9 | init as navigationInit,
10 | RouteUpdates,
11 | } from "./navigation"
12 | import emitter from "./emitter"
13 | import PageRenderer from "./page-renderer"
14 | import asyncRequires from "./async-requires"
15 | import {
16 | setLoader,
17 | ProdLoader,
18 | publicLoader,
19 | PageResourceStatus,
20 | } from "./loader"
21 | import EnsureResources from "./ensure-resources"
22 | import stripPrefix from "./strip-prefix"
23 |
24 | // Generated during bootstrap
25 | import matchPaths from "./match-paths.json"
26 |
27 | const loader = new ProdLoader(asyncRequires, matchPaths)
28 | setLoader(loader)
29 | loader.setApiRunner(apiRunner)
30 |
31 | window.asyncRequires = asyncRequires
32 | window.___emitter = emitter
33 | window.___loader = publicLoader
34 |
35 | navigationInit()
36 |
37 | apiRunnerAsync(`onClientEntry`).then(() => {
38 | // Let plugins register a service worker. The plugin just needs
39 | // to return true.
40 | if (apiRunner(`registerServiceWorker`).length > 0) {
41 | require(`./register-service-worker`)
42 | }
43 |
44 | // In gatsby v2 if Router is used in page using matchPaths
45 | // paths need to contain full path.
46 | // For example:
47 | // - page have `/app/*` matchPath
48 | // - inside template user needs to use `/app/xyz` as path
49 | // Resetting `basepath`/`baseuri` keeps current behaviour
50 | // to not introduce breaking change.
51 | // Remove this in v3
52 | const RouteHandler = props => (
53 |
59 |
60 |
61 | )
62 |
63 | class LocationHandler extends React.Component {
64 | render() {
65 | const { location } = this.props
66 | return (
67 |
68 | {({ pageResources, location }) => (
69 |
70 |
74 |
79 |
93 |
94 |
95 |
96 | )}
97 |
98 | )
99 | }
100 | }
101 |
102 | const { pagePath, location: browserLoc } = window
103 |
104 | // Explicitly call navigate if the canonical path (window.pagePath)
105 | // is different to the browser path (window.location.pathname). But
106 | // only if NONE of the following conditions hold:
107 | //
108 | // - The url matches a client side route (page.matchPath)
109 | // - it's a 404 page
110 | // - it's the offline plugin shell (/offline-plugin-app-shell-fallback/)
111 | if (
112 | pagePath &&
113 | __BASE_PATH__ + pagePath !== browserLoc.pathname &&
114 | !(
115 | loader.findMatchPath(stripPrefix(browserLoc.pathname, __BASE_PATH__)) ||
116 | pagePath === `/404.html` ||
117 | pagePath.match(/^\/404\/?$/) ||
118 | pagePath.match(/^\/offline-plugin-app-shell-fallback\/?$/)
119 | )
120 | ) {
121 | navigate(__BASE_PATH__ + pagePath + browserLoc.search + browserLoc.hash, {
122 | replace: true,
123 | })
124 | }
125 |
126 | publicLoader.loadPage(browserLoc.pathname).then(page => {
127 | if (!page || page.status === PageResourceStatus.Error) {
128 | throw new Error(
129 | `page resources for ${browserLoc.pathname} not found. Not rendering React`
130 | )
131 | }
132 |
133 | window.___webpackCompilationHash = page.page.webpackCompilationHash
134 |
135 | const Root = () => (
136 |
137 | {locationContext => }
138 |
139 | )
140 |
141 | const WrappedRoot = apiRunner(
142 | `wrapRootElement`,
143 | { element: },
144 | ,
145 | ({ result }) => {
146 | return { element: result }
147 | }
148 | ).pop()
149 |
150 | const NewRoot = () => WrappedRoot
151 |
152 | const renderer = apiRunner(
153 | `replaceHydrateFunction`,
154 | undefined,
155 | ReactDOM.hydrate
156 | )[0]
157 |
158 | domReady(() => {
159 | renderer(
160 | ,
161 | typeof window !== `undefined`
162 | ? document.getElementById(`___gatsby`)
163 | : void 0,
164 | () => {
165 | apiRunner(`onInitialClientRender`)
166 | }
167 | )
168 | })
169 | })
170 | })
171 |
--------------------------------------------------------------------------------
/.cache/dev-404-page.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import PropTypes from "prop-types"
3 | import { graphql, Link, navigate } from "gatsby"
4 | import queryString from "query-string"
5 |
6 | class Dev404Page extends React.Component {
7 | static propTypes = {
8 | data: PropTypes.object,
9 | custom404: PropTypes.element,
10 | location: PropTypes.object,
11 | }
12 |
13 | constructor(props) {
14 | super(props)
15 | const { data, location } = this.props
16 | const pagePaths = data.allSitePage.nodes.map(node => node.path)
17 | const urlState = queryString.parse(location.search)
18 |
19 | const initialPagePathSearchTerms = urlState.filter ? urlState.filter : ``
20 |
21 | this.state = {
22 | showCustom404: false,
23 | initPagePaths: pagePaths,
24 | pagePathSearchTerms: initialPagePathSearchTerms,
25 | pagePaths: this.getFilteredPagePaths(
26 | pagePaths,
27 | initialPagePathSearchTerms
28 | ),
29 | }
30 | this.showCustom404 = this.showCustom404.bind(this)
31 | this.handlePagePathSearch = this.handlePagePathSearch.bind(this)
32 | this.handleSearchTermChange = this.handleSearchTermChange.bind(this)
33 | }
34 |
35 | showCustom404() {
36 | this.setState({ showCustom404: true })
37 | }
38 |
39 | handleSearchTermChange(event) {
40 | const searchValue = event.target.value
41 |
42 | this.setSearchUrl(searchValue)
43 |
44 | this.setState({
45 | pagePathSearchTerms: searchValue,
46 | })
47 | }
48 |
49 | handlePagePathSearch(event) {
50 | event.preventDefault()
51 | const allPagePaths = [...this.state.initPagePaths]
52 | this.setState({
53 | pagePaths: this.getFilteredPagePaths(
54 | allPagePaths,
55 | this.state.pagePathSearchTerms
56 | ),
57 | })
58 | }
59 |
60 | getFilteredPagePaths(allPagePaths, pagePathSearchTerms) {
61 | const searchTerm = new RegExp(`${pagePathSearchTerms}`)
62 | return allPagePaths.filter(pagePath => searchTerm.test(pagePath))
63 | }
64 |
65 | setSearchUrl(searchValue) {
66 | const {
67 | location: { pathname, search },
68 | } = this.props
69 |
70 | const searchMap = queryString.parse(search)
71 | searchMap.filter = searchValue
72 |
73 | const newSearch = queryString.stringify(searchMap)
74 |
75 | if (search !== `?${newSearch}`) {
76 | navigate(`${pathname}?${newSearch}`, { replace: true })
77 | }
78 | }
79 |
80 | render() {
81 | const { pathname } = this.props.location
82 | let newFilePath
83 | if (pathname === `/`) {
84 | newFilePath = `src/pages/index.js`
85 | } else if (pathname.slice(-1) === `/`) {
86 | newFilePath = `src/pages${pathname.slice(0, -1)}.js`
87 | } else {
88 | newFilePath = `src/pages${pathname}.js`
89 | }
90 |
91 | return this.state.showCustom404 ? (
92 | this.props.custom404
93 | ) : (
94 |
95 |
Gatsby.js development 404 page
96 |
97 | {`There's not a page yet at `}
98 | {pathname}
99 |
100 | {this.props.custom404 ? (
101 |
102 |
105 |
106 | ) : (
107 |
108 | {`A custom 404 page wasn't detected - if you would like to add one, create a component in your site directory at `}
109 | src/pages/404.js.
110 |
111 | )}
112 |
113 | Create a React.js component in your site directory at
114 | {` `}
115 | {newFilePath}
116 | {` `}
117 | and this page will automatically refresh to show the new page
118 | component you created.
119 |