lightnet 3.0.1 → 3.1.1
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 +19 -0
- package/README.md +1 -1
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +2 -2
- package/__e2e__/fixtures/basics/package.json +7 -7
- package/__tests__/pages/details-page/create-content-metadata.spec.ts +11 -0
- package/package.json +4 -4
- package/src/content/content-schema.ts +9 -0
- package/src/pages/details-page/AudioDetailsPage.astro +26 -0
- package/src/pages/details-page/DefaultDetailsPage.astro +4 -2
- package/src/pages/details-page/DetailsPage.astro +6 -0
- package/src/pages/details-page/components/MainDetailsSection.astro +2 -5
- package/src/pages/details-page/components/main-details/AudioPlayer.astro +23 -0
- package/src/pages/details-page/utils/create-content-metadata.ts +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# lightnet
|
|
2
2
|
|
|
3
|
+
## 3.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#243](https://github.com/LightNetDev/LightNet/pull/243) [`735e984`](https://github.com/LightNetDev/LightNet/commit/735e984ee00e67bc0d326e4e67efd45cf10b73e0) Thanks [@smn-cds](https://github.com/smn-cds)! - Fix open button label for websites
|
|
8
|
+
|
|
9
|
+
Before website links e.g. https://wikipedia.org showed a "Download" button on the details page.
|
|
10
|
+
With this fix they show a "Open" button.
|
|
11
|
+
|
|
12
|
+
## 3.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#238](https://github.com/LightNetDev/LightNet/pull/238) [`3f1cdbc`](https://github.com/LightNetDev/LightNet/commit/3f1cdbcbf83d20bec83a4c6d3bf1b97ec76e72ee) Thanks [@smn-cds](https://github.com/smn-cds)! - Add Audio details page.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#238](https://github.com/LightNetDev/LightNet/pull/238) [`3f1cdbc`](https://github.com/LightNetDev/LightNet/commit/3f1cdbcbf83d20bec83a4c6d3bf1b97ec76e72ee) Thanks [@smn-cds](https://github.com/smn-cds)! - Update dependencies.
|
|
21
|
+
|
|
3
22
|
## 3.0.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ LightNet is built as an integration for the [Astro](https://astro.build) framewo
|
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
|
-
[Read the LightNet docs](https://
|
|
9
|
+
[Read the LightNet docs](https://docs.lightnet.community) to learn how to use LightNet.
|
|
10
10
|
|
|
11
11
|
## Example site
|
|
12
12
|
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.
|
|
9
|
+
export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.6_@types+node@22.13.15_jiti@2.4.2_lightningcss@1.29.1_rollup@4.38.0_terser@5.39.0_typescript@5.8.2_yaml@2.7.1/node_modules/astro/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.6_@types+node@22.13.15_jiti@2.4.2_lightningcss@1.29.1_rollup@4.38.0_terser@5.39.0_typescript@5.8.2_yaml@2.7.1/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.
|
|
11
|
+
export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.6_@types+node@22.13.15_jiti@2.4.2_lightningcss@1.29.1_rollup@4.38.0_terser@5.39.0_typescript@5.8.2_yaml@2.7.1/node_modules/astro/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.5.6_@types+node@22.13.15_jiti@2.4.2_lightningcss@1.29.1_rollup@4.38.0_terser@5.39.0_typescript@5.8.2_yaml@2.7.1/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../astro/astro.js" "$@"
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"version": "0.0.1",
|
|
5
5
|
"private": "true",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@astrojs/react": "^4.2.
|
|
8
|
-
"@astrojs/tailwind": "^6.0.
|
|
9
|
-
"@lightnet/decap-admin": "^3.
|
|
10
|
-
"astro": "^5.5.
|
|
11
|
-
"lightnet": "^3.
|
|
12
|
-
"react": "^19.
|
|
13
|
-
"react-dom": "^19.
|
|
7
|
+
"@astrojs/react": "^4.2.3",
|
|
8
|
+
"@astrojs/tailwind": "^6.0.2",
|
|
9
|
+
"@lightnet/decap-admin": "^3.1.0",
|
|
10
|
+
"astro": "^5.5.6",
|
|
11
|
+
"lightnet": "^3.1.0",
|
|
12
|
+
"react": "^19.1.0",
|
|
13
|
+
"react-dom": "^19.1.0",
|
|
14
14
|
"sharp": "^0.33.5",
|
|
15
15
|
"tailwindcss": "^3.4.17",
|
|
16
16
|
"typescript": "^5.8.2"
|
|
@@ -25,6 +25,17 @@ test("Should create complete content metadata", () => {
|
|
|
25
25
|
type: "link",
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
url: "https://wikipedia.org",
|
|
30
|
+
expected: {
|
|
31
|
+
canBeOpened: true,
|
|
32
|
+
target: "_blank",
|
|
33
|
+
label: "wikipedia.org",
|
|
34
|
+
isExternal: true,
|
|
35
|
+
extension: "",
|
|
36
|
+
type: "link",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
28
39
|
{
|
|
29
40
|
url: "https://some.host/some.pDf",
|
|
30
41
|
expected: {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "lightnet",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.1.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/LightNetDev/lightnet",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"fuse.js": "^7.1.0",
|
|
51
51
|
"i18next": "^24.2.3",
|
|
52
52
|
"marked": "^15.0.7",
|
|
53
|
-
"yaml": "^2.7.
|
|
53
|
+
"yaml": "^2.7.1",
|
|
54
54
|
"zod-validation-error": "^3.4.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@playwright/test": "^1.51.1",
|
|
58
|
-
"@types/node": "^22.13.
|
|
59
|
-
"vitest": "^3.
|
|
58
|
+
"@types/node": "^22.13.15",
|
|
59
|
+
"vitest": "^3.1.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"test": "vitest",
|
|
@@ -134,6 +134,7 @@ export const mediaItemSchema = z.object({
|
|
|
134
134
|
* - links to youtube videos
|
|
135
135
|
* - links to vimeo videos
|
|
136
136
|
* - links to .mp4 video files
|
|
137
|
+
* - links to .mp3 audio files
|
|
137
138
|
* - links to external websites
|
|
138
139
|
* - links to pdfs (might be hosted inside the public/files/ folder)
|
|
139
140
|
* - links to epubs (might be hosted inside the public/files/ folder)
|
|
@@ -223,6 +224,14 @@ export const mediaTypeSchema = z.object({
|
|
|
223
224
|
*/
|
|
224
225
|
layout: z.literal("video"),
|
|
225
226
|
}),
|
|
227
|
+
z.object({
|
|
228
|
+
/**
|
|
229
|
+
* Detail page for audio files.
|
|
230
|
+
*
|
|
231
|
+
* This only supports mp3 files.
|
|
232
|
+
*/
|
|
233
|
+
layout: z.literal("audio"),
|
|
234
|
+
}),
|
|
226
235
|
])
|
|
227
236
|
.optional(),
|
|
228
237
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getMediaItem } from "../../content/get-media-items"
|
|
3
|
+
import ContentSection from "./components/ContentSection.astro"
|
|
4
|
+
import DescriptionSection from "./components/DescriptionSection.astro"
|
|
5
|
+
import AudioPlayer from "./components/main-details/AudioPlayer.astro"
|
|
6
|
+
import ShareButton from "./components/main-details/ShareButton.astro"
|
|
7
|
+
import MainDetailsSection from "./components/MainDetailsSection.astro"
|
|
8
|
+
import MediaCollectionsSection from "./components/MediaCollectionsSection.astro"
|
|
9
|
+
import MoreDetailsSection from "./components/MoreDetailsSection.astro"
|
|
10
|
+
|
|
11
|
+
export type Props = {
|
|
12
|
+
mediaId: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { mediaId } = Astro.props
|
|
16
|
+
const audioSrc = (await getMediaItem(mediaId)).data.content[0].url
|
|
17
|
+
---
|
|
18
|
+
|
|
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} />
|
|
@@ -17,8 +17,10 @@ const { mediaId, coverStyle, openActionLabel = "ln.details.open" } = Astro.props
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
<MainDetailsSection mediaId={mediaId} coverStyle={coverStyle}>
|
|
20
|
-
<
|
|
21
|
-
|
|
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>
|
|
22
24
|
</MainDetailsSection>
|
|
23
25
|
<DescriptionSection mediaId={mediaId} />
|
|
24
26
|
<ContentSection mediaId={mediaId} />
|
|
@@ -8,6 +8,7 @@ import { getMediaType } from "../../content/get-media-types"
|
|
|
8
8
|
import { resolveLocales } from "../../i18n/resolve-locales"
|
|
9
9
|
import Page from "../../layouts/Page.astro"
|
|
10
10
|
import { markdownToText } from "../../utils/markdown"
|
|
11
|
+
import AudioDetailsPage from "./AudioDetailsPage.astro"
|
|
11
12
|
import DefaultDetailsPage from "./DefaultDetailsPage.astro"
|
|
12
13
|
import VideoDetailsPage from "./VideoDetailsPage.astro"
|
|
13
14
|
|
|
@@ -56,5 +57,10 @@ if (detailsPage?.layout === "custom") {
|
|
|
56
57
|
<VideoDetailsPage mediaId={mediaId} {...detailsPage} />
|
|
57
58
|
)
|
|
58
59
|
}
|
|
60
|
+
{
|
|
61
|
+
layout === "audio" && (
|
|
62
|
+
<AudioDetailsPage mediaId={mediaId} {...detailsPage} />
|
|
63
|
+
)
|
|
64
|
+
}
|
|
59
65
|
{CustomDetails && <CustomDetails mediaId={mediaId} {...detailsPage} />}
|
|
60
66
|
</Page>
|
|
@@ -15,12 +15,9 @@ const { mediaId, coverStyle = "default" } = Astro.props
|
|
|
15
15
|
class="mx-auto mt-10 flex max-w-screen-md flex-col items-center gap-8 px-4 sm:mt-20 sm:flex-row sm:items-start sm:gap-14 md:px-8"
|
|
16
16
|
>
|
|
17
17
|
<Cover mediaId={mediaId} style={coverStyle} />
|
|
18
|
-
<div class="flex flex-col items-center sm:items-start">
|
|
18
|
+
<div class="flex w-full grow flex-col items-center sm:items-start">
|
|
19
19
|
<Title className="text-center sm:text-start" mediaId={mediaId} />
|
|
20
20
|
<Authors className="text-center sm:text-start" mediaId={mediaId} />
|
|
21
|
-
|
|
22
|
-
<div class="mt-10 flex flex-col justify-center gap-4 sm:justify-start">
|
|
23
|
-
<slot />
|
|
24
|
-
</div>
|
|
21
|
+
<slot />
|
|
25
22
|
</div>
|
|
26
23
|
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { AstroError } from "astro/errors"
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
src: string
|
|
6
|
+
className?: string
|
|
7
|
+
}
|
|
8
|
+
const { src, className } = Astro.props
|
|
9
|
+
if (!src.endsWith(".mp3")) {
|
|
10
|
+
throw new AstroError(
|
|
11
|
+
`Unsupported audio file ${src}`,
|
|
12
|
+
"Mp3 is the only supported format.",
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<audio class="rounded-xl" class:list={[className]} src={src} controls></audio>
|
|
18
|
+
|
|
19
|
+
<style>
|
|
20
|
+
audio::-webkit-media-controls-enclosure {
|
|
21
|
+
border-radius: 0;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -49,17 +49,18 @@ export function createContentMetadata({
|
|
|
49
49
|
url: string
|
|
50
50
|
label?: string
|
|
51
51
|
}) {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const isExternal = isExternalUrl(url)
|
|
53
|
+
const path = isExternal ? new URL(url).pathname : url
|
|
54
|
+
|
|
55
|
+
const lastPathSegment = path.split("/").slice(-1)[0]
|
|
56
|
+
const hasExtension = lastPathSegment.includes(".")
|
|
54
57
|
const extension = hasExtension
|
|
55
|
-
?
|
|
58
|
+
? lastPathSegment.split(".").slice(-1)[0].toLowerCase()
|
|
56
59
|
: ""
|
|
57
60
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const linkName = isExternal ? new URL(url).hostname : lastUrlSegment
|
|
61
|
+
const linkName = isExternal ? new URL(url).hostname : lastPathSegment
|
|
61
62
|
const fileName = hasExtension
|
|
62
|
-
?
|
|
63
|
+
? lastPathSegment.slice(0, -(extension.length + 1))
|
|
63
64
|
: undefined
|
|
64
65
|
const label = customLabel ?? fileName ?? linkName
|
|
65
66
|
const type = KNOWN_EXTENSIONS[extension]?.type ?? "link"
|