Tweaks to search bar, clean up conflicts
This commit is contained in:
parent
31220c277b
commit
e93af9e168
|
@ -16,72 +16,17 @@ module.exports = {
|
||||||
`gatsby-plugin-sass`,
|
`gatsby-plugin-sass`,
|
||||||
`gatsby-plugin-sharp`,
|
`gatsby-plugin-sharp`,
|
||||||
`gatsby-plugin-sitemap`,
|
`gatsby-plugin-sitemap`,
|
||||||
<<<<<<< HEAD
|
|
||||||
`gatsby-plugin-netlify`,
|
`gatsby-plugin-netlify`,
|
||||||
{
|
|
||||||
resolve: `gatsby-source-git`,
|
|
||||||
options: {
|
|
||||||
<<<<<<< HEAD
|
|
||||||
name: `4`,
|
|
||||||
remote: `https://github.com/silverstripe/silverstripe-framework.git`,
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
name: `docs--4`,
|
|
||||||
remote: `/Users/acarlino/Sites/gatsby-docs-4`,
|
|
||||||
>>>>>>> Docs/userguide switching
|
|
||||||
=======
|
|
||||||
>>>>>>> UX improvements per Paul design
|
|
||||||
branch: `4`,
|
|
||||||
patterns: `docs/en/**`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-git`,
|
|
||||||
options: {
|
|
||||||
name: `docs--3`,
|
|
||||||
remote: `https://github.com/silverstripe/silverstripe-framework.git`,
|
|
||||||
branch: `3.7`,
|
|
||||||
patterns: `docs/en/**`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-git`,
|
|
||||||
options: {
|
|
||||||
name: `user--4`,
|
|
||||||
remote: `https://github.com/silverstripe/silverstripe-userhelp-content.git`,
|
|
||||||
branch: `4`,
|
|
||||||
patterns: `docs/en/**`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-git`,
|
|
||||||
options: {
|
|
||||||
name: `user--3`,
|
|
||||||
remote: `https://github.com/silverstripe/silverstripe-userhelp-content.git`,
|
|
||||||
branch: `3`,
|
|
||||||
patterns: `docs/en/**`
|
|
||||||
}
|
|
||||||
<<<<<<< HEAD
|
|
||||||
},
|
|
||||||
=======
|
|
||||||
},
|
|
||||||
// ...userhelpImports
|
|
||||||
>>>>>>> Docs/userguide switching
|
|
||||||
=======
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
...sources.slice(0, 4),
|
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
=======
|
|
||||||
...sources,
|
...sources,
|
||||||
>>>>>>> Remove limited sources
|
|
||||||
{
|
{
|
||||||
resolve: `gatsby-source-filesystem`,
|
resolve: `gatsby-source-filesystem`,
|
||||||
options: {
|
options: {
|
||||||
name: `watcher`,
|
name: `watcher`,
|
||||||
path: `${__dirname}/.cache/gatsby-source-git/`,
|
path: `${__dirname}/.cache/gatsby-source-git/`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
resolve: 'gatsby-transformer-remark',
|
resolve: 'gatsby-transformer-remark',
|
||||||
options: {
|
options: {
|
||||||
|
@ -96,22 +41,12 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
`gatsby-remark-copy-linked-files`,
|
||||||
{
|
{
|
||||||
resolve: `gatsby-remark-images`,
|
resolve: `gatsby-remark-images`,
|
||||||
options: {
|
options: {
|
||||||
maxWidth: 850,
|
maxWidth: 850,
|
||||||
linkImagesToOriginal: false,
|
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-remark-copy-linked-files`,
|
|
||||||
options: {
|
|
||||||
// Links to markdown files should be considered links to pages, not downloads.
|
|
||||||
ignoreFileExtensions: [`md`],
|
|
||||||
}
|
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -170,14 +105,5 @@ 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
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,7 @@ exports.onCreateNode = async ({ node, getNode, getNodesByType, actions, createNo
|
||||||
parentSlug,
|
parentSlug,
|
||||||
unhideSelf,
|
unhideSelf,
|
||||||
category,
|
category,
|
||||||
<<<<<<< HEAD
|
|
||||||
...node.frontmatter,
|
|
||||||
=======
|
|
||||||
...frontmatter,
|
...frontmatter,
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!docData.title || docData.title === '') {
|
if (!docData.title || docData.title === '') {
|
||||||
|
@ -115,16 +111,10 @@ exports.onCreateNode = async ({ node, getNode, getNodesByType, actions, createNo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
exports.createPages = async ({ actions, graphql, getNodesByType }) => {
|
exports.createPages = async ({ actions, graphql, getNodesByType }) => {
|
||||||
const { createPage, createRedirect } = actions;
|
const { createPage, createRedirect } = actions;
|
||||||
|
|
||||||
const docTemplate = path.resolve(`src/templates/docs-template.tsx`);
|
const docTemplate = path.resolve(`src/templates/docs-template.tsx`);
|
||||||
=======
|
|
||||||
exports.createPages = async ({ actions, graphql }) => {
|
|
||||||
const { createPage } = actions;
|
|
||||||
const docsTemplate = path.resolve(`src/templates/docs-template.tsx`)
|
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
const result = await graphql(`
|
const result = await graphql(`
|
||||||
{
|
{
|
||||||
allSilverstripeDocument {
|
allSilverstripeDocument {
|
||||||
|
@ -143,7 +133,7 @@ exports.createPages = async ({ actions, graphql }) => {
|
||||||
.forEach(node => {
|
.forEach(node => {
|
||||||
createPage({
|
createPage({
|
||||||
path: node.slug,
|
path: node.slug,
|
||||||
component: docsTemplate,
|
component: docTemplate,
|
||||||
context: {
|
context: {
|
||||||
id: node.id,
|
id: node.id,
|
||||||
slug: node.slug,
|
slug: node.slug,
|
||||||
|
|
|
@ -77,20 +77,11 @@ const SEO: StatelessComponent<SEOProps> = ({ description, lang, meta, title }) =
|
||||||
{
|
{
|
||||||
name: `docsearch:version`,
|
name: `docsearch:version`,
|
||||||
content: getCurrentVersion(),
|
content: getCurrentVersion(),
|
||||||
<<<<<<< HEAD
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `docsearch:context`,
|
name: `docsearch:context`,
|
||||||
content: site.siteMetadata.context,
|
content: site.siteMetadata.context,
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: `docsearch:context`,
|
|
||||||
content: process.env.DOCS_CONTEXT,
|
|
||||||
}
|
|
||||||
>>>>>>> Docs/userguide switching
|
|
||||||
].concat(meta)}
|
].concat(meta)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react'
|
||||||
import { StatelessComponent, ReactElement, useEffect, useState } from 'react';
|
import { StatelessComponent, ReactElement, useEffect, useState } from 'react';
|
||||||
import { navigateTo } from "gatsby-link"
|
import { navigateTo } from "gatsby-link"
|
||||||
import useHierarchy from '../hooks/useHierarchy';
|
import useHierarchy from '../hooks/useHierarchy';
|
||||||
|
import { useStaticQuery, graphql } from 'gatsby';
|
||||||
|
|
||||||
interface SearchBoxProps {
|
interface SearchBoxProps {
|
||||||
identifier: string;
|
identifier: string;
|
||||||
|
@ -19,6 +20,16 @@ const autocompleteSelected = (e) => {
|
||||||
const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactElement|null => {
|
const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactElement|null => {
|
||||||
const { getCurrentVersion } = useHierarchy();
|
const { getCurrentVersion } = useHierarchy();
|
||||||
const [ isFocused, setFocus ] = useState(false);
|
const [ isFocused, setFocus ] = useState(false);
|
||||||
|
const { site } = useStaticQuery(graphql`
|
||||||
|
query {
|
||||||
|
site {
|
||||||
|
siteMetadata {
|
||||||
|
context
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window === 'undefined') return;
|
if (typeof window === 'undefined') return;
|
||||||
if (!process.env.GATSBY_DOCSEARCH_API_KEY) {
|
if (!process.env.GATSBY_DOCSEARCH_API_KEY) {
|
||||||
|
@ -34,7 +45,7 @@ const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactEle
|
||||||
algoliaOptions: {
|
algoliaOptions: {
|
||||||
facetFilters: [
|
facetFilters: [
|
||||||
`version:${getCurrentVersion()}`,
|
`version:${getCurrentVersion()}`,
|
||||||
`context:${process.env.DOCS_CONTEXT}`,
|
//`context:${site.siteMetadata.context}`,
|
||||||
],
|
],
|
||||||
hitsPerPage: 5,
|
hitsPerPage: 5,
|
||||||
},
|
},
|
||||||
|
@ -48,7 +59,11 @@ const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactEle
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleFocus = () => setFocus(true);
|
const handleFocus = () => setFocus(true);
|
||||||
const handleBlur = () => setFocus(false);
|
const handleBlur = (e) => {
|
||||||
|
if (!e.target.value.trim()) {
|
||||||
|
setFocus(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -21,41 +21,7 @@ const initialise = (nodes: SilverstripeDocument[]) => __nodes = nodes;
|
||||||
/**
|
/**
|
||||||
* Get all documents in the source
|
* Get all documents in the source
|
||||||
*/
|
*/
|
||||||
<<<<<<< HEAD
|
|
||||||
const getNodes = (): SilverstripeDocument[] => {
|
|
||||||
if (__nodes) {
|
|
||||||
return __nodes;
|
|
||||||
}
|
|
||||||
const result:HierarchyQuery = useStaticQuery(graphql`
|
|
||||||
{
|
|
||||||
allSilverstripeDocument {
|
|
||||||
nodes {
|
|
||||||
title
|
|
||||||
summary
|
|
||||||
isIndex
|
|
||||||
introduction
|
|
||||||
icon
|
|
||||||
iconBrand
|
|
||||||
hideChildren
|
|
||||||
unhideSelf
|
|
||||||
slug
|
|
||||||
parentSlug
|
|
||||||
fileTitle
|
|
||||||
fileAbsolutePath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
);
|
|
||||||
__nodes = result.allSilverstripeDocument.nodes.map(node => ({
|
|
||||||
...node,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return __nodes;
|
|
||||||
};
|
|
||||||
=======
|
|
||||||
const getNodes = (): SilverstripeDocument[] => __nodes;
|
const getNodes = (): SilverstripeDocument[] => __nodes;
|
||||||
>>>>>>> Docs/userguide switching
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the children of a given node
|
* Get the children of a given node
|
||||||
|
@ -163,12 +129,9 @@ const getHomePage = (): SilverstripeDocument | null => {
|
||||||
const nodes = getNodes();
|
const nodes = getNodes();
|
||||||
const version = getCurrentVersion();
|
const version = getCurrentVersion();
|
||||||
let slug = `/en/${version}/`;
|
let slug = `/en/${version}/`;
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
if (homeMap.has(slug)) {
|
if (homeMap.has(slug)) {
|
||||||
return homeMap.get(slug) || null;
|
return homeMap.get(slug) || null;
|
||||||
}
|
}
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
const homePage = nodes.find(n => n.slug === slug) || null;
|
const homePage = nodes.find(n => n.slug === slug) || null;
|
||||||
homeMap.set(slug, homePage);
|
homeMap.set(slug, homePage);
|
||||||
|
|
||||||
|
@ -181,13 +144,8 @@ const getHomePage = (): SilverstripeDocument | null => {
|
||||||
const getCurrentVersion = (): string => __currentVersion || '4';
|
const getCurrentVersion = (): string => __currentVersion || '4';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
<<<<<<< HEAD
|
|
||||||
* Set the current node by its slug.
|
|
||||||
* @param slug
|
|
||||||
=======
|
|
||||||
* Set the current path, with some side effects for version
|
* Set the current path, with some side effects for version
|
||||||
* @param slug
|
* @param slug
|
||||||
>>>>>>> Initial commit of userdocs merge
|
|
||||||
*/
|
*/
|
||||||
const setCurrentPath = (path: string) => {
|
const setCurrentPath = (path: string) => {
|
||||||
__path = path || `/`;
|
__path = path || `/`;
|
||||||
|
|
Loading…
Reference in New Issue