Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve weighting with flex search #302

Merged
merged 9 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions config-overrides.js

This file was deleted.

File renamed without changes.
196 changes: 7 additions & 189 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,191 +1,9 @@
module.exports = {
siteMetadata: {
title: "Toit Documentation",
siteUrl: "https://template.toit.io",
// Put common data you want to reuse in the site here.
},
plugins: [
{
resolve: `gatsby-plugin-typescript`,
options: {
isTSX: true, // defaults to false
jsxPragma: `jsx`, // defaults to "React"
allExtensions: true, // defaults to false
},
},
"gatsby-plugin-typescript",
"gatsby-plugin-typescript-checker",
"gatsby-plugin-eslint",
"gatsby-plugin-material-ui",
"gatsby-plugin-react-helmet",
{
resolve: `gatsby-plugin-svgr-svgo`,
options: {
inlineSvgOptions: [
{
test: /(\.inline\.svg)$/,
svgoConfig: {
plugins: [{ removeViewBox: false }],
},
},
],
urlSvgOptions: [
{
test: /\.svg$/,
svgoConfig: {
plugins: [
{
removeViewBox: false,
},
],
},
},
],
},
},
"gatsby-plugin-sitemap",
{
resolve: "gatsby-plugin-manifest",
options: {
icon: "src/images/icon.svg",
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "pages",
path: `${__dirname}/src/pages/`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "docs",
path: `${__dirname}/docs/`,
},
},
"gatsby-plugin-remove-trailing-slashes",
"gatsby-plugin-layout",
{
resolve: "gatsby-plugin-mdx",
options: {
extensions: [".mdx", ".md"],
defaultLayouts: {
docs: require.resolve("./src/components/layout/MdxLayout.tsx"),
default: require.resolve("./src/components/layout/MdxLayout.tsx"),
},
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-autolink-headers`,
options: {
className: `table-of-contents-icon`,
},
},
],
},
},
// Instructions for this are taken from https://gist.github.com/JohnAlbin/2fc05966624dffb20f4b06b4305280f9

// You can have multiple instances of this plugin to create indexes with
// different names or engines. For example, multi-lingual sites could create
// an index for each language.
{
resolve: "gatsby-plugin-local-search",
options: {
// A unique name for the search index. This should be descriptive of
// what the index contains. This is required.
name: "pages",
// We register the TypeScript evaluator in gatsby-config so we don't need to do
// it in any other .js file. It automatically reads TypeScript config from
// tsconfig.json.
require("ts-node").register();

// Set the search engine to create the index. This is required.
// The following engines are supported: flexsearch, lunr
engine: "flexsearch",

// Provide options to the engine. This is optional and only recommended
// for advanced users.
//
// Note: Only the flexsearch engine supports options.
// engineOptions: "speed",

// GraphQL query used to fetch all data for the search index. This is
// required.
query: `
{
allMdx(filter: { fileAbsolutePath: { regex: "//docs//" } }) {
nodes {
id
slug
excerpt
headings {
value
}
rawBody
}
}
}
`,

// Field used as the reference value for each document.
// Default: 'id'.
ref: "id",

// List of keys to index. The values of the keys are taken from the
// normalizer function below.
// Default: all fields
index: ["title", "body"],

// List of keys to store and make available in your UI. The values of
// the keys are taken from the normalizer function below.
// Default: all fields
store: ["id", "path", "title", "excerpt"],

// Function used to map the result from the GraphQL query. This should
// return an array of items to index in the form of flat objects
// containing properties to index. The objects must contain the `ref`
// field above (default: 'id'). This is required.
normalizer: ({ data }) =>
data.allMdx.nodes.map((node) => {
let path = `/${node.slug}`.replace(/\/$/, "");

return {
id: node.id,
path: path,
title: node.headings[0]?.value ?? "",
body: node.rawBody,
excerpt: node.excerpt,
};
}),
},
},
{
resolve: "gatsby-plugin-segment-js",
options: {
// The keys must be defined otherwise the plugin will no load analytics.js
prodKey: "XXXXXXXXXXXXXXXXX",
devKey: "XXXXXXXXXXXXXXXXX",
manualLoad: true,
trackPage: true,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `@raae/gatsby-remark-oembed`,
options: {
// usePrefix defaults to false
// usePrefix: true is the same as ["oembed"]
usePrefix: ["oembed", "video"],
providers: {
include: ["YouTube"],
// Important to exclude providers
// that adds js to the page.
// If you do not need them.
exclude: ["Reddit", "Twitter", "Flickr", "Instagram"],
},
},
},
],
},
},
],
};
// Use a TypeScript version of gatsby-config.js.
module.exports = require("./gatsby-config.ts");
120 changes: 120 additions & 0 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
export const siteMetadata = {
title: "Toit Documentation",
siteUrl: "https://docs.toit.io",
// Put common data you want to reuse in the site here.
};

export const plugins = [
{
resolve: `gatsby-plugin-typescript`,
options: {
isTSX: true, // defaults to false
jsxPragma: `jsx`, // defaults to "React"
allExtensions: true, // defaults to false
},
},
"gatsby-plugin-typescript",
"gatsby-plugin-typescript-checker",
"gatsby-plugin-eslint",
"gatsby-plugin-material-ui",
"gatsby-plugin-react-helmet",
"gatsby-plugin-emotion",
{
resolve: `gatsby-plugin-svgr-svgo`,
options: {
inlineSvgOptions: [
{
test: /(\.inline\.svg)$/,
svgoConfig: {
plugins: [{ removeViewBox: false }],
},
},
],
urlSvgOptions: [
{
test: /\.svg$/,
svgoConfig: {
plugins: [
{
removeViewBox: false,
},
],
},
},
],
},
},
"gatsby-plugin-sitemap",
{
resolve: "gatsby-plugin-manifest",
options: {
icon: "src/images/icon.svg",
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "pages",
path: `${__dirname}/src/pages/`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "docs",
path: `${__dirname}/docs/`,
},
},
"gatsby-plugin-remove-trailing-slashes",
"gatsby-plugin-layout",
{
resolve: "gatsby-plugin-mdx",
options: {
extensions: [".mdx", ".md"],
defaultLayouts: {
docs: require.resolve("./src/components/layout/MdxLayout.tsx"),
default: require.resolve("./src/components/layout/MdxLayout.tsx"),
},
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-autolink-headers`,
options: {
className: `table-of-contents-icon`,
},
},
],
},
},
{
resolve: "gatsby-plugin-segment-js",
options: {
// The keys must be defined otherwise the plugin will no load analytics.js
prodKey: "XXXXXXXXXXXXXXXXX",
devKey: "XXXXXXXXXXXXXXXXX",
manualLoad: true,
trackPage: true,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `@raae/gatsby-remark-oembed`,
options: {
// usePrefix defaults to false
// usePrefix: true is the same as ["oembed"]
usePrefix: ["oembed", "video"],
providers: {
include: ["YouTube"],
// Important to exclude providers
// that adds js to the page.
// If you do not need them.
exclude: ["Reddit", "Twitter", "Flickr", "Instagram"],
},
},
},
],
},
},
];
69 changes: 0 additions & 69 deletions gatsby-node.js

This file was deleted.

Loading