Skip to content

Commit

Permalink
Merge pull request #69 from opendatasicilia/wip_add_searchbar
Browse files Browse the repository at this point in the history
add searchbar #58
  • Loading branch information
gabacode authored Jan 4, 2022
2 parents 2f830b6 + 5c80da5 commit af5a593
Show file tree
Hide file tree
Showing 11 changed files with 6,073 additions and 14,013 deletions.
3 changes: 2 additions & 1 deletion gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import "bootstrap/dist/css/bootstrap.min.css"
import "bootstrap/dist/css/bootstrap.min.css"
import "./src/styles/main.css"
42 changes: 41 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require("dotenv").config({path: `.env.${process.env.NODE_ENV}`})

module.exports = {
flags: {
PRESERVE_FILE_DOWNLOAD_CACHE: true,
FAST_DEV: true,
},
plugins: [
{
resolve: "gatsby-source-wordpress",
Expand Down Expand Up @@ -30,7 +34,43 @@ module.exports = {
"gatsby-plugin-react-helmet",
"gatsby-transformer-sharp",
"gatsby-plugin-sharp",
"gatsby-plugin-no-sourcemaps"
"gatsby-plugin-no-sourcemaps",
{
resolve: 'gatsby-plugin-local-search',
options: {
name: 'posts',
engine: 'flexsearch',
engineOptions: {
tokenize: 'forward'
},
query: `
{
allWpPost{
nodes {
slug
title
content
author {
node {
name
}
}
}
}
}
`,
ref: 'slug',
index: ['title', 'author', 'content'],
store: ['slug', 'title', 'content', 'author'],
normalizer: ({ data }) =>
data.allWpPost.nodes.map((node) => ({
slug: node.slug,
title: node.title,
content: node.content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '').replace(/<[^>]+>/g, ''),
author: node.author.node.name
})),
},
},
],
};

Loading

0 comments on commit af5a593

Please sign in to comment.