@levino/shipyard-base 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  ---
2
- import type { Config } from "../../schemas/config";
2
+ import type { Config } from "../../src/schemas/config";
3
3
  import { cn } from "../../src/tools/cn";
4
4
 
5
5
  type Props = Pick<Config, "brand" | "navigation"> & { showBrand: boolean };
@@ -1,11 +1,15 @@
1
1
  ---
2
2
  import { Footer as FooterComponent } from "../components";
3
+ import config from "virtual:shipyard/config";
3
4
 
4
- const locale = Astro.currentLocale;
5
+ const locale = Astro.currentLocale || config.defaultLocale;
6
+
7
+ const withLocale = (path: string) =>
8
+ locale === config.defaultLocale ? path : `/${locale}${path}`;
5
9
  ---
6
10
 
7
11
  <FooterComponent
8
- links={[{ href: `/${locale}/imprint`, label: "Impressum" }]}
12
+ links={[{ href: withLocale("/imprint"), label: "Impressum" }]}
9
13
  copyright={{
10
14
  href: "https://github.com/levino",
11
15
  label: "Levin Keller",
@@ -18,16 +18,16 @@ type Props = {
18
18
  sidebarNavigation?: NavigationTree;
19
19
  };
20
20
 
21
- const locale = Astro.currentLocale || "de";
21
+ const currentLocale = Astro.currentLocale || config.defaultLocale;
22
22
  const currentPath = Astro.url.pathname;
23
23
  const props = Astro.props.frontmatter || Astro.props;
24
24
 
25
- const withLocale = (locale: string) => (path: string) => `/${locale}${path}`;
26
- const withCurrentLocale = withLocale(locale);
25
+ const withLocale = (path: string) =>
26
+ currentLocale === config.defaultLocale ? path : `/${currentLocale}${path}`;
27
27
  const applyLocaleAndSetActive: (navigation: NavigationTree) => NavigationTree =
28
28
  mapObjIndexed((entry: NavigationEntry) => ({
29
29
  ...entry,
30
- ...(entry.href ? { href: withCurrentLocale(entry.href) } : {}),
30
+ ...(entry.href ? { href: withLocale(entry.href) } : {}),
31
31
  active: entry.href === currentPath,
32
32
  ...(entry.subEntry
33
33
  ? { subEntry: applyLocaleAndSetActive(entry.subEntry) }
@@ -35,8 +35,7 @@ const applyLocaleAndSetActive: (navigation: NavigationTree) => NavigationTree =
35
35
  }));
36
36
 
37
37
  const navigation = applyLocaleAndSetActive(config.navigation);
38
- const title = `${config.title} - ${props.title}`
39
-
38
+ const title = `${config.title} - ${props.title}`;
40
39
  ---
41
40
 
42
41
  <html>
@@ -44,9 +43,7 @@ const title = `${config.title} - ${props.title}`
44
43
  <meta charset="utf-8" />
45
44
  <link rel="sitemap" href="/sitemap-index.xml" />
46
45
  <title>
47
- {
48
- title
49
- }
46
+ {title}
50
47
  </title>
51
48
  <meta name="viewport" content="width=device-width, initial-scale=1" />
52
49
  <meta name="description" content={props.description} />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levino/shipyard-base",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {