Skip to content

Commit a55cbdb

Browse files
Fix logo link (#1199)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 0b47cc0 commit a55cbdb

File tree

12 files changed

+87
-81
lines changed

12 files changed

+87
-81
lines changed

src/i18n/dictionaries/en/ui.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
export default {
2+
// meta
3+
"meta.title.solid_start": "SolidStart Docs",
4+
"meta.title.solid_router": "Solid Router Docs",
5+
"meta.title.solid_meta": "Solid Meta Docs",
6+
"meta.title.solid": "Solid Docs",
7+
28
// hero
39
"hero.title": "Effortless UIs with Reactive Precision.",
410
"hero.subtitle": "Solid is a modern JavaScript framework for today's web.",

src/i18n/helpers.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import { useLocation } from "@solidjs/router";
2-
import { SUPPORTED_LOCALES } from "./config";
1+
import { useLocation, useMatch } from "@solidjs/router";
32
import { useCurrentRouteMetaData } from "~/utils/route-metadata-helper";
3+
import { SUPPORTED_LOCALES } from "./config";
44

5-
export function getLocaleFromPathname(pathname: string) {
6-
return pathname.split("/")[1];
7-
}
8-
9-
export function isValidLocale(
10-
locale: string
11-
): locale is (typeof SUPPORTED_LOCALES)[number] {
12-
return SUPPORTED_LOCALES.includes(locale);
13-
}
14-
15-
export function getValidLocaleFromPathname(pathname: string) {
16-
const locale = getLocaleFromPathname(pathname);
17-
18-
return isValidLocale(locale) ? locale : null;
5+
export function getCurrentLocale() {
6+
const match = useMatch(() => "/:locale?/*", {
7+
locale: SUPPORTED_LOCALES,
8+
});
9+
return match()?.params.project ?? null;
1910
}
2011

2112
export function getEntryFileName() {

src/i18n/i18n-context.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { useLocation } from "@solidjs/router";
1+
import { useMatch } from "@solidjs/router";
22
import { type JSX, createContext, useContext } from "solid-js";
33
import { createStore } from "solid-js/store";
44
import { createTranslator } from "./translator";
5-
import { getValidLocaleFromPathname } from "./helpers";
5+
import { SUPPORTED_LOCALES } from "./config";
66

77
type ProviderProps = { children: JSX.Element };
88

99
const initialI18nStore = {
1010
get t() {
11-
const { pathname } = useLocation();
12-
const locale = getValidLocaleFromPathname(pathname);
11+
const match = useMatch(() => "/:locale?/*", {
12+
locale: SUPPORTED_LOCALES,
13+
});
1314

14-
return createTranslator(locale);
15+
return createTranslator(match()?.params.project ?? null);
1516
},
1617
};
1718

18-
export const I18nContext =
19-
createContext<typeof initialI18nStore>(initialI18nStore);
19+
export const I18nContext = createContext(initialI18nStore);
2020

2121
export function I18nProvider(props: ProviderProps) {
2222
const [i18n] = createStore(initialI18nStore);

src/solidbase-theme/Layout.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { ErrorBoundary } from "solid-js";
44
import { Layout } from "~/ui/layout";
55
import { NotFound } from "~/ui/not-found";
66
import { I18nProvider } from "~/i18n/i18n-context";
7-
import { Title } from "@solidjs/meta";
87
import { useThemeListener } from "@kobalte/solidbase/client";
98
import { usePace } from "@kobalte/solidbase/default-theme/pace.js";
10-
import { useProjectTitle } from "~/ui/use-project-title";
9+
import { Title } from "@solidjs/meta";
10+
import { useProjectTitle } from "~/ui/use-project";
1111

1212
export default function (props: RouteSectionProps) {
1313
useThemeListener();
1414
usePace();
15-
1615
const projectTitle = useProjectTitle();
1716

1817
return (

src/ui/docs-layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { coreEntries } from "solid:collection";
55
import { Pagination } from "~/ui/pagination";
66
import { EditPageLink } from "./edit-page-link";
77
import { PageIssueLink } from "./page-issue-link";
8-
import { useProjectTitle } from "./use-project-title";
8+
import { useProjectTitle } from "./use-project";
99

1010
interface DocsLayoutProps {
1111
entries: typeof coreEntries;

src/ui/i18n-anchor.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import {
2-
A as RouterAnchor,
3-
useLocation,
4-
type AnchorProps,
5-
} from "@solidjs/router";
1+
import { A as RouterAnchor, type AnchorProps } from "@solidjs/router";
62
import { Match, Switch, splitProps } from "solid-js";
7-
import { getValidLocaleFromPathname, isExternalURL } from "~/i18n/helpers";
3+
import { getCurrentLocale, isExternalURL } from "~/i18n/helpers";
84

95
export type RouterLinkProps = AnchorProps & {
106
addLocale?: boolean;
117
};
128

139
export function A(props: RouterLinkProps) {
14-
const { pathname } = useLocation();
15-
const locale = () => getValidLocaleFromPathname(pathname);
10+
const locale = () => getCurrentLocale();
1611
const external = () => isExternalURL(props.href);
1712

1813
const [_, rest] = splitProps(props, ["addLocale"]);

src/ui/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { query, createAsync, useMatch } from "@solidjs/router";
1818
import { DocsLayout } from "./docs-layout";
1919
import { SidePanel } from "./layout/side-panel";
2020
import { SUPPORTED_LOCALES } from "~/i18n/config";
21-
import { getValidLocaleFromPathname } from "~/i18n/helpers";
21+
import { getCurrentLocale } from "~/i18n/helpers";
2222
import { useCurrentRouteMetaData } from "~/utils/route-metadata-helper";
2323

2424
const PROJECTS = ["solid-router", "solid-start", "solid-meta"] as const;
@@ -72,7 +72,7 @@ const getDocsMetadata = query(
7272

7373
const { path } = (isFirstMatch || isI18nOrProject || isCore) as PathMatch;
7474

75-
const locale = getValidLocaleFromPathname(path);
75+
const locale = getCurrentLocale();
7676
const project = getProjectFromUrl(path);
7777

7878
if (project) {

src/ui/layout/language-selector.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Icon } from "solid-heroicons";
44
import { language } from "solid-heroicons/solid";
55
import { A, useLocation } from "@solidjs/router";
66
import { languages } from "~/i18n/dictionaries";
7-
import { getValidLocaleFromPathname } from "~/i18n/helpers";
7+
import { getCurrentLocale } from "~/i18n/helpers";
88

99
const getLocalizedPath = ({
1010
selectedLanguage,
@@ -30,8 +30,7 @@ const languageEntries = Object.entries(languages);
3030

3131
export const LanguageSelector: Component = () => {
3232
const location = useLocation();
33-
const selectedLanguage =
34-
getValidLocaleFromPathname(location.pathname) ?? "en";
33+
const selectedLanguage = getCurrentLocale() ?? "en";
3534

3635
return (
3736
<DropdownMenu.Root gutter={10}>

src/ui/layout/main-header.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { LanguageSelector } from "./language-selector";
1111

1212
import { useCurrentRouteMetaData } from "~/utils/route-metadata-helper";
1313
import { clientOnly } from "@solidjs/start";
14+
import { useProject } from "~/ui/use-project";
1415

1516
const ClientSearch = clientOnly(() =>
1617
import("../search").then((m) => ({ default: m.Search }))
@@ -33,9 +34,7 @@ interface NavProps {
3334

3435
export function MainHeader(props: NavProps) {
3536
const [isScrolled, setIsScrolled] = createSignal(false);
36-
const notSolidCore = useMatch(() => "/:project/*", {
37-
project: ["solid-router", "solid-start", "solid-meta"],
38-
});
37+
const project = useProject();
3938
const translatedLocale = useMatch(() => "/:locale/:project/*", {
4039
locale: SUPPORTED_LOCALES,
4140
project: ["solid-router", "solid-start", "solid-meta"],
@@ -60,6 +59,19 @@ export function MainHeader(props: NavProps) {
6059
return useCurrentRouteMetaData();
6160
});
6261

62+
const homePageUrl = createMemo(() => {
63+
switch (project()) {
64+
case "solid-start":
65+
return "/solid-start";
66+
case "solid-router":
67+
return "/solid-router";
68+
case "solid-meta":
69+
return "/solid-meta";
70+
default:
71+
return "/";
72+
}
73+
});
74+
6375
return (
6476
<header
6577
class="sticky top-0 z-50 flex items-center justify-between bg-blue-50/80 shadow-md shadow-slate-900/5 transition duration-500 dark:shadow-none backdrop-blur"
@@ -74,7 +86,7 @@ export function MainHeader(props: NavProps) {
7486
<div class="flex lg:hidden">
7587
<MobileNavigation tree={props.tree} />
7688
</div>
77-
<A href="/" aria-label="Home page" addLocale>
89+
<A href={homePageUrl()} aria-label="Home page" addLocale>
7890
<Logo class="h-9" />
7991
</A>
8092
</div>
@@ -86,7 +98,7 @@ export function MainHeader(props: NavProps) {
8698
class="text-slate-900 dark:text-slate-200 relative overflow-hidden drop-shadow-[0_35px_35px_rgba(1,1,1,1.75)] px-2"
8799
classList={{
88100
"border-b-2 border-b-blue-500 dark:bottom-b-blue-500 transition-all duration-250":
89-
!notSolidCore() && !translatedLocale(),
101+
project() === "solid" && !translatedLocale(),
90102
}}
91103
addLocale
92104
>

src/ui/not-found.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Title } from "@solidjs/meta";
22
import { Layout } from "./layout";
33
import { HttpStatusCode } from "@solidjs/start";
44
import { A } from "~/ui/i18n-anchor";
5-
import { useProjectTitle } from "./use-project-title";
5+
import { useProjectTitle } from "./use-project";
66

77
export function NotFound() {
88
const projectTitle = useProjectTitle();

0 commit comments

Comments
 (0)