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-sharp`,
|
||||
`gatsby-plugin-sitemap`,
|
||||
<<<<<<< HEAD
|
||||
`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,
|
||||
>>>>>>> Remove limited sources
|
||||
|
||||
{
|
||||
resolve: `gatsby-source-filesystem`,
|
||||
options: {
|
||||
name: `watcher`,
|
||||
path: `${__dirname}/.cache/gatsby-source-git/`,
|
||||
path: `${__dirname}/.cache/gatsby-source-git/`
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
resolve: 'gatsby-transformer-remark',
|
||||
options: {
|
||||
|
@ -96,22 +41,12 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
},
|
||||
`gatsby-remark-copy-linked-files`,
|
||||
{
|
||||
resolve: `gatsby-remark-images`,
|
||||
options: {
|
||||
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`,
|
||||
<<<<<<< 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,
|
||||
unhideSelf,
|
||||
category,
|
||||
<<<<<<< HEAD
|
||||
...node.frontmatter,
|
||||
=======
|
||||
...frontmatter,
|
||||
>>>>>>> Initial commit of userdocs merge
|
||||
};
|
||||
|
||||
if (!docData.title || docData.title === '') {
|
||||
|
@ -115,16 +111,10 @@ exports.onCreateNode = async ({ node, getNode, getNodesByType, actions, createNo
|
|||
};
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
exports.createPages = async ({ actions, graphql, getNodesByType }) => {
|
||||
const { createPage, createRedirect } = actions;
|
||||
|
||||
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(`
|
||||
{
|
||||
allSilverstripeDocument {
|
||||
|
@ -143,7 +133,7 @@ exports.createPages = async ({ actions, graphql }) => {
|
|||
.forEach(node => {
|
||||
createPage({
|
||||
path: node.slug,
|
||||
component: docsTemplate,
|
||||
component: docTemplate,
|
||||
context: {
|
||||
id: node.id,
|
||||
slug: node.slug,
|
||||
|
|
|
@ -77,20 +77,11 @@ const SEO: StatelessComponent<SEOProps> = ({ description, lang, meta, title }) =
|
|||
{
|
||||
name: `docsearch:version`,
|
||||
content: getCurrentVersion(),
|
||||
<<<<<<< HEAD
|
||||
},
|
||||
{
|
||||
name: `docsearch:context`,
|
||||
content: site.siteMetadata.context,
|
||||
},
|
||||
=======
|
||||
|
||||
},
|
||||
{
|
||||
name: `docsearch:context`,
|
||||
content: process.env.DOCS_CONTEXT,
|
||||
}
|
||||
>>>>>>> Docs/userguide switching
|
||||
].concat(meta)}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react'
|
|||
import { StatelessComponent, ReactElement, useEffect, useState } from 'react';
|
||||
import { navigateTo } from "gatsby-link"
|
||||
import useHierarchy from '../hooks/useHierarchy';
|
||||
import { useStaticQuery, graphql } from 'gatsby';
|
||||
|
||||
interface SearchBoxProps {
|
||||
identifier: string;
|
||||
|
@ -19,6 +20,16 @@ const autocompleteSelected = (e) => {
|
|||
const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactElement|null => {
|
||||
const { getCurrentVersion } = useHierarchy();
|
||||
const [ isFocused, setFocus ] = useState(false);
|
||||
const { site } = useStaticQuery(graphql`
|
||||
query {
|
||||
site {
|
||||
siteMetadata {
|
||||
context
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
if (!process.env.GATSBY_DOCSEARCH_API_KEY) {
|
||||
|
@ -34,7 +45,7 @@ const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactEle
|
|||
algoliaOptions: {
|
||||
facetFilters: [
|
||||
`version:${getCurrentVersion()}`,
|
||||
`context:${process.env.DOCS_CONTEXT}`,
|
||||
//`context:${site.siteMetadata.context}`,
|
||||
],
|
||||
hitsPerPage: 5,
|
||||
},
|
||||
|
@ -48,7 +59,11 @@ const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactEle
|
|||
}, []);
|
||||
|
||||
const handleFocus = () => setFocus(true);
|
||||
const handleBlur = () => setFocus(false);
|
||||
const handleBlur = (e) => {
|
||||
if (!e.target.value.trim()) {
|
||||
setFocus(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -21,41 +21,7 @@ const initialise = (nodes: SilverstripeDocument[]) => __nodes = nodes;
|
|||
/**
|
||||
* 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;
|
||||
>>>>>>> Docs/userguide switching
|
||||
|
||||
/**
|
||||
* Get the children of a given node
|
||||
|
@ -163,12 +129,9 @@ const getHomePage = (): SilverstripeDocument | null => {
|
|||
const nodes = getNodes();
|
||||
const version = getCurrentVersion();
|
||||
let slug = `/en/${version}/`;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (homeMap.has(slug)) {
|
||||
return homeMap.get(slug) || null;
|
||||
}
|
||||
>>>>>>> Initial commit of userdocs merge
|
||||
const homePage = nodes.find(n => n.slug === slug) || null;
|
||||
homeMap.set(slug, homePage);
|
||||
|
||||
|
@ -181,13 +144,8 @@ const getHomePage = (): SilverstripeDocument | null => {
|
|||
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
|
||||
* @param slug
|
||||
>>>>>>> Initial commit of userdocs merge
|
||||
*/
|
||||
const setCurrentPath = (path: string) => {
|
||||
__path = path || `/`;
|
||||
|
|
Loading…
Reference in New Issue