Skip to content

Commit ca8e47f

Browse files
authored
Merge pull request #2869 from hpe-dev-incubator/fix_external_blog_issue
Fix external blog issue
2 parents a1b1cbb + 56676ef commit ca8e47f

File tree

4 files changed

+337
-178
lines changed

4 files changed

+337
-178
lines changed

gatsby-config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ module.exports = {
543543
{ name: 'path', store: true },
544544
{ name: 'sourceInstanceName', store: true },
545545
{ name: 'author', store: true },
546+
{name: 'externalLink',store:true}
546547
],
547548
filterNodes: (node) => !!node.frontmatter,
548549
// How to resolve each field's value for a supported node type
@@ -565,6 +566,7 @@ module.exports = {
565566
)}`,
566567
sourceInstanceName: (node) => node.fields.sourceInstanceName,
567568
author: (node) => node.frontmatter.author,
569+
externalLink:(node)=> node.frontmatter.externalLink
568570
},
569571
},
570572
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"babel-plugin-styled-components": "^2.1.4",
1616
"dotenv": "^16.3.1",
1717
"formik": "^2.4.5",
18-
"gatsby": "5.12.11",
18+
"gatsby": "^5.14.1",
1919
"gatsby-cli": "^5.12.4",
2020
"gatsby-image": "^3.11.0",
2121
"gatsby-legacy-polyfills": "^3.12.0",

src/containers/SearchContainer/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ const Results = ({ searchTerm, results }) => {
2727
<Box pad={{ bottom: 'medium' }} border={{ side: 'bottom' }} key={index}>
2828
<Text size="small">{categoryLabel(doc.sourceInstanceName)}</Text>
2929
{doc && doc.sourceInstanceName !== 'platforms' ? (
30-
<Link to={`/${doc.path}`}>
30+
<Link to={doc.externalLink ? doc.externalLink : `/${doc.path}`}>
3131
<HighlightedText content={doc.title} positions={titlePos} />
3232
</Link>
33-
) : (
34-
<Link to={doc.path}>
33+
) : (
34+
<Link to={doc.externalLink ? doc.externalLink : doc.path}>
3535
<HighlightedText content={doc.title} positions={titlePos} />
3636
</Link>
3737
)}
@@ -63,6 +63,7 @@ Results.propTypes = {
6363
tags: PropTypes.string,
6464
sourceInstanceName: PropTypes.string,
6565
path: PropTypes.string,
66+
externalLink:PropTypes.string
6667
}),
6768
titlePos: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number))
6869
.isRequired,
@@ -118,7 +119,6 @@ const getSearchResults = async (query) => {
118119
const queryResults =
119120
(await window.__LUNR__.__loaded) &&
120121
window.__LUNR__.en.index.search(query);
121-
122122
searchResults = queryResults.map((searchResult) => {
123123
const doc = window.__LUNR__.en.store[searchResult.ref];
124124
categoryMap[doc.sourceInstanceName] = true;
@@ -161,7 +161,6 @@ const SearchContainer = ({ location }) => {
161161
const onChange = (event) => {
162162
const { value: newValue } = event.target;
163163
setValue(newValue);
164-
165164
// update the URL
166165
const query = newValue ? `?term=${encodeURIComponent(newValue)}` : '';
167166
navigate(`/search/${query}`, { replace: true });

0 commit comments

Comments
 (0)