lightnet 2.15.2
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 +428 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/__e2e__/detailPage.spec.ts +0 -0
- package/__e2e__/fixtures/basics/astro.config.mjs +38 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +17 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/astro-check +17 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwind +17 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/tailwindcss +17 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/tsc +17 -0
- package/__e2e__/fixtures/basics/node_modules/.bin/tsserver +17 -0
- package/__e2e__/fixtures/basics/package.json +19 -0
- package/__e2e__/fixtures/basics/public/favicon.svg +1 -0
- 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 +3 -0
- package/__e2e__/fixtures/basics/src/content/categories/teens.json +3 -0
- package/__e2e__/fixtures/basics/src/content/categories/theology.json +3 -0
- package/__e2e__/fixtures/basics/src/content/media/faithful-freestyle--en.json +13 -0
- package/__e2e__/fixtures/basics/src/content/media/how-to-kickflip--de.json +12 -0
- 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-collections/how-to-articles.json +3 -0
- package/__e2e__/fixtures/basics/src/content/media-types/book.json +9 -0
- package/__e2e__/fixtures/basics/src/content/media-types/video.json +7 -0
- package/__e2e__/fixtures/basics/src/content.config.ts +3 -0
- package/__e2e__/fixtures/basics/src/pages/[locale]/index.astro +14 -0
- package/__e2e__/fixtures/basics/src/translations/de.json +10 -0
- package/__e2e__/fixtures/basics/src/translations/en.json +10 -0
- package/__e2e__/fixtures/basics/tailwind.config.mjs +8 -0
- package/__e2e__/homepage.spec.ts +108 -0
- package/__e2e__/search.spec.ts +16 -0
- package/__e2e__/test-utils.ts +80 -0
- package/__tests__/pages/details-page/create-content-metadata.spec.ts +104 -0
- package/__tests__/utils/markdown.spec.ts +33 -0
- package/exports/components.ts +9 -0
- package/exports/content.ts +8 -0
- package/exports/details-page.ts +1 -0
- package/exports/i18n.ts +2 -0
- package/exports/index.ts +6 -0
- package/exports/utils.ts +2 -0
- package/package.json +54 -0
- package/playwright.config.ts +30 -0
- package/src/astro-integration/config.ts +185 -0
- package/src/astro-integration/integration.ts +74 -0
- package/src/astro-integration/project-context.ts +5 -0
- package/src/astro-integration/virtual.d.ts +14 -0
- package/src/astro-integration/vite-plugin-lightnet-config.ts +55 -0
- package/src/components/CategoriesOverview.astro +37 -0
- package/src/components/Gallery.astro +121 -0
- package/src/components/Hero.astro +82 -0
- package/src/components/HighlightSection.astro +71 -0
- package/src/components/Icon.tsx +27 -0
- package/src/components/MediaItemList.astro +84 -0
- package/src/components/Section.astro +49 -0
- package/src/content/astro-image.ts +14 -0
- package/src/content/content-schema-internal.ts +52 -0
- package/src/content/content-schema.ts +263 -0
- package/src/content/external-api.ts +7 -0
- package/src/content/get-categories.ts +15 -0
- package/src/content/get-languages.ts +14 -0
- package/src/content/get-media-items.ts +27 -0
- package/src/content/get-media-types.ts +23 -0
- package/src/content/query-media-items.ts +89 -0
- package/src/content/resolve-category-label.ts +20 -0
- package/src/i18n/get-locale-paths.ts +8 -0
- package/src/i18n/languages.ts +10 -0
- package/src/i18n/locals.d.ts +38 -0
- package/src/i18n/locals.ts +28 -0
- package/src/i18n/resolve-default-locale.ts +30 -0
- package/src/i18n/resolve-language.ts +25 -0
- package/src/i18n/resolve-locales.ts +5 -0
- package/src/i18n/translate.ts +64 -0
- package/src/i18n/translations/de.json +25 -0
- package/src/i18n/translations/en.json +25 -0
- package/src/layouts/MarkdownPage.astro +11 -0
- package/src/layouts/Page.astro +54 -0
- package/src/layouts/components/Favicon.astro +32 -0
- package/src/layouts/components/LanguagePicker.astro +38 -0
- package/src/layouts/components/Menu.astro +28 -0
- package/src/layouts/components/MenuItem.astro +21 -0
- package/src/layouts/components/PageNavigation.astro +65 -0
- package/src/layouts/components/PageTitle.astro +44 -0
- package/src/layouts/components/PreloadReact.tsx +3 -0
- package/src/pages/404.astro +14 -0
- package/src/pages/RedirectToDefaultLocale.astro +3 -0
- package/src/pages/api/search-response.ts +14 -0
- package/src/pages/api/search.ts +47 -0
- package/src/pages/details-page/DefaultDetails.astro +44 -0
- package/src/pages/details-page/DetailsPage.astro +53 -0
- package/src/pages/details-page/VideoDetails.astro +43 -0
- package/src/pages/details-page/components/Authors.astro +19 -0
- package/src/pages/details-page/components/Content.astro +73 -0
- package/src/pages/details-page/components/Cover.astro +35 -0
- package/src/pages/details-page/components/Description.astro +26 -0
- package/src/pages/details-page/components/MediaCollection.astro +39 -0
- package/src/pages/details-page/components/MediaCollections.astro +21 -0
- package/src/pages/details-page/components/OpenButton.astro +34 -0
- package/src/pages/details-page/components/SectionTitle.astro +8 -0
- package/src/pages/details-page/components/ShareButton.astro +58 -0
- package/src/pages/details-page/components/Title.astro +18 -0
- package/src/pages/details-page/components/VideoPlayer.astro +78 -0
- package/src/pages/details-page/components/details/Categories.astro +31 -0
- package/src/pages/details-page/components/details/Details.astro +17 -0
- package/src/pages/details-page/components/details/Label.astro +3 -0
- package/src/pages/details-page/components/details/Languages.astro +46 -0
- package/src/pages/details-page/utils/create-content-metadata.ts +78 -0
- package/src/pages/search-page/Search.tsx +71 -0
- package/src/pages/search-page/SearchPage.astro +51 -0
- package/src/pages/search-page/components/ResultList.tsx +135 -0
- package/src/pages/search-page/components/SearchFilter.tsx +189 -0
- package/src/pages/search-page/hooks/use-debounce.ts +17 -0
- package/src/pages/search-page/hooks/use-search.ts +95 -0
- package/src/pages/search-page/types.ts +9 -0
- package/src/pages/search-page/utils/search-translations.ts +22 -0
- package/src/pages/search-page/utils/use-provided-translations.ts +5 -0
- package/src/utils/markdown.ts +41 -0
- package/src/utils/paths.ts +45 -0
- package/src/utils/urls.ts +29 -0
- package/src/utils/verify-schema.ts +38 -0
- package/tailwind.config.ts +56 -0
- package/vitest.config.js +19 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@e2e/basics",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"private": "true",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@astrojs/check": "^0.9.4",
|
|
8
|
+
"@astrojs/react": "^4.1.6",
|
|
9
|
+
"@astrojs/tailwind": "^5.1.5",
|
|
10
|
+
"@lightnet/decap-admin": "^2.3.2",
|
|
11
|
+
"lightnet": "^2.15.0",
|
|
12
|
+
"astro": "^5.1.9",
|
|
13
|
+
"react": "^18.3.1",
|
|
14
|
+
"react-dom": "^18.3.1",
|
|
15
|
+
"sharp": "^0.33.5",
|
|
16
|
+
"tailwindcss": "^3.4.17",
|
|
17
|
+
"typescript": "^5.7.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="1000" height="1000" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><rect width="1000" height="1000" rx="50" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M125 75c-27.614 0-50 22.386-50 50v699.786l583.089-583.089c7.03-7.03 18.427-7.03 25.456 0l54.261 54.261c7.03 7.029 7.03 18.426 0 25.456L134.22 925H875c27.614 0 50-22.386 50-50V125c0-27.614-22.386-50-50-50H125Zm497.912 420.321c-43.19 13.289-66.806 59.165-52.965 102.523 13.871 43.106 59.913 67.443 103.104 54.155 43.051-13.428 66.806-59.164 52.851-102.409-5.509-17.636-16.528-32.088-30.648-42.055-20.238-14.757-46.817-20.072-72.315-12.181l-.027-.033Zm48.422 71.125c4.153 12.957-2.935 26.745-15.891 30.732-12.93 4.015-26.772-3.295-30.925-16.251-4.153-12.957 2.934-26.745 15.891-30.732 12.957-3.986 26.772 3.295 30.925 16.251Z" fill="url(#b)"/></g><defs><linearGradient id="b" x1="897" y1="98.923" x2="75" y2="934.345" gradientUnits="userSpaceOnUse"><stop stop-color="#2D03A4"/><stop offset="1" stop-color="#25212C"/></linearGradient><clipPath id="a"><path fill="#fff" d="M0 0h1000v1000H0z"/></clipPath></defs></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
export { getLocalePaths as getStaticPaths } from "lightnet/i18n"
|
|
3
|
+
|
|
4
|
+
import { Gallery, Page, Section } from "lightnet/components"
|
|
5
|
+
import { getMediaItems } from "lightnet/content"
|
|
6
|
+
|
|
7
|
+
const allItems = await getMediaItems({})
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<Page>
|
|
11
|
+
<Section title={Astro.locals.i18n.t("home.all-items")}>
|
|
12
|
+
<Gallery items={allItems} layout="book" />
|
|
13
|
+
</Section>
|
|
14
|
+
</Page>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"home.all-items": "Alle Artikel",
|
|
3
|
+
"category.christian-living": "Glaube leben",
|
|
4
|
+
"category.teens": "Teens",
|
|
5
|
+
"category.theology": "Theologie",
|
|
6
|
+
"type.book": "Buch",
|
|
7
|
+
"type.video": "Video",
|
|
8
|
+
"details.action.read": "Lesen",
|
|
9
|
+
"details.action.watch": "Anschauen"
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"home.all-items": "All items",
|
|
3
|
+
"category.christian-living": "Christian Living",
|
|
4
|
+
"category.teens": "Teens",
|
|
5
|
+
"category.theology": "Theology",
|
|
6
|
+
"type.book": "Book",
|
|
7
|
+
"type.video": "Video",
|
|
8
|
+
"details.action.read": "Read",
|
|
9
|
+
"details.action.watch": "Watch"
|
|
10
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { expect } from "@playwright/test"
|
|
2
|
+
|
|
3
|
+
import { lightnetTest } from "./test-utils"
|
|
4
|
+
|
|
5
|
+
const test = lightnetTest("./fixtures/basics/")
|
|
6
|
+
|
|
7
|
+
test("Should have title set", async ({ page, startLightnet }) => {
|
|
8
|
+
await startLightnet()
|
|
9
|
+
await expect(page).toHaveTitle("Basic Test")
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test("Should have header title that navigates to home page", async ({
|
|
13
|
+
page,
|
|
14
|
+
startLightnet,
|
|
15
|
+
}) => {
|
|
16
|
+
const ln = await startLightnet()
|
|
17
|
+
await page.getByRole("link", { name: "Basic Test" }).click()
|
|
18
|
+
|
|
19
|
+
await expect(page).toHaveURL(ln.resolveURL("/en/"))
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test("Should have item section", async ({ page, startLightnet }) => {
|
|
23
|
+
await startLightnet()
|
|
24
|
+
await expect(page.getByRole("heading", { name: "All items" })).toBeVisible()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test("Should navigate to search page from main menu", async ({
|
|
28
|
+
page,
|
|
29
|
+
startLightnet,
|
|
30
|
+
}) => {
|
|
31
|
+
const ln = await startLightnet()
|
|
32
|
+
await expect(
|
|
33
|
+
page.getByRole("button", { name: "Open Main Menu" }),
|
|
34
|
+
).toBeVisible()
|
|
35
|
+
await page
|
|
36
|
+
.getByRole("navigation")
|
|
37
|
+
.getByRole("button", { name: "Open Main Menu" })
|
|
38
|
+
.click()
|
|
39
|
+
await page.getByRole("navigation").getByText("Search").click()
|
|
40
|
+
|
|
41
|
+
await expect(page).toHaveURL(ln.resolveURL("/en/media"))
|
|
42
|
+
await expect(page.getByRole("heading", { name: "Search" })).toBeVisible()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test("Should switch languages", async ({ page, startLightnet }) => {
|
|
46
|
+
const ln = await startLightnet()
|
|
47
|
+
|
|
48
|
+
await expect(
|
|
49
|
+
page.getByRole("button", { name: "Select language" }),
|
|
50
|
+
).toBeVisible()
|
|
51
|
+
await page.getByRole("button", { name: "Select language" }).click()
|
|
52
|
+
await page.getByLabel("Select language").click()
|
|
53
|
+
await page.getByRole("link", { name: "Deutsch" }).click()
|
|
54
|
+
await expect(page).toHaveURL(ln.resolveURL("/de/"))
|
|
55
|
+
await expect(page.getByRole("heading")).toHaveText("Alle Artikel")
|
|
56
|
+
|
|
57
|
+
await page.getByLabel("Sprache auswählen").click()
|
|
58
|
+
await page.getByRole("link", { name: "English" }).click()
|
|
59
|
+
await expect(page).toHaveURL(ln.resolveURL("/en/"))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test("Should verify EN Detail media page url and title", async ({
|
|
63
|
+
page,
|
|
64
|
+
startLightnet,
|
|
65
|
+
}) => {
|
|
66
|
+
const ln = await startLightnet()
|
|
67
|
+
|
|
68
|
+
await page.getByRole("link", { name: "Faithful Freestyle" }).click()
|
|
69
|
+
await expect(
|
|
70
|
+
page.getByRole("heading", { name: "Faithful Freestyle" }),
|
|
71
|
+
).toBeVisible()
|
|
72
|
+
await expect(page).toHaveURL(
|
|
73
|
+
ln.resolveURL("/en/media/faithful-freestyle--en"),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
await page.goBack()
|
|
77
|
+
|
|
78
|
+
await page.getByRole("link", { name: "Kickflip Anleitung" }).click()
|
|
79
|
+
await expect(
|
|
80
|
+
page.getByRole("heading", { name: "Kickflip Anleitung" }),
|
|
81
|
+
).toBeVisible()
|
|
82
|
+
await expect(page).toHaveURL(ln.resolveURL("/en/media/how-to-kickflip--de"))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test("Should verify DE Detail media page url and title", async ({
|
|
86
|
+
page,
|
|
87
|
+
startLightnet,
|
|
88
|
+
}) => {
|
|
89
|
+
const ln = await startLightnet()
|
|
90
|
+
|
|
91
|
+
await page.getByLabel("Select language").click()
|
|
92
|
+
await page.getByRole("link", { name: "Deutsch" }).click()
|
|
93
|
+
await page.getByRole("link", { name: "Faithful Freestyle" }).click()
|
|
94
|
+
await expect(page).toHaveURL(
|
|
95
|
+
ln.resolveURL("/de/media/faithful-freestyle--en"),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
const lesenLink = page.getByRole("link", { name: "Lesen" })
|
|
99
|
+
await expect(lesenLink).toBeVisible()
|
|
100
|
+
await expect(lesenLink).toBeEnabled()
|
|
101
|
+
// await lesenLink.click()
|
|
102
|
+
// await page.waitForLoadState("networkidle")
|
|
103
|
+
// await page.goBack()
|
|
104
|
+
|
|
105
|
+
await expect(page.getByRole("button", { name: "Teilen" })).toBeVisible()
|
|
106
|
+
await expect(page.getByText("Sprache")).toBeVisible()
|
|
107
|
+
await expect(page.getByText("Kategorien")).toBeVisible()
|
|
108
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect } from "@playwright/test"
|
|
2
|
+
|
|
3
|
+
import { lightnetTest } from "./test-utils"
|
|
4
|
+
|
|
5
|
+
const test = lightnetTest("./fixtures/basics/")
|
|
6
|
+
|
|
7
|
+
test("Search should have heading section and URL", async ({
|
|
8
|
+
page,
|
|
9
|
+
startLightnet,
|
|
10
|
+
}) => {
|
|
11
|
+
const ln = await startLightnet()
|
|
12
|
+
|
|
13
|
+
await page.getByLabel("Search").click()
|
|
14
|
+
await expect(page.getByRole("heading", { name: "Search" })).toBeVisible()
|
|
15
|
+
await expect(page).toHaveURL(ln.resolveURL("/en/media"))
|
|
16
|
+
})
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is based on https://github.com/withastro/starlight/blob/main/packages/starlight/__e2e__/test-utils.ts
|
|
3
|
+
* Here is the source license of the original code.
|
|
4
|
+
*
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2023 [Astro contributors](https://github.com/withastro/starlight/graphs/contributors)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { fileURLToPath } from "node:url"
|
|
29
|
+
|
|
30
|
+
import { type Page, test as baseTest } from "@playwright/test"
|
|
31
|
+
import { build, preview } from "astro"
|
|
32
|
+
|
|
33
|
+
export { expect, type Locator } from "@playwright/test"
|
|
34
|
+
|
|
35
|
+
process.env.ASTRO_TELEMETRY_DISABLED = "true"
|
|
36
|
+
process.env.ASTRO_DISABLE_UPDATE_CHECK = "true"
|
|
37
|
+
export function lightnetTest(fixturePath: string) {
|
|
38
|
+
const root = fileURLToPath(new URL(fixturePath, import.meta.url))
|
|
39
|
+
|
|
40
|
+
let server: Server | null = null
|
|
41
|
+
const test = baseTest.extend<{
|
|
42
|
+
startLightnet: (path?: string) => Promise<LightNetPage>
|
|
43
|
+
}>({
|
|
44
|
+
startLightnet: ({ page }, use) =>
|
|
45
|
+
use(async (path) => {
|
|
46
|
+
if (!server) {
|
|
47
|
+
await build({ logLevel: "error", root })
|
|
48
|
+
server = await preview({ logLevel: "error", root })
|
|
49
|
+
}
|
|
50
|
+
const ln = new LightNetPage(server, page)
|
|
51
|
+
await ln.goto(path ?? "/")
|
|
52
|
+
return ln
|
|
53
|
+
}),
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test.afterAll(async () => {
|
|
57
|
+
await server?.stop()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return test
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// A Playwright test fixture accessible from within all tests.
|
|
64
|
+
class LightNetPage {
|
|
65
|
+
constructor(
|
|
66
|
+
private readonly server: Server,
|
|
67
|
+
private readonly page: Page,
|
|
68
|
+
) {}
|
|
69
|
+
|
|
70
|
+
// Navigate to a URL relative to the server used during a test run and return the resource response.
|
|
71
|
+
goto(path: string) {
|
|
72
|
+
return this.page.goto(this.resolveURL(path))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
resolveURL(path: string) {
|
|
76
|
+
return `http://localhost:${this.server.port}${path.replace(/^\/?/, "/")}`
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type Server = Awaited<ReturnType<typeof preview>>
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
name: "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
|
+
name: "youtube.com",
|
|
23
|
+
isExternal: true,
|
|
24
|
+
extension: "",
|
|
25
|
+
type: "link",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
url: "https://some.host/some.pDf",
|
|
30
|
+
expected: {
|
|
31
|
+
canBeOpened: true,
|
|
32
|
+
type: "text",
|
|
33
|
+
target: "_blank",
|
|
34
|
+
name: "some",
|
|
35
|
+
isExternal: true,
|
|
36
|
+
extension: "pdf",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
url: "https://some.host/some.unknown",
|
|
41
|
+
expected: {
|
|
42
|
+
type: "link",
|
|
43
|
+
canBeOpened: false,
|
|
44
|
+
target: "_blank",
|
|
45
|
+
name: "some",
|
|
46
|
+
isExternal: true,
|
|
47
|
+
extension: "unknown",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
url: "/files/my.pdf",
|
|
52
|
+
expected: {
|
|
53
|
+
canBeOpened: true,
|
|
54
|
+
type: "text",
|
|
55
|
+
target: "_self",
|
|
56
|
+
name: "my",
|
|
57
|
+
isExternal: false,
|
|
58
|
+
extension: "pdf",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
url: "/paths/my-id",
|
|
63
|
+
expected: {
|
|
64
|
+
canBeOpened: true,
|
|
65
|
+
target: "_self",
|
|
66
|
+
name: "my-id",
|
|
67
|
+
isExternal: false,
|
|
68
|
+
extension: "",
|
|
69
|
+
type: "link",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
url: "/files/my.unknown",
|
|
74
|
+
expected: {
|
|
75
|
+
canBeOpened: false,
|
|
76
|
+
target: "_self",
|
|
77
|
+
name: "my",
|
|
78
|
+
isExternal: false,
|
|
79
|
+
type: "link",
|
|
80
|
+
extension: "unknown",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
url: "/some.zip",
|
|
85
|
+
expected: {
|
|
86
|
+
canBeOpened: false,
|
|
87
|
+
target: "_self",
|
|
88
|
+
name: "some",
|
|
89
|
+
isExternal: false,
|
|
90
|
+
extension: "zip",
|
|
91
|
+
type: "package",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
].forEach(({ url, expected }) => {
|
|
95
|
+
test(`Should create content metadata for url ${url}`, () => {
|
|
96
|
+
expect(createContentMetadata({ url })).toMatchObject(expected)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test("Should override name with input", () => {
|
|
101
|
+
expect(
|
|
102
|
+
createContentMetadata({ url: "/path/to/a.file", name: "My file" }),
|
|
103
|
+
).toMatchObject({ name: "My file" })
|
|
104
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { expect, test } from "vitest"
|
|
2
|
+
|
|
3
|
+
import { markdownToText } from "../../src/utils/markdown"
|
|
4
|
+
|
|
5
|
+
test("Should remove headers", () => {
|
|
6
|
+
expect(markdownToText("# H1\n## H2 words#")).toBe("H1\nH2 words#")
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test("Should remove inline modifiers", async () => {
|
|
10
|
+
expect(markdownToText("this is **some bold** and _italic_ text")).toBe(
|
|
11
|
+
"this is some bold and italic text",
|
|
12
|
+
)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test("Should remove list", () => {
|
|
16
|
+
expect(markdownToText("- this is **bold**\n- this is normal")).toBe(
|
|
17
|
+
"this is bold\nthis is normal",
|
|
18
|
+
)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test("Should convert links", () => {
|
|
22
|
+
expect(markdownToText("some [link](https://link.com?foo)")).toBe("some link")
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test("Should remove images", () => {
|
|
26
|
+
expect(markdownToText("")).toBe("a image")
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test("Should remove block quotes", () => {
|
|
30
|
+
expect(markdownToText("> block quote\n>more quote")).toBe(
|
|
31
|
+
"block quote\nmore quote",
|
|
32
|
+
)
|
|
33
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as CategoriesOverview } from "../src/components/CategoriesOverview.astro"
|
|
2
|
+
export { default as Gallery } from "../src/components/Gallery.astro"
|
|
3
|
+
export { default as Hero } from "../src/components/Hero.astro"
|
|
4
|
+
export { default as HighlightSection } from "../src/components/HighlightSection.astro"
|
|
5
|
+
export { default as Icon } from "../src/components/Icon"
|
|
6
|
+
export { default as MediaItemList } from "../src/components/MediaItemList.astro"
|
|
7
|
+
export { default as Section } from "../src/components/Section.astro"
|
|
8
|
+
export { default as MarkdownPage } from "../src/layouts/MarkdownPage.astro"
|
|
9
|
+
export { default as Page } from "../src/layouts/Page.astro"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MediaCollections } from "../src/pages/details-page/components/MediaCollections.astro"
|
package/exports/i18n.ts
ADDED
package/exports/index.ts
ADDED
package/exports/utils.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lightnet",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"version": "2.15.2",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"astro-integration"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./exports/index.ts",
|
|
11
|
+
"./content": "./exports/content.ts",
|
|
12
|
+
"./utils": "./exports/utils.ts",
|
|
13
|
+
"./components": "./exports/components.ts",
|
|
14
|
+
"./details-page": "./exports/details-page.ts",
|
|
15
|
+
"./i18n": "./exports/i18n.ts",
|
|
16
|
+
"./locals": "./src/i18n/locals.ts",
|
|
17
|
+
"./tailwind.config.ts": "./tailwind.config.ts",
|
|
18
|
+
"./layouts/MarkdownPage.astro": "./src/layouts/MarkdownPage.astro",
|
|
19
|
+
"./pages/404.astro": "./src/pages/404.astro",
|
|
20
|
+
"./pages/RedirectToDefaultLocale.astro": "./src/pages/RedirectToDefaultLocale.astro",
|
|
21
|
+
"./pages/SearchPage.astro": "./src/pages/search-page/SearchPage.astro",
|
|
22
|
+
"./pages/DetailsPage.astro": "./src/pages/details-page/DetailsPage.astro",
|
|
23
|
+
"./pages/api/search.ts": "./src/pages/api/search.ts"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@astrojs/react": "^4.1.0",
|
|
27
|
+
"@astrojs/tailwind": "^5.1.0",
|
|
28
|
+
"astro": "^5.1.0",
|
|
29
|
+
"react": "^18.3.1",
|
|
30
|
+
"react-dom": "^18.3.1",
|
|
31
|
+
"sharp": "^0.33.4",
|
|
32
|
+
"tailwindcss": "^3.4.4",
|
|
33
|
+
"typescript": "^5.5.3"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
37
|
+
"@iconify/tailwind": "^1.2.0",
|
|
38
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
39
|
+
"@types/react": "^18.3.18",
|
|
40
|
+
"daisyui": "^4.12.23",
|
|
41
|
+
"fuse.js": "^7.0.0",
|
|
42
|
+
"marked": "^15.0.6",
|
|
43
|
+
"zod-validation-error": "^3.4.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@playwright/test": "^1.50.0",
|
|
47
|
+
"@types/node": "^22.10.10",
|
|
48
|
+
"vitest": "^3.0.4"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"test": "vitest",
|
|
52
|
+
"e2e": "playwright install --with-deps chromium && playwright test"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
9
|
+
forbidOnly: !!process.env.CI,
|
|
10
|
+
/* Retry on CI only */
|
|
11
|
+
retries: process.env.CI ? 2 : 0,
|
|
12
|
+
/* Opt out of parallel tests. */
|
|
13
|
+
workers: 1,
|
|
14
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
15
|
+
reporter: "html",
|
|
16
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
17
|
+
use: {
|
|
18
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
19
|
+
trace: "on-first-retry",
|
|
20
|
+
viewport: { width: 1280, height: 800 }, // Set default viewport
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/* Configure projects for major browsers */
|
|
24
|
+
projects: [
|
|
25
|
+
{
|
|
26
|
+
name: "chromium",
|
|
27
|
+
use: { ...devices["Desktop Chrome"] },
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
})
|