@levino/shipyard-base 0.1.2 → 0.2.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,8 +1,8 @@
1
1
  ---
2
- import type { Config } from '../schemas/config';
3
- import { cn } from '../tools/cn';
2
+ import type { Config } from "../../schemas/config";
3
+ import { cn } from "../../src/tools/cn";
4
4
 
5
- type Props = Pick<Config, 'brand' | 'navigation'> & { showBrand: boolean };
5
+ type Props = Pick<Config, "brand" | "navigation"> & { showBrand: boolean };
6
6
 
7
7
  const { brand, navigation, showBrand = false } = Astro.props as Props;
8
8
  ---
@@ -29,16 +29,15 @@ const { brand, navigation, showBrand = false } = Astro.props as Props;
29
29
  stroke-linecap="round"
30
30
  stroke-linejoin="round"
31
31
  stroke-width="2"
32
- d="M4 6h16M4 12h16M4 18h16"
33
- ></path>
32
+ d="M4 6h16M4 12h16M4 18h16"></path>
34
33
  </svg>
35
34
  </label>
36
35
  </span>
37
36
  <div class="flex-1">
38
37
  <a
39
38
  href="/"
40
- class={cn('btn btn-ghost text-xl', {
41
- 'md:hidden': !showBrand,
39
+ class={cn("btn btn-ghost text-xl", {
40
+ "md:hidden": !showBrand,
42
41
  })}
43
42
  >
44
43
  {brand}
@@ -46,26 +45,28 @@ const { brand, navigation, showBrand = false } = Astro.props as Props;
46
45
  </div>
47
46
  <div class="hidden flex-none lg:flex">
48
47
  <ul class="menu menu-horizontal px-1">
49
- {Object.entries(navigation).map(([key, entry]) =>
50
- entry.subEntry ? (
51
- <li>
52
- <details>
53
- <summary>{entry.label ?? key}</summary>
54
- <ul class="rounded-t-none bg-base-100 p-2">
55
- {Object.entries(entry.subEntry).map(([key, entry]) => (
56
- <li>
57
- <a href={entry.href}>{entry.label ?? key}</a>
58
- </li>
59
- ))}
60
- </ul>
61
- </details>
62
- </li>
63
- ) : (
64
- <li>
65
- <a href={entry.href}>{entry.label ?? key}</a>
66
- </li>
48
+ {
49
+ Object.entries(navigation).map(([key, entry]) =>
50
+ entry.subEntry ? (
51
+ <li>
52
+ <details>
53
+ <summary>{entry.label ?? key}</summary>
54
+ <ul class="rounded-t-none bg-base-100 p-2">
55
+ {Object.entries(entry.subEntry).map(([key, entry]) => (
56
+ <li>
57
+ <a href={entry.href}>{entry.label ?? key}</a>
58
+ </li>
59
+ ))}
60
+ </ul>
61
+ </details>
62
+ </li>
63
+ ) : (
64
+ <li>
65
+ <a href={entry.href}>{entry.label ?? key}</a>
66
+ </li>
67
+ ),
67
68
  )
68
- )}
69
+ }
69
70
  </ul>
70
71
  </div>
71
72
  </div>
@@ -1,6 +1,6 @@
1
1
  ---
2
- import SidebarElement from './SidebarElement.astro';
3
- import { Entry } from './types';
2
+ import SidebarElement from "./SidebarElement.astro";
3
+ import type { Entry } from "./types";
4
4
 
5
5
  interface SidebarProps {
6
6
  entry: Entry;
@@ -0,0 +1,37 @@
1
+ ---
2
+ import { cn } from "../../src/tools/cn";
3
+ import SidebarElement from "./SidebarElement.astro";
4
+ import type { Entry } from "./types";
5
+
6
+ interface Props {
7
+ local: Entry | undefined;
8
+ global: Entry;
9
+ brand: string;
10
+ }
11
+
12
+ const { local, global, brand } = Astro.props;
13
+ ---
14
+
15
+ <ul class={cn("menu min-h-screen w-56 bg-base-100", { "md:hidden": !local })}>
16
+ <div>
17
+ <a href="/" class="btn btn-ghost mb-2 text-xl">
18
+ {brand}
19
+ </a>
20
+ </div>
21
+ <div class="block md:hidden">
22
+ <li>
23
+ {
24
+ local ? (
25
+ <details>
26
+ <summary>Main menu</summary>
27
+ <SidebarElement entry={global} />
28
+ </details>
29
+ ) : (
30
+ <SidebarElement entry={global} />
31
+ )
32
+ }
33
+ </li>
34
+ <div class={cn("divider my-1 block md:hidden", { hidden: !local })}></div>
35
+ </div>
36
+ {local && <SidebarElement entry={local} />}
37
+ </ul>
@@ -14,10 +14,6 @@ const { links } = Astro.props as TableOfContentsProps;
14
14
 
15
15
  <div class="fixed right-0 h-full lg:h-auto lg:overflow-y-visible">
16
16
  <div class="w-128 sticky" aria-label="Auf dieser Seite">
17
- {links.map((link, key) => (
18
- <a href={`#${link.slug}`}>
19
- {link.text}
20
- </a>
21
- ))}
17
+ {links.map((link) => <a href={`#${link.slug}`}>{link.text}</a>)}
22
18
  </div>
23
19
  </div>
@@ -0,0 +1,6 @@
1
+ export { default as Footer } from './Footer.astro'
2
+ export { default as GlobalDesktopNavigation } from './GlobalDesktopNavigation.astro'
3
+ export { default as LocalNavigation } from './LocalNavigation.astro'
4
+ export { default as SidebarElement } from './SidebarElement.astro'
5
+ export { default as SidebarNavigation } from './SidebarNavigation.astro'
6
+ export { default as TableOfContents } from './TableOfContents.astro'
@@ -0,0 +1,9 @@
1
+ export type Entry = Record<
2
+ string,
3
+ {
4
+ label?: string
5
+ href?: string
6
+ subEntry?: Entry
7
+ active?: boolean
8
+ }
9
+ >
@@ -0,0 +1,14 @@
1
+ ---
2
+ import { Footer as FooterComponent } from "../components";
3
+
4
+ const locale = Astro.currentLocale;
5
+ ---
6
+
7
+ <FooterComponent
8
+ links={[{ href: `/${locale}/imprint`, label: "Impressum" }]}
9
+ copyright={{
10
+ href: "https://github.com/levino",
11
+ label: "Levin Keller",
12
+ year: 2023,
13
+ }}
14
+ />
@@ -1,30 +1,29 @@
1
1
  ---
2
- import Footer from './Footer.astro'
3
- import '../globals.css'
4
- import config from 'virtual:shipyard/config'
5
- import GlobalDesktopNavigation from '../components/GlobalDesktopNavigation.astro'
6
- import type { NavigationTree, NavigationEntry } from '../schemas/config'
7
- import { mapObjIndexed } from 'ramda'
8
- import SidebarNavigation from '../components/SidebarNavigation.astro'
2
+ import Footer from "./Footer.astro";
3
+ import "../../src/globals.css";
4
+ import config from "virtual:shipyard/config";
5
+ import { GlobalDesktopNavigation, SidebarNavigation } from "../components";
6
+ import type { NavigationTree, NavigationEntry } from "../../src/schemas/config";
7
+ import { mapObjIndexed } from "ramda";
9
8
 
10
9
  type Props = {
11
10
  frontmatter?: {
12
- title?: string
13
- description?: string
14
- sidebarNavigation?: NavigationTree
15
- }
11
+ title?: string;
12
+ description?: string;
13
+ sidebarNavigation?: NavigationTree;
14
+ };
16
15
  } & {
17
- title?: string
18
- description?: string
19
- sidebarNavigation?: NavigationTree
20
- }
16
+ title?: string;
17
+ description?: string;
18
+ sidebarNavigation?: NavigationTree;
19
+ };
21
20
 
22
- const locale = Astro.currentLocale || 'de'
23
- const currentPath = Astro.url.pathname
24
- const props = Astro.props.frontmatter || Astro.props
21
+ const locale = Astro.currentLocale || "de";
22
+ const currentPath = Astro.url.pathname;
23
+ const props = Astro.props.frontmatter || Astro.props;
25
24
 
26
- const withLocale = (locale: string) => (path: string) => `/${locale}${path}`
27
- const withCurrentLocale = withLocale(locale)
25
+ const withLocale = (locale: string) => (path: string) => `/${locale}${path}`;
26
+ const withCurrentLocale = withLocale(locale);
28
27
  const applyLocaleAndSetActive: (navigation: NavigationTree) => NavigationTree =
29
28
  mapObjIndexed((entry: NavigationEntry) => ({
30
29
  ...entry,
@@ -33,9 +32,11 @@ const applyLocaleAndSetActive: (navigation: NavigationTree) => NavigationTree =
33
32
  ...(entry.subEntry
34
33
  ? { subEntry: applyLocaleAndSetActive(entry.subEntry) }
35
34
  : {}),
36
- }))
35
+ }));
36
+
37
+ const navigation = applyLocaleAndSetActive(config.navigation);
38
+ const title = `${config.title} - ${props.title}`
37
39
 
38
- const navigation = applyLocaleAndSetActive(config.navigation)
39
40
  ---
40
41
 
41
42
  <html>
@@ -44,12 +45,13 @@ const navigation = applyLocaleAndSetActive(config.navigation)
44
45
  <link rel="sitemap" href="/sitemap-index.xml" />
45
46
  <title>
46
47
  {
47
- config.meta.title
48
- ? `Levin Keller - ${config.meta.title}`
49
- : 'Levin Keller'
48
+ title
50
49
  }
51
50
  </title>
52
51
  <meta name="viewport" content="width=device-width, initial-scale=1" />
52
+ <meta name="description" content={props.description} />
53
+ <meta property="og:title" content={title} />
54
+ <meta property="og:description" content={props.description} />
53
55
  </head>
54
56
  <body>
55
57
  <div class="drawer lg:drawer-open">
@@ -0,0 +1,18 @@
1
+ ---
2
+ import type { NavigationTree } from '../../src/schemas/config';
3
+ import Base from './Page.astro'
4
+
5
+ type Props = {
6
+ frontmatter?: {
7
+ title?: string;
8
+ description?: string;
9
+ sidebarNavigation?: NavigationTree;
10
+ };
11
+ }
12
+
13
+ const props = Astro.props
14
+ ---
15
+
16
+ <Base {...props}>
17
+ <div class="prose mx-auto"><slot /></div>
18
+ </Base>
@@ -0,0 +1,3 @@
1
+ export { default as Footer } from './Footer.astro'
2
+ export { default as Page } from './Page.astro'
3
+ export { default as Splash } from './Splash.astro'
package/package.json CHANGED
@@ -1,25 +1,26 @@
1
1
  {
2
2
  "name": "@levino/shipyard-base",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
- "main": "lib/index.js",
5
+ "main": "src/index.ts",
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./astro": "./src/astro.ts",
9
+ "./layouts": "./astro/layouts/index.ts",
10
+ "./layouts/*": "./astro/layouts/*",
11
+ "./components": "./astro/components/index.ts",
12
+ "./components/*": "./astro/components/*"
13
+ },
6
14
  "peerDependencies": {
7
15
  "astro": "^5",
8
16
  "daisyui": "^4",
9
17
  "tailwindcss": "^3",
10
18
  "@tailwindcss/typography": "^0.5.10"
11
19
  },
12
- "scripts": {
13
- "build": "tsc -p tsconfig.build.json && rsync -avm --include='*/' --include='*.astro' --include='*.css' --exclude='*' ./src/ ./lib/",
14
- "prepublishOnly": "npm run build"
15
- },
16
20
  "files": [
17
- "lib"
21
+ "astro",
22
+ "src"
18
23
  ],
19
- "exports": {
20
- ".": "./lib/index.js",
21
- "./*": "./lib/*"
22
- },
23
24
  "devDependencies": {
24
25
  "@tailwindcss/typography": "^0.5.10",
25
26
  "@types/ramda": "^0.29.9",
package/src/astro.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * as components from './astro/components'
2
+ export * as layouts from './astro/layouts'
package/src/index.ts ADDED
@@ -0,0 +1,34 @@
1
+ import type { AstroIntegration } from 'astro'
2
+ import type { Config } from './schemas/config'
3
+ export type { Entry } from '../astro/components/types'
4
+ export * from './types'
5
+ export type * from './schemas/config'
6
+ const shipyardConfigId = 'virtual:shipyard/config'
7
+
8
+ const resolveId: Record<string, string | undefined> = {
9
+ [shipyardConfigId]: `${shipyardConfigId}`,
10
+ }
11
+
12
+ const load = (config: Config) =>
13
+ ({
14
+ [shipyardConfigId]: `export default ${JSON.stringify(config)}`,
15
+ }) as Record<string, string | undefined>
16
+
17
+ export default (config: Config): AstroIntegration => ({
18
+ name: 'shipyard',
19
+ hooks: {
20
+ 'astro:config:setup': ({ updateConfig }) => {
21
+ updateConfig({
22
+ vite: {
23
+ plugins: [
24
+ {
25
+ name: 'shipyard',
26
+ resolveId: (id: string) => resolveId[id],
27
+ load: (id: string) => load(config)[id],
28
+ },
29
+ ],
30
+ },
31
+ })
32
+ },
33
+ },
34
+ })
@@ -0,0 +1,15 @@
1
+ export interface NavigationEntry {
2
+ label?: string
3
+ href?: string
4
+ subEntry?: NavigationTree
5
+ active?: boolean
6
+ }
7
+
8
+ export type NavigationTree = Record<string, NavigationEntry>
9
+
10
+ export type Config = {
11
+ brand: string
12
+ navigation: NavigationTree
13
+ title: string
14
+ tagline: string
15
+ }
@@ -0,0 +1,4 @@
1
+ import clsx, { type ClassValue } from 'clsx'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ export const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes))
package/src/types.ts ADDED
@@ -0,0 +1,34 @@
1
+ export interface LinkData {
2
+ href: string
3
+ label: string
4
+ active: boolean
5
+ }
6
+ export const MONTHS_EN = [
7
+ 'january',
8
+ 'february',
9
+ 'march',
10
+ 'april',
11
+ 'may',
12
+ 'june',
13
+ 'july',
14
+ 'august',
15
+ 'september',
16
+ 'october',
17
+ 'november',
18
+ 'december',
19
+ ] as const
20
+
21
+ export const MONTHS_DE = [
22
+ 'Januar',
23
+ 'Februar',
24
+ 'März',
25
+ 'April',
26
+ 'Mai',
27
+ 'Juni',
28
+ 'Juli',
29
+ 'August',
30
+ 'September',
31
+ 'Oktober',
32
+ 'November',
33
+ 'Dezember',
34
+ ] as const
@@ -1,36 +0,0 @@
1
- ---
2
- import { cn } from '../tools/cn';
3
- import SidebarElement from './SidebarElement.astro';
4
- import type { Entry } from './types';
5
-
6
- interface Props {
7
- local?: Entry;
8
- global: Entry;
9
- brand: string;
10
- }
11
-
12
-
13
- const { local, global, brand } = Astro.props;
14
- ---
15
-
16
- <ul class={cn('menu min-h-screen w-56 bg-base-100', { 'md:hidden': !local })}>
17
- <div>
18
- <a href="/" class="btn btn-ghost mb-2 text-xl">
19
- {brand}
20
- </a>
21
- </div>
22
- <div class="block md:hidden">
23
- <li>
24
- {local ? (
25
- <details>
26
- <summary>Main menu</summary>
27
- <SidebarElement entry={global} />
28
- </details>
29
- ) : (
30
- <SidebarElement entry={global} />
31
- )}
32
- </li>
33
- <div class={cn('divider my-1 block md:hidden', { hidden: !local })} />
34
- </div>
35
- {local && <SidebarElement entry={local} />}
36
- </ul>
@@ -1,6 +0,0 @@
1
- export type Entry = Record<string, {
2
- label?: string;
3
- href?: string;
4
- subEntry?: Entry;
5
- active?: boolean;
6
- }>;
@@ -1 +0,0 @@
1
- export {};
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { AstroIntegration } from 'astro';
2
- import type { Config } from './schemas/config.ts';
3
- export type { Entry } from './components/types.ts';
4
- declare const _default: (config: Config) => AstroIntegration;
5
- export default _default;
package/lib/index.js DELETED
@@ -1,25 +0,0 @@
1
- const shipyardConfigId = 'virtual:shipyard/config';
2
- const resolveId = {
3
- [shipyardConfigId]: `${shipyardConfigId}`,
4
- };
5
- const load = (config) => ({
6
- [shipyardConfigId]: `export default ${JSON.stringify(config)}`,
7
- });
8
- export default (config) => ({
9
- name: 'shipyard',
10
- hooks: {
11
- 'astro:config:setup': ({ updateConfig }) => {
12
- updateConfig({
13
- vite: {
14
- plugins: [
15
- {
16
- name: 'shipyard',
17
- resolveId: (id) => resolveId[id],
18
- load: (id) => load(config)[id],
19
- },
20
- ],
21
- },
22
- });
23
- },
24
- },
25
- });
@@ -1,14 +0,0 @@
1
- ---
2
- import FooterComponent from '@levino/shipyard-base/components/Footer.astro'
3
-
4
- const locale = Astro.currentLocale
5
- ---
6
-
7
- <FooterComponent
8
- links={[{ href: `/${locale}/imprint`, label: 'Impressum' }]}
9
- copyright={{
10
- href: 'https://github.com/levino',
11
- label: 'Levin Keller',
12
- year: 2023,
13
- }}
14
- />
@@ -1,7 +0,0 @@
1
- ---
2
- import Base from './Page.astro'
3
- ---
4
-
5
- <Base>
6
- <div class="prose mx-auto"><slot /></div>
7
- </Base>
@@ -1,15 +0,0 @@
1
- export interface NavigationEntry {
2
- label?: string;
3
- href?: string;
4
- subEntry?: NavigationTree;
5
- active?: boolean;
6
- }
7
- export type NavigationTree = Record<string, NavigationEntry>;
8
- export type Config = {
9
- brand: string;
10
- navigation: NavigationTree;
11
- meta: {
12
- title: string;
13
- description: string;
14
- };
15
- };
@@ -1 +0,0 @@
1
- export {};
package/lib/tools/cn.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type ClassValue } from 'clsx';
2
- export declare const cn: (...classes: ClassValue[]) => string;
package/lib/tools/cn.js DELETED
@@ -1,3 +0,0 @@
1
- import clsx from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
3
- export const cn = (...classes) => twMerge(clsx(...classes));
package/lib/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export interface LinkData {
2
- href: string;
3
- label: string;
4
- active: boolean;
5
- }
6
- export declare const MONTHS_EN: readonly ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
7
- export declare const MONTHS_DE: readonly ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];
package/lib/types.js DELETED
@@ -1,28 +0,0 @@
1
- export const MONTHS_EN = [
2
- 'january',
3
- 'february',
4
- 'march',
5
- 'april',
6
- 'may',
7
- 'june',
8
- 'july',
9
- 'august',
10
- 'september',
11
- 'october',
12
- 'november',
13
- 'december',
14
- ];
15
- export const MONTHS_DE = [
16
- 'Januar',
17
- 'Februar',
18
- 'März',
19
- 'April',
20
- 'Mai',
21
- 'Juni',
22
- 'Juli',
23
- 'August',
24
- 'September',
25
- 'Oktober',
26
- 'November',
27
- 'Dezember',
28
- ];
File without changes
File without changes
File without changes