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

feat(search)!: Remove tag-based search #242

Merged
merged 23 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da1b8ce
Implement new search UI
half0wl Apr 20, 2023
d07b7a7
Move "no results" into its own component
half0wl Apr 24, 2023
8020723
re-lock dependencies
half0wl Apr 24, 2023
bb09a55
Refactor: Move search logic into reusable hooks
half0wl Apr 24, 2023
0583ee8
Refactor: clean up, combine useSearchIndex
half0wl Apr 24, 2023
eec4afc
Refactor: Separate QueryInput, add ability to clear results
half0wl Apr 24, 2023
0eb5515
Cleanup
half0wl Apr 24, 2023
c5f4e0e
Tweak UI
half0wl Apr 24, 2023
3e4a77c
Cleanup: Remove unused types
half0wl Apr 24, 2023
7b26140
feat(search)!: Remove old tag-based search
half0wl Apr 24, 2023
011bdc4
Move searchParams out; lower debounce ms
half0wl Apr 24, 2023
3a36133
UI: Make "Clear" button smaller
half0wl Apr 24, 2023
035fc9a
Remove OpenSearchModalButton from mobile nav
half0wl Apr 24, 2023
fc48cae
Revert "Remove OpenSearchModalButton from mobile nav"
half0wl Apr 24, 2023
9f2ab5d
cleanup
half0wl Apr 24, 2023
e258fdb
Merge branch 'feat/new-search-ui' into feat/remove-old-search
half0wl Apr 24, 2023
5f05d07
Refactor to a generic response transformation method
half0wl Apr 24, 2023
c016b15
Remove redundant `Array.from`
half0wl Apr 24, 2023
82a2878
Remove baseUri from slug
half0wl Apr 24, 2023
1d7d8e8
fix: close modal on result click
half0wl Apr 24, 2023
e6494c8
Merge branch 'main' into feat/new-search-ui
half0wl Apr 25, 2023
1b9e9a2
Merge branch 'feat/new-search-ui' into feat/remove-old-search
half0wl Apr 25, 2023
d4d51dc
Merge branch 'main' into feat/remove-old-search
half0wl Apr 25, 2023
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"copy-to-clipboard": "^3.3.1",
"dayjs": "^1.10.4",
"fathom-client": "^3.1.0",
"fuse.js": "^6.4.6",
"interweave": "^13.1.0",
"meilisearch": "^0.32.3",
"nanostores": "^0.7.4",
Expand Down
151 changes: 40 additions & 111 deletions src/data/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { IPage, ISidebarContent } from "../types";

const makePage = (
title: string,
category?: string,
tags?: string[],
slug?: string,
): IPage => ({
const makePage = (title: string, category?: string, slug?: string): IPage => ({
title,
tags,
category,
slug:
slug ??
Expand All @@ -21,138 +15,73 @@ export const sidebarContent: ISidebarContent = [
{
title: "",
pages: [
makePage("Introduction", undefined, ["home", "railway", "index"], "/"),
makePage("Getting Started", undefined, [
"introduction",
"tutorial",
"getting started",
]),
makePage("Introduction", undefined, "/"),
makePage("Getting Started", undefined),
],
},
{
title: "Develop",
pages: [
makePage("Projects", "develop", [
"project",
"dashboard",
"canvas",
"invite",
]),
makePage("Services", "develop", [
"services",
"monorepo",
"repo",
"domains",
"databases",
]),
makePage("CLI", "develop", ["CLI", "command", "line"]),
makePage("Variables", "develop", ["railway run", "variables"]),
makePage("Environments", "develop", [
"staging",
"create env",
"environment",
]),
makePage("Projects", "develop"),
makePage("Services", "develop"),
makePage("CLI", "develop"),
makePage("Variables", "develop"),
makePage("Environments", "develop"),
],
},
{
title: "Deploy",
pages: [
makePage("Railway Up", "deploy", [
"deploying from command line",
"live",
"deploy",
"up",
]),
makePage("Builds", "deploy", [
"builds",
"procfile",
"buildpacks",
"heroku",
"paketo",
"nixpacks",
]),
makePage("Deployments", "deploy", ["logs", "singleton", "rollback"]),
makePage("Healthchecks", "deploy", ["health", "healthcheck"]),
makePage("Dockerfiles", "deploy", ["docker, compose"]),
makePage("Exposing Your App", "deploy", [
"port",
"bad gateway",
"internet",
"custom domain",
"cloudflare",
]),
makePage("Networking", "deploy", ["domain", "dns", "cname", "private"]),
makePage("Monorepo", "deploy", ["start command", "yarn workspace"]),
makePage("Integrations", "deploy", [
"vercel",
"netlify",
"project tokens",
"ci",
"continuous integration",
"aws",
"gcp",
"azure",
"digital ocean",
"doppler",
]),
makePage("Config as Code", "deploy", ["CaC", "IaC", "service", "config"]),
makePage("Deploy on Railway Button", "deploy", ["button", "badge"]),
makePage("Railway Up", "deploy"),
makePage("Builds", "deploy"),
makePage("Deployments", "deploy"),
makePage("Healthchecks", "deploy"),
makePage("Dockerfiles", "deploy"),
makePage("Exposing Your App", "deploy"),
makePage("Networking", "deploy"),
makePage("Monorepo", "deploy"),
makePage("Integrations", "deploy"),
makePage("Config as Code", "deploy"),
makePage("Deploy on Railway Button", "deploy"),
],
},
{
title: "Diagnose",
pages: [
makePage("Metrics", "diagnose", ["metrics", "logs"]),
makePage("Webhooks", "diagnose", ["webhooks", "notifcations"]),
makePage("Project Usage", "diagnose", ["usage", "pricing"]),
makePage("Metrics", "diagnose"),
makePage("Webhooks", "diagnose"),
makePage("Project Usage", "diagnose"),
],
},
{
title: "Databases",
pages: [
makePage("Database View", "databases", [
"management view",
"plugin view",
"create table",
]),
makePage("PostgreSQL", "databases", ["database", "sql"]),
makePage("MySQL", "databases", ["database", "sql"]),
makePage("Redis", "databases", ["key", "value", "store", "cache"]),
makePage("MongoDB", "databases", ["database", "nosql"]),
makePage("Database View", "databases"),
makePage("PostgreSQL", "databases"),
makePage("MySQL", "databases"),
makePage("Redis", "databases"),
makePage("MongoDB", "databases"),
],
},
{
title: "Troubleshoot",
pages: [
makePage("Fixing Common Errors", "troubleshoot", [
"error",
"errors",
"railway error",
"railway errors",
"application error",
"failed to respond",
"application failed to respond",
"503",
"service unavailable",
"503 service unavailable",
]),
],
pages: [makePage("Fixing Common Errors", "troubleshoot")],
},
{
title: "Reference",
pages: [
makePage("Pricing", "reference", ["pricing"]),
makePage("Plans", "reference", ["limits", "plans"]),
makePage("Accounts", "reference", ["accounts"]),
makePage("Teams", "reference", ["teams"]),
makePage("CLI API", "reference", ["cli"]),
makePage("Public API", "reference", ["api"]),
makePage("Templates", "reference", ["templates"]),
makePage("Guides", "reference", ["guides"]),
makePage("Usecases", "reference", ["usecases"]),
makePage("Support", "reference", ["support"]),
makePage("Priority Boarding", "reference", ["priority", "boarding"]),
makePage("Compare to Heroku", "reference", ["heroku", "vs"]),
makePage("Pricing", "reference"),
makePage("Plans", "reference"),
makePage("Accounts", "reference"),
makePage("Teams", "reference"),
makePage("CLI API", "reference"),
makePage("Public API", "reference"),
makePage("Templates", "reference"),
makePage("Guides", "reference"),
makePage("Usecases", "reference"),
makePage("Support", "reference"),
makePage("Priority Boarding", "reference"),
makePage("Compare to Heroku", "reference"),
],
},
];
20 changes: 4 additions & 16 deletions src/layouts/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Modal } from "@/components/Modal";
import { SearchModal } from "@/components/Search";
import { searchStore } from "@/store";
import { useStore } from "@nanostores/react";
import Fuse from "fuse.js";
import React, { PropsWithChildren, useEffect, useMemo } from "react";
import React, { PropsWithChildren, useEffect } from "react";
import tinykeys from "tinykeys";
import "twin.macro";
import { Modal } from "@/components/Modal";
import { MobileNav, Nav } from "../components/Nav";
import { SearchModal } from "@/components/Search";
import { Props as SEOProps, SEO } from "../components/SEO";
import { Sidebar } from "../components/Sidebar";
import { sidebarContent } from "../data/sidebar";
import { Background } from "../pages";
import { searchStore } from "@/store";

export interface Props {
seo?: SEOProps;
Expand All @@ -30,16 +28,6 @@ export const Page: React.FC<PropsWithChildren<Props>> = props => {
return () => unsubscribe();
}, [isSearchOpen]);

const fuse = useMemo(() => {
const pages = sidebarContent.map(section => section.pages).flat();
const fuse = new Fuse(pages, {
keys: ["title", "tags", "category"],
includeScore: true,
});

return fuse;
}, [sidebarContent]);

return (
<>
<SEO {...props.seo} />
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface IPage {
title: string;
slug: string;
category?: string;
tags?: string[];
}

export interface ISidebarSection {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2884,11 +2884,6 @@ function-bind@^1.1.1:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==

fuse.js@^6.4.6:
version "6.6.2"
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.6.2.tgz#fe463fed4b98c0226ac3da2856a415576dc9a111"
integrity sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==

get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
Expand Down