lightnet 3.2.0 → 3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # lightnet
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#252](https://github.com/LightNetDev/LightNet/pull/252) [`9573e88`](https://github.com/LightNetDev/LightNet/commit/9573e88515f66ade87cb187b59abba498527c693) Thanks [@smn-cds](https://github.com/smn-cds)! - Add config logo option `replacesTitle`. This will hide the title from the header bar.
8
+
9
+ ## 3.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#250](https://github.com/LightNetDev/LightNet/pull/250) [`bc728aa`](https://github.com/LightNetDev/LightNet/commit/bc728aae93cdba4383167488536e5c6ab3654523) Thanks [@smn-cds](https://github.com/smn-cds)! - Introduce DetailsPage wrapper component
14
+
15
+ ‼️ BREAKING CHANGE on experimental custom details page API.
16
+
17
+ With this change all custom details pages need to be wrapped by
18
+ a `DetailsPage` component. This component is exported by `@lightnet/experimental-details-page`.
19
+ Previously custom details pages were automatically wrapped by LightNet.
20
+
21
+ This is how to create a custom details page:
22
+
23
+ ```astro
24
+ ---
25
+ import { DetailsPage } from "@lightNet/experimental-details-page"
26
+ type Props = {
27
+ mediaId
28
+ }
29
+ ---
30
+
31
+ <DetailsPage mediaId={Astro.props.mediaId}>
32
+ {/* Your custom details page components go here */}
33
+ </DetailsPage>
34
+ ```
35
+
3
36
  ## 3.2.0
4
37
 
5
38
  ### Minor Changes
@@ -8,7 +8,7 @@
8
8
  "@astrojs/tailwind": "^6.0.2",
9
9
  "@lightnet/decap-admin": "^3.1.0",
10
10
  "astro": "^5.6.1",
11
- "lightnet": "^3.2.0",
11
+ "lightnet": "^3.4.0",
12
12
  "react": "^19.1.0",
13
13
  "react-dom": "^19.1.0",
14
14
  "sharp": "^0.33.5",
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export { default as ContentSection } from "../src/pages/details-page/components/ContentSection.astro"
6
6
  export { default as DescriptionSection } from "../src/pages/details-page/components/DescriptionSection.astro"
7
+ export { default as DetailsPage } from "../src/pages/details-page/components/DetailsPage.astro"
7
8
  export { default as OpenButton } from "../src/pages/details-page/components/main-details/OpenButton.astro"
8
9
  export { default as ShareButton } from "../src/pages/details-page/components/main-details/ShareButton.astro"
9
10
  export { default as MainDetailsSection } from "../src/pages/details-page/components/MainDetailsSection.astro"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lightnet",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
- "version": "3.2.0",
5
+ "version": "3.4.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/LightNetDev/lightnet",
@@ -25,10 +25,10 @@
25
25
  "./locals": "./src/i18n/locals.ts",
26
26
  "./tailwind.config.ts": "./tailwind.config.ts",
27
27
  "./layouts/MarkdownPage.astro": "./src/layouts/MarkdownPage.astro",
28
- "./pages/404.astro": "./src/pages/404.astro",
29
- "./pages/RedirectToDefaultLocale.astro": "./src/pages/RedirectToDefaultLocale.astro",
30
- "./pages/SearchPage.astro": "./src/pages/search-page/SearchPage.astro",
31
- "./pages/DetailsPage.astro": "./src/pages/details-page/DetailsPage.astro",
28
+ "./pages/404Route.astro": "./src/pages/404Route.astro",
29
+ "./pages/RootRoute.astro": "./src/pages/RootRoute.astro",
30
+ "./pages/SearchPageRoute.astro": "./src/pages/search-page/SearchPageRoute.astro",
31
+ "./pages/DetailsPageRoute.astro": "./src/pages/details-page/DetailsPageRoute.astro",
32
32
  "./pages/api/search.ts": "./src/pages/api/search.ts"
33
33
  },
34
34
  "peerDependencies": {
@@ -153,7 +153,7 @@ export const configSchema = z.object({
153
153
  * Alt attribute to add for screen reader etc.
154
154
  * This can be a fixed string or a translation key.
155
155
  */
156
- alt: z.string().default(""),
156
+ alt: z.string().optional(),
157
157
  /**
158
158
  * Size in px to use for the logo on the header bar.
159
159
  * The size will be applied to the shorter side of your logo image.
@@ -161,6 +161,11 @@ export const configSchema = z.object({
161
161
  * Default is 28 px.
162
162
  */
163
163
  size: z.number().default(28),
164
+ /**
165
+ * Do not show the site title next to the logo.
166
+ * Set this to `true` if your logo already contains the title.
167
+ */
168
+ replacesTitle: z.boolean().default(false),
164
169
  })
165
170
  .optional(),
166
171
  /**
@@ -28,19 +28,19 @@ export function lightnet(lightnetConfig: LightnetConfig): AstroIntegration {
28
28
 
29
29
  injectRoute({
30
30
  pattern: "404",
31
- entrypoint: "lightnet/pages/404.astro",
31
+ entrypoint: "lightnet/pages/404Route.astro",
32
32
  prerender: true,
33
33
  })
34
34
 
35
35
  injectRoute({
36
36
  pattern: "",
37
- entrypoint: "lightnet/pages/RedirectToDefaultLocale.astro",
37
+ entrypoint: "lightnet/pages/RootRoute.astro",
38
38
  prerender: true,
39
39
  })
40
40
 
41
41
  injectRoute({
42
42
  pattern: "/[locale]/media",
43
- entrypoint: "lightnet/pages/SearchPage.astro",
43
+ entrypoint: "lightnet/pages/SearchPageRoute.astro",
44
44
  prerender: true,
45
45
  })
46
46
 
@@ -52,7 +52,7 @@ export function lightnet(lightnetConfig: LightnetConfig): AstroIntegration {
52
52
 
53
53
  injectRoute({
54
54
  pattern: "/[locale]/media/[mediaId]",
55
- entrypoint: "lightnet/pages/DetailsPage.astro",
55
+ entrypoint: "lightnet/pages/DetailsPageRoute.astro",
56
56
  prerender: true,
57
57
  })
58
58
 
@@ -6,8 +6,7 @@ import config from "virtual:lightnet/config"
6
6
 
7
7
  import { resolveLanguage } from "../i18n/resolve-language"
8
8
  import Favicon from "./components/Favicon.astro"
9
- import PageNavigation from "./components/PageNavigation.astro"
10
- import PageTitle from "./components/PageTitle.astro"
9
+ import Header from "./components/Header.astro"
11
10
  import PreloadReact from "./components/PreloadReact"
12
11
 
13
12
  interface Props {
@@ -38,17 +37,7 @@ const language = resolveLanguage(currentLocale)
38
37
  <body
39
38
  class="flex min-h-screen flex-col overflow-y-scroll bg-gray-50 text-gray-900"
40
39
  >
41
- <header
42
- class="fixed top-0 z-50 h-14 w-full bg-white shadow-lg sm:h-20"
43
- transition:animate="none"
44
- >
45
- <div
46
- class="mx-auto flex h-full max-w-screen-xl justify-between px-4 md:px-8"
47
- >
48
- <PageTitle />
49
- <PageNavigation />
50
- </div>
51
- </header>
40
+ <Header />
52
41
  <main class="grow pb-8 pt-14 sm:py-20">
53
42
  <slot />
54
43
  </main>
@@ -0,0 +1,14 @@
1
+ ---
2
+ import PageNavigation from "./PageNavigation.astro"
3
+ import PageTitle from "./PageTitle.astro"
4
+ ---
5
+
6
+ <header
7
+ class="fixed top-0 z-50 h-14 w-full bg-white shadow-lg sm:h-20"
8
+ transition:animate="none"
9
+ >
10
+ <div class="mx-auto flex h-full max-w-screen-xl justify-between px-4 md:px-8">
11
+ <PageTitle />
12
+ <PageNavigation />
13
+ </div>
14
+ </header>
@@ -14,8 +14,10 @@ function getWidth(logo: ImageMetadata) {
14
14
  return Math.floor(size * Math.max(1, logo.width / logo.height))
15
15
  }
16
16
 
17
- const logoAlt = config.logo?.alt ?? ""
18
- const t = Astro.locals.i18n.t
17
+ const logoAlt =
18
+ config.logo?.alt ?? (config.logo?.replacesTitle ? config.title : "")
19
+
20
+ const { t } = Astro.locals.i18n
19
21
  ---
20
22
 
21
23
  <a
@@ -40,5 +42,5 @@ const t = Astro.locals.i18n.t
40
42
  loading="eager"
41
43
  />
42
44
  ))
43
- }{t(config.title)}</a
45
+ }{!config.logo?.replacesTitle && t(config.title)}</a
44
46
  >
@@ -2,6 +2,7 @@
2
2
  import { getMediaItem } from "../../content/get-media-items"
3
3
  import ContentSection from "./components/ContentSection.astro"
4
4
  import DescriptionSection from "./components/DescriptionSection.astro"
5
+ import DetailsPage from "./components/DetailsPage.astro"
5
6
  import AudioPlayer from "./components/main-details/AudioPlayer.astro"
6
7
  import ShareButton from "./components/main-details/ShareButton.astro"
7
8
  import MainDetailsSection from "./components/MainDetailsSection.astro"
@@ -16,11 +17,13 @@ const { mediaId } = Astro.props
16
17
  const audioSrc = (await getMediaItem(mediaId)).data.content[0].url
17
18
  ---
18
19
 
19
- <MainDetailsSection mediaId={mediaId}>
20
- <AudioPlayer src={audioSrc} className="mt-10 w-full" />
21
- <ShareButton className="mt-4 min-w-40" />
22
- </MainDetailsSection>
23
- <DescriptionSection mediaId={mediaId} />
24
- <ContentSection mediaId={mediaId} />
25
- <MediaCollectionsSection mediaId={mediaId} />
26
- <MoreDetailsSection mediaId={mediaId} />
20
+ <DetailsPage mediaId={mediaId}>
21
+ <MainDetailsSection mediaId={mediaId}>
22
+ <AudioPlayer src={audioSrc} className="mt-10 w-full" />
23
+ <ShareButton className="mt-4 min-w-40" />
24
+ </MainDetailsSection>
25
+ <DescriptionSection mediaId={mediaId} />
26
+ <ContentSection mediaId={mediaId} />
27
+ <MediaCollectionsSection mediaId={mediaId} />
28
+ <MoreDetailsSection mediaId={mediaId} />
29
+ </DetailsPage>
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import ContentSection from "./components/ContentSection.astro"
3
3
  import DescriptionSection from "./components/DescriptionSection.astro"
4
+ import DetailsPage from "./components/DetailsPage.astro"
4
5
  import OpenButton from "./components/main-details/OpenButton.astro"
5
6
  import ShareButton from "./components/main-details/ShareButton.astro"
6
7
  import MainDetailsSection from "./components/MainDetailsSection.astro"
@@ -16,13 +17,15 @@ export type Props = {
16
17
  const { mediaId, coverStyle, openActionLabel = "ln.details.open" } = Astro.props
17
18
  ---
18
19
 
19
- <MainDetailsSection mediaId={mediaId} coverStyle={coverStyle}>
20
- <div class="mt-10 flex flex-col justify-center gap-4 sm:justify-start">
21
- <OpenButton mediaId={mediaId} openActionLabel={openActionLabel} />
22
- <ShareButton />
23
- </div>
24
- </MainDetailsSection>
25
- <DescriptionSection mediaId={mediaId} />
26
- <ContentSection mediaId={mediaId} />
27
- <MediaCollectionsSection mediaId={mediaId} />
28
- <MoreDetailsSection mediaId={mediaId} />
20
+ <DetailsPage mediaId={mediaId}>
21
+ <MainDetailsSection mediaId={mediaId} coverStyle={coverStyle}>
22
+ <div class="mt-10 flex flex-col justify-center gap-4 sm:justify-start">
23
+ <OpenButton mediaId={mediaId} openActionLabel={openActionLabel} />
24
+ <ShareButton />
25
+ </div>
26
+ </MainDetailsSection>
27
+ <DescriptionSection mediaId={mediaId} />
28
+ <ContentSection mediaId={mediaId} />
29
+ <MediaCollectionsSection mediaId={mediaId} />
30
+ <MoreDetailsSection mediaId={mediaId} />
31
+ </DetailsPage>
@@ -6,8 +6,6 @@ import config from "virtual:lightnet/config"
6
6
  import { getMediaItem, getMediaItems } from "../../content/get-media-items"
7
7
  import { getMediaType } from "../../content/get-media-types"
8
8
  import { resolveLocales } from "../../i18n/resolve-locales"
9
- import Page from "../../layouts/Page.astro"
10
- import { markdownToText } from "../../utils/markdown"
11
9
  import AudioDetailsPage from "./AudioDetailsPage.astro"
12
10
  import DefaultDetailsPage from "./DefaultDetailsPage.astro"
13
11
  import VideoDetailsPage from "./VideoDetailsPage.astro"
@@ -43,24 +41,11 @@ if (detailsPage?.layout === "custom") {
43
41
  }
44
42
  ---
45
43
 
46
- <Page
47
- title={mediaItem.title}
48
- description={markdownToText(mediaItem.description)}
49
- >
50
- {
51
- layout === "default" && (
52
- <DefaultDetailsPage mediaId={mediaId} {...detailsPage} />
53
- )
54
- }
55
- {
56
- layout === "video" && (
57
- <VideoDetailsPage mediaId={mediaId} {...detailsPage} />
58
- )
59
- }
60
- {
61
- layout === "audio" && (
62
- <AudioDetailsPage mediaId={mediaId} {...detailsPage} />
63
- )
64
- }
65
- {CustomDetails && <CustomDetails mediaId={mediaId} {...detailsPage} />}
66
- </Page>
44
+ {
45
+ layout === "default" && (
46
+ <DefaultDetailsPage mediaId={mediaId} {...detailsPage} />
47
+ )
48
+ }
49
+ {layout === "video" && <VideoDetailsPage mediaId={mediaId} {...detailsPage} />}
50
+ {layout === "audio" && <AudioDetailsPage mediaId={mediaId} {...detailsPage} />}
51
+ {CustomDetails && <CustomDetails mediaId={mediaId} {...detailsPage} />}
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import ContentSection from "./components/ContentSection.astro"
3
3
  import DescriptionSection from "./components/DescriptionSection.astro"
4
+ import DetailsPage from "./components/DetailsPage.astro"
4
5
  import MediaCollectionsSection from "./components/MediaCollectionsSection.astro"
5
6
  import MoreDetailsSection from "./components/MoreDetailsSection.astro"
6
7
  import VideoDetailsSection from "./components/VideoDetailsSection.astro"
@@ -12,8 +13,10 @@ export type Props = {
12
13
  const { mediaId } = Astro.props
13
14
  ---
14
15
 
15
- <VideoDetailsSection mediaId={mediaId} />
16
- <DescriptionSection mediaId={mediaId} />
17
- <ContentSection mediaId={mediaId} />
18
- <MediaCollectionsSection mediaId={mediaId} />
19
- <MoreDetailsSection mediaId={mediaId} />
16
+ <DetailsPage mediaId={mediaId}>
17
+ <VideoDetailsSection mediaId={mediaId} />
18
+ <DescriptionSection mediaId={mediaId} />
19
+ <ContentSection mediaId={mediaId} />
20
+ <MediaCollectionsSection mediaId={mediaId} />
21
+ <MoreDetailsSection mediaId={mediaId} />
22
+ </DetailsPage>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { getMediaItem } from "../../../content/get-media-items"
3
+ import Page from "../../../layouts/Page.astro"
4
+ import { markdownToText } from "../../../utils/markdown"
5
+
6
+ type Props = {
7
+ mediaId: string
8
+ }
9
+
10
+ const mediaItem = (await getMediaItem(Astro.props.mediaId)).data
11
+ ---
12
+
13
+ <Page
14
+ title={mediaItem.title}
15
+ description={markdownToText(mediaItem.description)}
16
+ >
17
+ <slot />
18
+ </Page>
File without changes