lightnet 3.12.2 → 4.0.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 +55 -0
- package/exports/content.ts +7 -2
- package/exports/i18n.ts +0 -1
- package/exports/index.ts +1 -5
- package/exports/utils.ts +0 -1
- package/package.json +26 -12
- package/src/astro-integration/config.ts +60 -49
- package/src/astro-integration/integration.ts +13 -24
- package/src/astro-integration/tailwind.ts +86 -0
- package/src/astro-integration/validators/validate-inline-translations.ts +51 -0
- package/src/astro-integration/validators/validate-languages.ts +39 -0
- package/src/astro-integration/virtual.d.ts +8 -6
- package/src/astro-integration/vite-plugin-lightnet-config.ts +29 -9
- package/src/components/CarouselSection.astro +7 -11
- package/src/components/CategoriesSection.astro +2 -2
- package/src/components/HighlightSection.astro +4 -7
- package/src/components/Icon.tsx +2 -2
- package/src/components/MediaGallerySection.astro +88 -68
- package/src/components/MediaList.astro +9 -7
- package/src/components/SearchInput.astro +7 -4
- package/src/components/Section.astro +7 -5
- package/src/components/VideoPlayer.astro +2 -3
- package/src/content/content-schema.ts +129 -142
- package/src/content/get-categories.ts +52 -28
- package/src/content/get-languages.ts +29 -8
- package/src/content/get-media-collections.ts +43 -0
- package/src/content/get-media-types.ts +41 -7
- package/src/content/query-media-items.ts +23 -13
- package/src/i18n/bcp-47.ts +8 -0
- package/src/i18n/get-locale-paths.ts +1 -3
- package/src/i18n/locals.d.ts +21 -3
- package/src/i18n/locals.ts +18 -11
- package/src/i18n/resolve-current-locale.ts +18 -0
- package/src/i18n/resolve-language.ts +10 -5
- package/src/i18n/translate-map.ts +70 -0
- package/src/i18n/translate.ts +68 -47
- package/src/layouts/Page.astro +5 -3
- package/src/layouts/components/LanguagePicker.astro +22 -17
- package/src/layouts/components/Menu.astro +2 -5
- package/src/layouts/components/MenuItem.astro +1 -1
- package/src/layouts/components/PageNavigation.astro +29 -29
- package/src/layouts/components/PageTitle.astro +23 -7
- package/src/pages/404Route.astro +2 -1
- package/src/pages/RootRoute.astro +6 -1
- package/src/pages/details-page/DefaultDetailsPage.astro +9 -2
- package/src/pages/details-page/DetailsPageRoute.astro +1 -2
- package/src/pages/details-page/components/AudioPanel.astro +7 -3
- package/src/pages/details-page/components/AudioPlayer.astro +2 -2
- package/src/pages/details-page/components/ContentSection.astro +67 -44
- package/src/pages/details-page/components/MediaCollection.astro +8 -4
- package/src/pages/details-page/components/MediaCollectionsSection.astro +3 -6
- package/src/pages/details-page/components/main-details/EditButton.astro +22 -10
- package/src/pages/details-page/components/main-details/OpenButton.astro +17 -12
- package/src/pages/details-page/components/main-details/ShareButton.astro +3 -2
- package/src/pages/details-page/components/more-details/Categories.astro +5 -3
- package/src/pages/details-page/components/more-details/Languages.astro +12 -7
- package/src/pages/details-page/utils/create-content-metadata.ts +24 -9
- package/src/pages/details-page/utils/get-translations.ts +6 -0
- package/src/pages/search-page/components/LoadingSkeleton.tsx +6 -5
- package/src/pages/search-page/components/SearchFilter.astro +10 -21
- package/src/pages/search-page/components/SearchFilter.tsx +2 -2
- package/src/pages/search-page/components/SearchList.astro +10 -7
- package/src/pages/search-page/components/SearchListItem.tsx +5 -4
- package/src/pages/search-page/hooks/use-search.ts +5 -2
- package/src/utils/lazy.ts +20 -0
- package/src/utils/paths.ts +40 -3
- package/src/utils/urls.ts +1 -2
- package/src/utils/verify-schema.ts +12 -10
- package/tailwind.config.ts +1 -25
- package/__e2e__/admin.spec.ts +0 -20
- package/__e2e__/basics-fixture.ts +0 -77
- package/__e2e__/fixtures/basics/astro.config.mjs +0 -40
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwind +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwindcss +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tsc +0 -21
- package/__e2e__/fixtures/basics/node_modules/.bin/tsserver +0 -21
- package/__e2e__/fixtures/basics/package.json +0 -21
- package/__e2e__/fixtures/basics/public/favicon.svg +0 -1
- package/__e2e__/fixtures/basics/public/files/example.pdf +0 -0
- package/__e2e__/fixtures/basics/src/assets/logo.png +0 -0
- package/__e2e__/fixtures/basics/src/content/categories/christian-living.json +0 -3
- package/__e2e__/fixtures/basics/src/content/categories/teens.json +0 -3
- package/__e2e__/fixtures/basics/src/content/categories/theology.json +0 -3
- package/__e2e__/fixtures/basics/src/content/media/faithful-freestyle--en.json +0 -13
- package/__e2e__/fixtures/basics/src/content/media/how-to-kickflip--de.json +0 -12
- package/__e2e__/fixtures/basics/src/content/media/images/cover.jpg +0 -0
- package/__e2e__/fixtures/basics/src/content/media/images/how-to-kickflip--en.webp +0 -0
- package/__e2e__/fixtures/basics/src/content/media/skate-sounds--en.json +0 -15
- package/__e2e__/fixtures/basics/src/content/media-collections/how-to-articles.json +0 -3
- package/__e2e__/fixtures/basics/src/content/media-types/audio.json +0 -7
- package/__e2e__/fixtures/basics/src/content/media-types/book.json +0 -9
- package/__e2e__/fixtures/basics/src/content/media-types/video.json +0 -7
- package/__e2e__/fixtures/basics/src/content.config.ts +0 -3
- package/__e2e__/fixtures/basics/src/pages/[locale]/index.astro +0 -16
- package/__e2e__/fixtures/basics/src/translations/de.yml +0 -9
- package/__e2e__/fixtures/basics/src/translations/en.yml +0 -9
- package/__e2e__/fixtures/basics/tailwind.config.mjs +0 -8
- package/__e2e__/global.teardown.ts +0 -5
- package/__e2e__/homepage.spec.ts +0 -123
- package/__e2e__/search.spec.ts +0 -14
- package/__tests__/pages/details-page/create-content-metadata.spec.ts +0 -135
- package/__tests__/utils/markdown.spec.ts +0 -74
- package/__tests__/utils/urls.spec.ts +0 -27
- package/playwright.config.ts +0 -31
- package/src/astro-integration/project-context.ts +0 -5
- package/src/content/compare-media-collection-items.ts +0 -24
- package/src/i18n/resolve-default-locale.ts +0 -19
- package/src/i18n/resolve-locales.ts +0 -5
- package/src/pages/details-page/utils/get-collection-items.ts +0 -29
- package/vitest.config.js +0 -20
|
Binary file
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"commonId": "faithful-freestyle",
|
|
3
|
-
"title": "Faithful Freestyle",
|
|
4
|
-
"type": "book",
|
|
5
|
-
"dateCreated": "2024-04-21",
|
|
6
|
-
"authors": ["Sk8 Ministries"],
|
|
7
|
-
"content": [{ "url": "/files/example.pdf" }],
|
|
8
|
-
"image": "./images/cover.jpg",
|
|
9
|
-
"language": "en",
|
|
10
|
-
"categories": ["christian-living"],
|
|
11
|
-
"collections": [{ "collection": "how-to-articles" }],
|
|
12
|
-
"description": "*How to: Faithful Freestyle* empowers you to express your Christianity through the unique and creative outlet of skateboarding. This book includes:\n\n* **Creative ways to incorporate faith** into your skating routines\n* **Stories of freestyle skaters** who honor God through their sport\n* **Practical advice on witnessing** to others in the skateboarding scene\n* **Inspirational devotions** designed for skaters\n\nEmbrace a faithful freestyle and let every trick and turn reflect your devotion to Christ."
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"commonId": "how-to-kickflip",
|
|
3
|
-
"title": "Kickflip Anleitung",
|
|
4
|
-
"type": "video",
|
|
5
|
-
"dateCreated": "2024-04-21",
|
|
6
|
-
"content": [{ "url": "https://www.youtube.com/watch?v=tnpLkUQZODc" }],
|
|
7
|
-
"image": "./images/how-to-kickflip--en.webp",
|
|
8
|
-
"authors": ["Skiddy Skates"],
|
|
9
|
-
"language": "de",
|
|
10
|
-
"categories": ["teens"],
|
|
11
|
-
"description": "Dieses Tutorial zeigt dir, wie du den Kickflip meisterst. Es behandelt den Stand, das Abpoppen, das Flicking, das Timing und das Landen. Perfekt für alle Könnensstufen!"
|
|
12
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"commonId": "skate-sounds",
|
|
3
|
-
"title": "Skate Sounds",
|
|
4
|
-
"type": "audio",
|
|
5
|
-
"dateCreated": "2024-04-21",
|
|
6
|
-
"authors": ["Sk8 Ministries"],
|
|
7
|
-
"content": [
|
|
8
|
-
{ "url": "/files/example-audio.mp3" },
|
|
9
|
-
{ "url": "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3" }
|
|
10
|
-
],
|
|
11
|
-
"image": "./images/cover.jpg",
|
|
12
|
-
"language": "en",
|
|
13
|
-
"categories": ["christian-living"],
|
|
14
|
-
"description": "A vibrant collection of authentic skate park sounds to energize your projects and playlists.\n\n**Highlights:**\n* Real-world skating ambience\n* Perfect for creative mixes\n* Inspiring background audio for worship gatherings"
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
export { getLocalePaths as getStaticPaths } from "lightnet/i18n"
|
|
3
|
-
|
|
4
|
-
import { MediaGallerySection, Page } from "lightnet/components"
|
|
5
|
-
import { getMediaItems } from "lightnet/content"
|
|
6
|
-
|
|
7
|
-
const allItems = await getMediaItems()
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<Page>
|
|
11
|
-
<MediaGallerySection
|
|
12
|
-
title={Astro.locals.i18n.t("home.all-items")}
|
|
13
|
-
items={allItems}
|
|
14
|
-
layout="book"
|
|
15
|
-
/>
|
|
16
|
-
</Page>
|
package/__e2e__/homepage.spec.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { expect } from "@playwright/test"
|
|
2
|
-
|
|
3
|
-
import { test } from "./basics-fixture"
|
|
4
|
-
|
|
5
|
-
test("Should have title set", async ({ page, lightnet }) => {
|
|
6
|
-
await lightnet()
|
|
7
|
-
await expect(page).toHaveTitle("Basic Test")
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
test("Should have header title that navigates to home page", async ({
|
|
11
|
-
page,
|
|
12
|
-
lightnet,
|
|
13
|
-
}) => {
|
|
14
|
-
const ln = await lightnet()
|
|
15
|
-
await page.getByRole("link", { name: "Basic Test" }).click()
|
|
16
|
-
|
|
17
|
-
await expect(page).toHaveURL(ln.resolveURL("/en/"))
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test("Should have item section", async ({ page, lightnet }) => {
|
|
21
|
-
await lightnet()
|
|
22
|
-
await expect(page.getByRole("heading", { name: "All items" })).toBeVisible()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test("Should navigate to search page from main menu", async ({
|
|
26
|
-
page,
|
|
27
|
-
lightnet,
|
|
28
|
-
}) => {
|
|
29
|
-
const ln = await lightnet()
|
|
30
|
-
await expect(
|
|
31
|
-
page.getByRole("button", { name: "Open Main Menu" }),
|
|
32
|
-
).toBeVisible()
|
|
33
|
-
await page
|
|
34
|
-
.getByRole("navigation")
|
|
35
|
-
.getByRole("button", { name: "Open Main Menu" })
|
|
36
|
-
.click()
|
|
37
|
-
await page.getByRole("navigation").getByText("Search").click()
|
|
38
|
-
|
|
39
|
-
await expect(page).toHaveURL(ln.resolveURL("/en/media"))
|
|
40
|
-
await expect(page.getByRole("heading", { name: "Search" })).toBeVisible()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test("Should switch languages", async ({ page, lightnet }) => {
|
|
44
|
-
const ln = await lightnet()
|
|
45
|
-
|
|
46
|
-
await page.getByLabel("Select language").click()
|
|
47
|
-
await page.getByRole("link", { name: "Deutsch" }).click()
|
|
48
|
-
await expect(page).toHaveURL(ln.resolveURL("/de/"))
|
|
49
|
-
await expect(page.getByRole("heading")).toHaveText("Alle Artikel")
|
|
50
|
-
|
|
51
|
-
await page.getByLabel("Sprache auswählen").click()
|
|
52
|
-
await page.getByRole("link", { name: "English" }).click()
|
|
53
|
-
await expect(page).toHaveURL(ln.resolveURL("/en/"))
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
test("Should verify EN Detail media page url and title", async ({
|
|
57
|
-
page,
|
|
58
|
-
lightnet,
|
|
59
|
-
}) => {
|
|
60
|
-
const ln = await lightnet()
|
|
61
|
-
|
|
62
|
-
await page.getByRole("link", { name: "Faithful Freestyle" }).click()
|
|
63
|
-
await expect(
|
|
64
|
-
page.getByRole("heading", { name: "Faithful Freestyle" }),
|
|
65
|
-
).toBeVisible()
|
|
66
|
-
await expect(page).toHaveURL(
|
|
67
|
-
ln.resolveURL("/en/media/faithful-freestyle--en"),
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
await page.goBack()
|
|
71
|
-
|
|
72
|
-
await page.getByRole("link", { name: "Kickflip Anleitung" }).click()
|
|
73
|
-
await expect(
|
|
74
|
-
page.getByRole("heading", { name: "Kickflip Anleitung" }),
|
|
75
|
-
).toBeVisible()
|
|
76
|
-
await expect(page).toHaveURL(ln.resolveURL("/en/media/how-to-kickflip--de"))
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test("Should verify DE Detail media page url and title", async ({
|
|
80
|
-
page,
|
|
81
|
-
lightnet,
|
|
82
|
-
}) => {
|
|
83
|
-
const ln = await lightnet()
|
|
84
|
-
|
|
85
|
-
await page.getByLabel("Select language").click()
|
|
86
|
-
await page.getByRole("link", { name: "Deutsch" }).click()
|
|
87
|
-
await page.getByRole("link", { name: "Faithful Freestyle" }).click()
|
|
88
|
-
await expect(page).toHaveURL(
|
|
89
|
-
ln.resolveURL("/de/media/faithful-freestyle--en"),
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
const lesenLink = page.getByRole("link", { name: "Lesen" })
|
|
93
|
-
await expect(lesenLink).toBeVisible()
|
|
94
|
-
await expect(lesenLink).toBeEnabled()
|
|
95
|
-
// await lesenLink.click()
|
|
96
|
-
// await page.waitForLoadState("networkidle")
|
|
97
|
-
// await page.goBack()
|
|
98
|
-
|
|
99
|
-
await expect(page.getByRole("button", { name: "Teilen" })).toBeVisible()
|
|
100
|
-
await expect(page.getByText("Sprache")).toBeVisible()
|
|
101
|
-
await expect(page.getByText("Kategorie")).toBeVisible()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test("Should show `Powered by LightNet` in footer", async ({
|
|
105
|
-
page,
|
|
106
|
-
lightnet,
|
|
107
|
-
}) => {
|
|
108
|
-
await lightnet()
|
|
109
|
-
|
|
110
|
-
const footerLink = page
|
|
111
|
-
.getByRole("contentinfo")
|
|
112
|
-
.getByRole("link", { name: /LightNet/ })
|
|
113
|
-
|
|
114
|
-
await expect(footerLink).toHaveText("Powered by LightNet")
|
|
115
|
-
await expect(footerLink).toHaveAttribute("href", "https://lightnet.community")
|
|
116
|
-
|
|
117
|
-
await page.getByLabel("Select language").click()
|
|
118
|
-
await page.getByRole("link", { name: "Deutsch" }).click()
|
|
119
|
-
|
|
120
|
-
await expect(
|
|
121
|
-
page.getByRole("contentinfo").getByRole("link", { name: /LightNet/ }),
|
|
122
|
-
).toHaveText("Ermöglicht durch LightNet")
|
|
123
|
-
})
|
package/__e2e__/search.spec.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { expect } from "@playwright/test"
|
|
2
|
-
|
|
3
|
-
import { test } from "./basics-fixture"
|
|
4
|
-
|
|
5
|
-
test("Search should have heading section and URL", async ({
|
|
6
|
-
page,
|
|
7
|
-
lightnet,
|
|
8
|
-
}) => {
|
|
9
|
-
const ln = await lightnet()
|
|
10
|
-
|
|
11
|
-
await page.getByLabel("Search").click()
|
|
12
|
-
await expect(page.getByRole("heading", { name: "Search" })).toBeVisible()
|
|
13
|
-
await expect(page).toHaveURL(ln.resolveURL("/en/media"))
|
|
14
|
-
})
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest"
|
|
2
|
-
|
|
3
|
-
import { createContentMetadata } from "../../../src/pages/details-page/utils/create-content-metadata"
|
|
4
|
-
|
|
5
|
-
test("Should create complete content metadata", () => {
|
|
6
|
-
expect(createContentMetadata({ url: "https://some.host/some.pDf" })).toEqual({
|
|
7
|
-
url: "https://some.host/some.pDf",
|
|
8
|
-
canBeOpened: true,
|
|
9
|
-
type: "text",
|
|
10
|
-
target: "_blank",
|
|
11
|
-
label: "some",
|
|
12
|
-
isExternal: true,
|
|
13
|
-
extension: "pdf",
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
;[
|
|
17
|
-
{
|
|
18
|
-
url: "https://youtube.com/watch?v=k2exixc",
|
|
19
|
-
expected: {
|
|
20
|
-
canBeOpened: true,
|
|
21
|
-
target: "_blank",
|
|
22
|
-
label: "youtube.com",
|
|
23
|
-
isExternal: true,
|
|
24
|
-
extension: "",
|
|
25
|
-
type: "link",
|
|
26
|
-
},
|
|
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
|
-
},
|
|
39
|
-
{
|
|
40
|
-
url: "https://some.host/some.pDf",
|
|
41
|
-
expected: {
|
|
42
|
-
canBeOpened: true,
|
|
43
|
-
type: "text",
|
|
44
|
-
target: "_blank",
|
|
45
|
-
label: "some",
|
|
46
|
-
isExternal: true,
|
|
47
|
-
extension: "pdf",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
url: "https://some.host/some.unknown",
|
|
52
|
-
expected: {
|
|
53
|
-
type: "link",
|
|
54
|
-
canBeOpened: false,
|
|
55
|
-
target: "_blank",
|
|
56
|
-
label: "some",
|
|
57
|
-
isExternal: true,
|
|
58
|
-
extension: "unknown",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
url: "/files/my.pdf",
|
|
63
|
-
expected: {
|
|
64
|
-
canBeOpened: true,
|
|
65
|
-
type: "text",
|
|
66
|
-
target: "_self",
|
|
67
|
-
label: "my",
|
|
68
|
-
isExternal: false,
|
|
69
|
-
extension: "pdf",
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
url: "/paths/my-id",
|
|
74
|
-
expected: {
|
|
75
|
-
canBeOpened: true,
|
|
76
|
-
target: "_self",
|
|
77
|
-
label: "my-id",
|
|
78
|
-
isExternal: false,
|
|
79
|
-
extension: "",
|
|
80
|
-
type: "link",
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
url: "/files/my.unknown",
|
|
85
|
-
expected: {
|
|
86
|
-
canBeOpened: false,
|
|
87
|
-
target: "_self",
|
|
88
|
-
label: "my",
|
|
89
|
-
isExternal: false,
|
|
90
|
-
type: "link",
|
|
91
|
-
extension: "unknown",
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
url: "/some.zip",
|
|
96
|
-
expected: {
|
|
97
|
-
canBeOpened: false,
|
|
98
|
-
target: "_self",
|
|
99
|
-
label: "some",
|
|
100
|
-
isExternal: false,
|
|
101
|
-
extension: "zip",
|
|
102
|
-
type: "package",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
url: "/some.zip",
|
|
107
|
-
label: "foo",
|
|
108
|
-
expected: {
|
|
109
|
-
label: "foo",
|
|
110
|
-
isExternal: false,
|
|
111
|
-
extension: "zip",
|
|
112
|
-
type: "package",
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
url: "/some.zip",
|
|
117
|
-
label: "",
|
|
118
|
-
expected: {
|
|
119
|
-
label: "some",
|
|
120
|
-
isExternal: false,
|
|
121
|
-
extension: "zip",
|
|
122
|
-
type: "package",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
].forEach(({ url, expected, label }) => {
|
|
126
|
-
test(`Should create content metadata for url '${url}' ${label !== undefined ? `and label '${label}'` : ""}`, () => {
|
|
127
|
-
expect(createContentMetadata({ url, label })).toMatchObject(expected)
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
test("Should override name with input", () => {
|
|
132
|
-
expect(
|
|
133
|
-
createContentMetadata({ url: "/path/to/a.file", label: "My file" }),
|
|
134
|
-
).toMatchObject({ label: "My file" })
|
|
135
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest"
|
|
2
|
-
|
|
3
|
-
import { markdownToText } from "../../src/utils/markdown"
|
|
4
|
-
|
|
5
|
-
test("Should remove '\\' to force new lines", () => {
|
|
6
|
-
expect(markdownToText("a\\\nb\\ \nc")).toBe("a\nb \nc")
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test("Should remove <br> to force new lines", () => {
|
|
10
|
-
expect(markdownToText("a <br> b<br>\nc")).toBe("a b \nc")
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test("Should remove double white space", () => {
|
|
14
|
-
expect(markdownToText("a b")).toBe("a b")
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test("Should remove triple white space", () => {
|
|
18
|
-
expect(markdownToText("a b")).toBe("a b")
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test("Should remove escape character '\\'", () => {
|
|
22
|
-
// eslint-disable-next-line no-useless-escape
|
|
23
|
-
expect(markdownToText("a \\\* \\\# b")).toBe("a * # b")
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test("Should remove headers", () => {
|
|
27
|
-
expect(markdownToText("# H1\n## H2 words#")).toBe("H1\nH2 words#")
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test("Should remove underline", () => {
|
|
31
|
-
expect(markdownToText("Some <u>underlined</u> Words /u >")).toBe(
|
|
32
|
-
"Some underlined Words /u >",
|
|
33
|
-
)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test("Should remove encoded space", () => {
|
|
37
|
-
expect(markdownToText("Text with space ")).toBe(
|
|
38
|
-
"Text with space ",
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test("Should remove inline modifiers", async () => {
|
|
43
|
-
expect(markdownToText("this is **some bold** and _italic_ text")).toBe(
|
|
44
|
-
"this is some bold and italic text",
|
|
45
|
-
)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test("Should remove code blocks", async () => {
|
|
49
|
-
expect(markdownToText("some\n```js \ncode\n```\n")).toBe("some\ncode\n")
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test("Should remove list", () => {
|
|
53
|
-
expect(markdownToText("- this is **bold**\n- this is normal")).toBe(
|
|
54
|
-
"this is bold\nthis is normal",
|
|
55
|
-
)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test("Should convert links", () => {
|
|
59
|
-
expect(markdownToText("some [link](https://link.com?foo)")).toBe("some link")
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test("Should remove images", () => {
|
|
63
|
-
expect(markdownToText("")).toBe("a image")
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test("Should remove block quotes", () => {
|
|
67
|
-
expect(markdownToText("> block quote\n>more quote")).toBe(
|
|
68
|
-
"block quote\nmore quote",
|
|
69
|
-
)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test("Should return undefined when markdown is undefined", () => {
|
|
73
|
-
expect(markdownToText(undefined)).toBeUndefined()
|
|
74
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import config from "virtual:lightnet/config"
|
|
2
|
-
import projectContext from "virtual:lightnet/project-context"
|
|
3
|
-
import { expect, test } from "vitest"
|
|
4
|
-
|
|
5
|
-
import { isExternalUrl } from "../../src/utils/urls"
|
|
6
|
-
|
|
7
|
-
// relative path should be treated as internal
|
|
8
|
-
test("Should treat relative paths as internal", () => {
|
|
9
|
-
expect(isExternalUrl("/page")).toBe(false)
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
// absolute url that matches the configured site should be internal
|
|
13
|
-
test("Should treat URLs matching projectContext.site as internal", () => {
|
|
14
|
-
expect(isExternalUrl(`${projectContext.site}/page`)).toBe(false)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
// domains listed in internalDomains should be treated as internal
|
|
18
|
-
test("Should treat configured internalDomains as internal", () => {
|
|
19
|
-
config.internalDomains.push("internal.test")
|
|
20
|
-
expect(isExternalUrl("https://internal.test/foo")).toBe(false)
|
|
21
|
-
config.internalDomains.pop()
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// any other absolute url should be external
|
|
25
|
-
test("Should treat other absolute URLs as external", () => {
|
|
26
|
-
expect(isExternalUrl("https://example.com")).toBe(true)
|
|
27
|
-
})
|
package/playwright.config.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineConfig, devices } from "@playwright/test"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* See https://playwright.dev/docs/test-configuration.
|
|
5
|
-
*/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
testDir: "./__e2e__",
|
|
8
|
-
globalTeardown: "./__e2e__/global.teardown.ts",
|
|
9
|
-
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
10
|
-
forbidOnly: !!process.env.CI,
|
|
11
|
-
/* Retry on CI only */
|
|
12
|
-
retries: process.env.CI ? 2 : 0,
|
|
13
|
-
/* Opt out of parallel tests. */
|
|
14
|
-
workers: 1,
|
|
15
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
16
|
-
reporter: "html",
|
|
17
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
18
|
-
use: {
|
|
19
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
20
|
-
trace: "on-first-retry",
|
|
21
|
-
viewport: { width: 1280, height: 800 }, // Set default viewport
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
/* Configure projects for major browsers */
|
|
25
|
-
projects: [
|
|
26
|
-
{
|
|
27
|
-
name: "chromium",
|
|
28
|
-
use: { ...devices["Desktop Chrome"] },
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { MediaItemEntry } from "./content-schema"
|
|
2
|
-
|
|
3
|
-
export function compareMediaCollectionItems(
|
|
4
|
-
item1: MediaItemEntry,
|
|
5
|
-
item2: MediaItemEntry,
|
|
6
|
-
collectionId: string,
|
|
7
|
-
) {
|
|
8
|
-
const getIndex = (item: MediaItemEntry) =>
|
|
9
|
-
item.data.collections?.find(
|
|
10
|
-
({ collection }) => collection.id === collectionId,
|
|
11
|
-
)?.index
|
|
12
|
-
const index1 = getIndex(item1)
|
|
13
|
-
const index2 = getIndex(item2)
|
|
14
|
-
if (index1 === index2) {
|
|
15
|
-
return item1.id.localeCompare(item2.id)
|
|
16
|
-
}
|
|
17
|
-
if (index1 === undefined && index2 !== undefined) {
|
|
18
|
-
return 1
|
|
19
|
-
}
|
|
20
|
-
if (index1 !== undefined && index2 === undefined) {
|
|
21
|
-
return -1
|
|
22
|
-
}
|
|
23
|
-
return index1! - index2!
|
|
24
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AstroError } from "astro/errors"
|
|
2
|
-
|
|
3
|
-
export const resolveDefaultLocale = ({
|
|
4
|
-
languages,
|
|
5
|
-
}: {
|
|
6
|
-
languages: {
|
|
7
|
-
code: string
|
|
8
|
-
isDefaultSiteLanguage?: boolean
|
|
9
|
-
}[]
|
|
10
|
-
}) => {
|
|
11
|
-
const defaultLanguage = languages.find((l) => l.isDefaultSiteLanguage)
|
|
12
|
-
if (!defaultLanguage) {
|
|
13
|
-
throw new AstroError(
|
|
14
|
-
"No default site language set",
|
|
15
|
-
"To fix the issue, set isDefaultSiteLanguage for one language in the LightNet configuration in your astro.config.mjs file.",
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
return defaultLanguage.code
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { compareMediaCollectionItems } from "../../../content/compare-media-collection-items"
|
|
2
|
-
import type { MediaItemEntry } from "../../../content/content-schema"
|
|
3
|
-
import { getMediaItems } from "../../../content/get-media-items"
|
|
4
|
-
|
|
5
|
-
const groupItemsByCollections = async () => {
|
|
6
|
-
const items = await getMediaItems()
|
|
7
|
-
items.forEach((item) => {
|
|
8
|
-
item.data.collections?.forEach(({ collection }) => {
|
|
9
|
-
if (!itemsByCollections.has(collection.id)) {
|
|
10
|
-
itemsByCollections.set(collection.id, [])
|
|
11
|
-
}
|
|
12
|
-
itemsByCollections.get(collection.id)?.push(item)
|
|
13
|
-
})
|
|
14
|
-
})
|
|
15
|
-
itemsByCollections.forEach((entries, collectionId) =>
|
|
16
|
-
entries.sort((a, b) => compareMediaCollectionItems(a, b, collectionId)),
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let isInitialized = false
|
|
21
|
-
const itemsByCollections = new Map<string, MediaItemEntry[]>()
|
|
22
|
-
|
|
23
|
-
export const getCollectionItems = async (collectionId: string) => {
|
|
24
|
-
if (!isInitialized) {
|
|
25
|
-
isInitialized = true
|
|
26
|
-
await groupItemsByCollections()
|
|
27
|
-
}
|
|
28
|
-
return itemsByCollections.get(collectionId) ?? []
|
|
29
|
-
}
|