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.
Files changed (111) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/exports/content.ts +7 -2
  3. package/exports/i18n.ts +0 -1
  4. package/exports/index.ts +1 -5
  5. package/exports/utils.ts +0 -1
  6. package/package.json +26 -12
  7. package/src/astro-integration/config.ts +60 -49
  8. package/src/astro-integration/integration.ts +13 -24
  9. package/src/astro-integration/tailwind.ts +86 -0
  10. package/src/astro-integration/validators/validate-inline-translations.ts +51 -0
  11. package/src/astro-integration/validators/validate-languages.ts +39 -0
  12. package/src/astro-integration/virtual.d.ts +8 -6
  13. package/src/astro-integration/vite-plugin-lightnet-config.ts +29 -9
  14. package/src/components/CarouselSection.astro +7 -11
  15. package/src/components/CategoriesSection.astro +2 -2
  16. package/src/components/HighlightSection.astro +4 -7
  17. package/src/components/Icon.tsx +2 -2
  18. package/src/components/MediaGallerySection.astro +88 -68
  19. package/src/components/MediaList.astro +9 -7
  20. package/src/components/SearchInput.astro +7 -4
  21. package/src/components/Section.astro +7 -5
  22. package/src/components/VideoPlayer.astro +2 -3
  23. package/src/content/content-schema.ts +129 -142
  24. package/src/content/get-categories.ts +52 -28
  25. package/src/content/get-languages.ts +29 -8
  26. package/src/content/get-media-collections.ts +43 -0
  27. package/src/content/get-media-types.ts +41 -7
  28. package/src/content/query-media-items.ts +23 -13
  29. package/src/i18n/bcp-47.ts +8 -0
  30. package/src/i18n/get-locale-paths.ts +1 -3
  31. package/src/i18n/locals.d.ts +21 -3
  32. package/src/i18n/locals.ts +18 -11
  33. package/src/i18n/resolve-current-locale.ts +18 -0
  34. package/src/i18n/resolve-language.ts +10 -5
  35. package/src/i18n/translate-map.ts +70 -0
  36. package/src/i18n/translate.ts +68 -47
  37. package/src/layouts/Page.astro +5 -3
  38. package/src/layouts/components/LanguagePicker.astro +22 -17
  39. package/src/layouts/components/Menu.astro +2 -5
  40. package/src/layouts/components/MenuItem.astro +1 -1
  41. package/src/layouts/components/PageNavigation.astro +29 -29
  42. package/src/layouts/components/PageTitle.astro +23 -7
  43. package/src/pages/404Route.astro +2 -1
  44. package/src/pages/RootRoute.astro +6 -1
  45. package/src/pages/details-page/DefaultDetailsPage.astro +9 -2
  46. package/src/pages/details-page/DetailsPageRoute.astro +1 -2
  47. package/src/pages/details-page/components/AudioPanel.astro +7 -3
  48. package/src/pages/details-page/components/AudioPlayer.astro +2 -2
  49. package/src/pages/details-page/components/ContentSection.astro +67 -44
  50. package/src/pages/details-page/components/MediaCollection.astro +8 -4
  51. package/src/pages/details-page/components/MediaCollectionsSection.astro +3 -6
  52. package/src/pages/details-page/components/main-details/EditButton.astro +22 -10
  53. package/src/pages/details-page/components/main-details/OpenButton.astro +17 -12
  54. package/src/pages/details-page/components/main-details/ShareButton.astro +3 -2
  55. package/src/pages/details-page/components/more-details/Categories.astro +5 -3
  56. package/src/pages/details-page/components/more-details/Languages.astro +12 -7
  57. package/src/pages/details-page/utils/create-content-metadata.ts +24 -9
  58. package/src/pages/details-page/utils/get-translations.ts +6 -0
  59. package/src/pages/search-page/components/LoadingSkeleton.tsx +6 -5
  60. package/src/pages/search-page/components/SearchFilter.astro +10 -21
  61. package/src/pages/search-page/components/SearchFilter.tsx +2 -2
  62. package/src/pages/search-page/components/SearchList.astro +10 -7
  63. package/src/pages/search-page/components/SearchListItem.tsx +5 -4
  64. package/src/pages/search-page/hooks/use-search.ts +5 -2
  65. package/src/utils/lazy.ts +20 -0
  66. package/src/utils/paths.ts +40 -3
  67. package/src/utils/urls.ts +1 -2
  68. package/src/utils/verify-schema.ts +12 -10
  69. package/tailwind.config.ts +1 -25
  70. package/__e2e__/admin.spec.ts +0 -20
  71. package/__e2e__/basics-fixture.ts +0 -77
  72. package/__e2e__/fixtures/basics/astro.config.mjs +0 -40
  73. package/__e2e__/fixtures/basics/node_modules/.bin/astro +0 -21
  74. package/__e2e__/fixtures/basics/node_modules/.bin/tailwind +0 -21
  75. package/__e2e__/fixtures/basics/node_modules/.bin/tailwindcss +0 -21
  76. package/__e2e__/fixtures/basics/node_modules/.bin/tsc +0 -21
  77. package/__e2e__/fixtures/basics/node_modules/.bin/tsserver +0 -21
  78. package/__e2e__/fixtures/basics/package.json +0 -21
  79. package/__e2e__/fixtures/basics/public/favicon.svg +0 -1
  80. package/__e2e__/fixtures/basics/public/files/example.pdf +0 -0
  81. package/__e2e__/fixtures/basics/src/assets/logo.png +0 -0
  82. package/__e2e__/fixtures/basics/src/content/categories/christian-living.json +0 -3
  83. package/__e2e__/fixtures/basics/src/content/categories/teens.json +0 -3
  84. package/__e2e__/fixtures/basics/src/content/categories/theology.json +0 -3
  85. package/__e2e__/fixtures/basics/src/content/media/faithful-freestyle--en.json +0 -13
  86. package/__e2e__/fixtures/basics/src/content/media/how-to-kickflip--de.json +0 -12
  87. package/__e2e__/fixtures/basics/src/content/media/images/cover.jpg +0 -0
  88. package/__e2e__/fixtures/basics/src/content/media/images/how-to-kickflip--en.webp +0 -0
  89. package/__e2e__/fixtures/basics/src/content/media/skate-sounds--en.json +0 -15
  90. package/__e2e__/fixtures/basics/src/content/media-collections/how-to-articles.json +0 -3
  91. package/__e2e__/fixtures/basics/src/content/media-types/audio.json +0 -7
  92. package/__e2e__/fixtures/basics/src/content/media-types/book.json +0 -9
  93. package/__e2e__/fixtures/basics/src/content/media-types/video.json +0 -7
  94. package/__e2e__/fixtures/basics/src/content.config.ts +0 -3
  95. package/__e2e__/fixtures/basics/src/pages/[locale]/index.astro +0 -16
  96. package/__e2e__/fixtures/basics/src/translations/de.yml +0 -9
  97. package/__e2e__/fixtures/basics/src/translations/en.yml +0 -9
  98. package/__e2e__/fixtures/basics/tailwind.config.mjs +0 -8
  99. package/__e2e__/global.teardown.ts +0 -5
  100. package/__e2e__/homepage.spec.ts +0 -123
  101. package/__e2e__/search.spec.ts +0 -14
  102. package/__tests__/pages/details-page/create-content-metadata.spec.ts +0 -135
  103. package/__tests__/utils/markdown.spec.ts +0 -74
  104. package/__tests__/utils/urls.spec.ts +0 -27
  105. package/playwright.config.ts +0 -31
  106. package/src/astro-integration/project-context.ts +0 -5
  107. package/src/content/compare-media-collection-items.ts +0 -24
  108. package/src/i18n/resolve-default-locale.ts +0 -19
  109. package/src/i18n/resolve-locales.ts +0 -5
  110. package/src/pages/details-page/utils/get-collection-items.ts +0 -29
  111. package/vitest.config.js +0 -20
@@ -2,35 +2,26 @@
2
2
  import config from "virtual:lightnet/config"
3
3
 
4
4
  import { getUsedCategories } from "../../../content/get-categories"
5
- import { contentLanguages } from "../../../content/get-languages"
6
- import { getMediaTypes } from "../../../content/get-media-types"
5
+ import { getUsedLanguages } from "../../../content/get-languages"
6
+ import { getUsedMediaTypes } from "../../../content/get-media-types"
7
7
  import { prepareI18nConfig } from "../../../i18n/react/prepare-i18n-config"
8
8
  import SearchFilterReact from "./SearchFilter.tsx"
9
9
 
10
- const { t, currentLocale } = Astro.locals.i18n
10
+ const { currentLocale, tMap } = Astro.locals.i18n
11
11
 
12
- const sortByLabelText = (array: { id: string; labelText: string }[]) =>
13
- array.sort((a, b) => a.labelText.localeCompare(b.labelText, currentLocale))
14
-
15
- const categories = (await getUsedCategories(currentLocale, t)).map(
12
+ const categories = (await getUsedCategories(currentLocale, tMap)).map(
16
13
  ({ id, labelText }) => ({ id, labelText }),
17
14
  )
18
15
 
19
- const mediaTypes = sortByLabelText(
20
- (await getMediaTypes()).map((type) => ({
21
- id: type.id,
22
- labelText: t(type.data.label),
23
- })),
16
+ const mediaTypes = (await getUsedMediaTypes(currentLocale, tMap)).map(
17
+ ({ id, labelText }) => ({ id, labelText }),
24
18
  )
25
19
 
26
- const languages = sortByLabelText(
27
- contentLanguages.map((language) => ({
28
- id: language.code,
29
- labelText: t(language.label),
30
- })),
20
+ const languages = (await getUsedLanguages(currentLocale, tMap)).map(
21
+ ({ code: id, labelText }) => ({ id, labelText }),
31
22
  )
32
23
 
33
- const languageFilterEnabled = contentLanguages.length > 1
24
+ const languageFilterEnabled = languages.length > 1
34
25
  const typesFilterEnabled = mediaTypes.length > 1
35
26
  // Not every media item has a category. So it makes
36
27
  // sense to have the filter when there is only one category.
@@ -38,9 +29,7 @@ const categoriesFilterEnabled = categories.length > 0
38
29
 
39
30
  const filterByLocale = !!config.searchPage?.filterByLocale
40
31
  let initialLanguageFilter: string | undefined = undefined
41
- const hasContentLanguage = contentLanguages.find(
42
- ({ code }) => code === currentLocale,
43
- )
32
+ const hasContentLanguage = languages.find(({ id }) => id === currentLocale)
44
33
  if (
45
34
  filterByLocale &&
46
35
  currentLocale &&
@@ -1,6 +1,6 @@
1
+ import { SearchIcon } from "lucide-react"
1
2
  import { useRef } from "react"
2
3
 
3
- import Icon from "../../../components/Icon"
4
4
  import { createI18n, type I18nConfig } from "../../../i18n/react/i18n-context"
5
5
  import { useDebounce } from "../hooks/use-debounce"
6
6
  import { useSearchQueryParam } from "../hooks/use-search-query-param"
@@ -57,7 +57,7 @@ export default function SearchFilter({
57
57
  onInput={(e) => debouncedSetSearch(e.currentTarget.value)}
58
58
  onKeyDown={(e) => e.key === "Enter" && searchInput.current?.blur()}
59
59
  />
60
- <Icon className="text-xl mdi--magnify" ariaLabel="" />
60
+ <SearchIcon className="shrink-0 text-gray-700" />
61
61
  </label>
62
62
  <div className="mb-8 grid grid-cols-1 gap-2 sm:grid-cols-3 sm:gap-6 md:mb-10">
63
63
  {languageFilterEnabled && (
@@ -2,15 +2,15 @@
2
2
  import { getCollection } from "astro:content"
3
3
 
4
4
  import { getUsedCategories } from "../../../content/get-categories"
5
- import { contentLanguages } from "../../../content/get-languages"
5
+ import { getUsedLanguages } from "../../../content/get-languages"
6
6
  import { getMediaTypes } from "../../../content/get-media-types"
7
7
  import { prepareI18nConfig } from "../../../i18n/react/prepare-i18n-config"
8
8
  import SearchListReact from "./SearchList.tsx"
9
9
 
10
- const { t, currentLocale } = Astro.locals.i18n
10
+ const { currentLocale, tMap } = Astro.locals.i18n
11
11
 
12
12
  const categories: Record<string, string> = {}
13
- for (const { id, labelText } of await getUsedCategories(currentLocale, t)) {
13
+ for (const { id, labelText } of await getUsedCategories(currentLocale, tMap)) {
14
14
  categories[id] = labelText
15
15
  }
16
16
 
@@ -18,23 +18,26 @@ const mediaTypes = Object.fromEntries(
18
18
  (await getMediaTypes()).map((type) => [
19
19
  type.id,
20
20
  {
21
- labelText: t(type.data.label),
21
+ labelText: tMap(type.data.label, {
22
+ path: ["media-types", type.id, "label"],
23
+ }),
22
24
  icon: type.data.icon,
23
25
  coverImageStyle: type.data.coverImageStyle,
24
26
  },
25
27
  ]),
26
28
  )
27
29
 
30
+ const contentLanguagesList = await getUsedLanguages(currentLocale, tMap)
28
31
  const languages = Object.fromEntries(
29
- contentLanguages.map((language) => [
32
+ contentLanguagesList.map((language) => [
30
33
  language.code,
31
- { direction: language.direction, labelText: t(language.label) },
34
+ { direction: language.direction, labelText: language.labelText },
32
35
  ]),
33
36
  )
34
37
 
35
38
  const mediaItemsTotal = (await getCollection("media")).length
36
39
 
37
- const showLanguage = contentLanguages.length > 1
40
+ const showLanguage = contentLanguagesList.length > 1
38
41
 
39
42
  const i18nConfig = prepareI18nConfig(Astro.locals.i18n, [
40
43
  "ln.search.no-results",
@@ -1,3 +1,5 @@
1
+ import { ChevronRightIcon } from "lucide-react"
2
+
1
3
  import CoverImageDecorator from "../../../components/CoverImageDecorator"
2
4
  import Icon from "../../../components/Icon"
3
5
  import { useI18n } from "../../../i18n/react/use-i18n"
@@ -32,6 +34,7 @@ export default function SearchListItem({
32
34
  }: Props) {
33
35
  const { currentLocale, direction } = useI18n()
34
36
  const coverImageStyle = mediaTypes[item.type].coverImageStyle
37
+ const iconDirectionClass = direction === "rtl" ? "scale-x-[-1]" : ""
35
38
  return (
36
39
  <a
37
40
  href={detailsPagePath(currentLocale, {
@@ -98,10 +101,8 @@ export default function SearchListItem({
98
101
  </p>
99
102
  </div>
100
103
  </div>
101
- <Icon
102
- className="my-auto me-4 ms-2 hidden shrink-0 text-2xl text-gray-300 mdi--chevron-right sm:block md:group-hover:text-primary"
103
- flipIcon={direction === "rtl"}
104
- ariaLabel=""
104
+ <ChevronRightIcon
105
+ className={`my-auto me-4 ms-2 hidden shrink-0 text-gray-300 sm:block md:group-hover:text-primary ${iconDirectionClass}`}
105
106
  />
106
107
  </a>
107
108
  )
@@ -1,6 +1,7 @@
1
1
  import Fuse from "fuse.js"
2
2
  import { useEffect, useMemo, useRef, useState } from "react"
3
3
 
4
+ import { pathWithBase } from "../../../utils/paths"
4
5
  import type { SearchItem, SearchResponse } from "../api/search-response"
5
6
  import { observeSearchQuery, type SearchQuery } from "../utils/search-query"
6
7
 
@@ -10,6 +11,8 @@ interface Context {
10
11
  languages: Record<string, { labelText: string }>
11
12
  }
12
13
 
14
+ const SEARCH_API_PATH = pathWithBase("/api/internal/search.json")
15
+
13
16
  export function useSearch({ categories, mediaTypes, languages }: Context) {
14
17
  const fuse = useRef<Fuse<SearchItem>>(undefined)
15
18
  const [allItems, setAllItems] = useState<SearchItem[]>([])
@@ -28,10 +31,10 @@ export function useSearch({ categories, mediaTypes, languages }: Context) {
28
31
  })
29
32
  const fetchData = async () => {
30
33
  try {
31
- const response = await fetch("/api/internal/search.json")
34
+ const response = await fetch(SEARCH_API_PATH)
32
35
  if (!response.ok) {
33
36
  throw new Error(
34
- "Was not able to load search results from /api/internal/search.json.",
37
+ `Was not able to load search results from ${SEARCH_API_PATH}.`,
35
38
  )
36
39
  }
37
40
  const { items }: SearchResponse = await response.json()
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Creates a lazily initialized value and caches the computed result after the
3
+ * first access.
4
+ *
5
+ * @param compute Function that produces the value when `get()` is called for
6
+ * the first time.
7
+ * @returns An object with a `get()` method that returns the cached value.
8
+ */
9
+ export const lazy = <TReturn>(compute: () => TReturn) => {
10
+ let initialized = false
11
+ let value: TReturn
12
+ const get = () => {
13
+ if (!initialized) {
14
+ value = compute()
15
+ initialized = true
16
+ }
17
+ return value
18
+ }
19
+ return { get }
20
+ }
@@ -1,3 +1,38 @@
1
+ /**
2
+ * Prefix a site-internal path with Astro's configured base path.
3
+ *
4
+ * This helper trims any trailing slash from `BASE_URL`, ensures the input
5
+ * path starts with a leading slash, and concatenates the two values.
6
+ * Absolute URLs are out of scope for this helper.
7
+ *
8
+ * @param path internal path such as "/en/media", "/api/internal/search.json", or "/"
9
+ * @returns base-aware internal path
10
+ */
11
+ export function pathWithBase(path: string) {
12
+ const normalizedBase = import.meta.env.BASE_URL.replace(/\/+$/, "")
13
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`
14
+ return `${normalizedBase}${normalizedPath}`
15
+ }
16
+
17
+ /**
18
+ * Remove Astro's configured base path from a pathname when present.
19
+ *
20
+ * @param pathname pathname such as "/docs/en/media" or "/en/media"
21
+ * @param base Astro base path. Defaults to `import.meta.env.BASE_URL`.
22
+ * @returns pathname without the base prefix
23
+ */
24
+ export function pathWithoutBase(
25
+ pathname: string,
26
+ base = import.meta.env.BASE_URL,
27
+ ) {
28
+ const normalizedBase = base !== "/" ? base.replace(/\/+$/, "") : ""
29
+
30
+ return normalizedBase &&
31
+ (pathname === normalizedBase || pathname.startsWith(`${normalizedBase}/`))
32
+ ? pathname.slice(normalizedBase.length) || "/"
33
+ : pathname
34
+ }
35
+
1
36
  /**
2
37
  * Build path to media item page.
3
38
  *
@@ -9,7 +44,7 @@ export function detailsPagePath(
9
44
  locale: string | undefined,
10
45
  { id }: { id: string },
11
46
  ) {
12
- return `/${locale}/media/${id}`
47
+ return pathWithBase(`/${locale}/media/${id}`)
13
48
  }
14
49
 
15
50
  /**
@@ -42,7 +77,7 @@ export function searchPagePath(
42
77
  searchParams.append("type", filter.type)
43
78
  }
44
79
  const query = searchParams.size ? `?${searchParams.toString()}` : ""
45
- return `/${locale}/media${query}`
80
+ return pathWithBase(`/${locale}/media${query}`)
46
81
  }
47
82
 
48
83
  /**
@@ -56,5 +91,7 @@ export function searchPagePath(
56
91
  * @returns resolved path. Eg. '/en/about' for input "en" and "/about"
57
92
  */
58
93
  export function localizePath(locale: string | undefined, path: string) {
59
- return `${locale ? `/${locale}` : ""}/${path.replace(/^\//, "")}`
94
+ return pathWithBase(
95
+ `${locale ? `/${locale}` : ""}/${path.replace(/^\//, "")}`,
96
+ )
60
97
  }
package/src/utils/urls.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import config from "virtual:lightnet/config"
2
- import projectContext from "virtual:lightnet/project-context"
3
2
 
4
3
  /**
5
4
  * Test if a given url is outside this site.
@@ -21,7 +20,7 @@ export function isExternalUrl(url: string) {
21
20
  if (config.internalDomains.includes(parsedUrl.hostname)) {
22
21
  return false
23
22
  }
24
- const { site } = projectContext
23
+ const { SITE: site } = import.meta.env
25
24
  if (!site) {
26
25
  return true
27
26
  }
@@ -8,10 +8,11 @@ export async function verifySchemaAsync<T extends z.Schema>(
8
8
  hint: string | ((id: string | undefined) => string),
9
9
  ): Promise<z.output<T>> {
10
10
  const parsed = await schema.safeParseAsync(toVerify)
11
- if (!parsed.success) {
12
- throwParseError(toVerify, errorMessage, hint, parsed)
11
+ if (parsed.success) {
12
+ return parsed.data
13
13
  }
14
- return parsed.data
14
+
15
+ throwParseError(toVerify, errorMessage, hint, parsed)
15
16
  }
16
17
 
17
18
  export function verifySchema<T extends z.Schema>(
@@ -21,24 +22,25 @@ export function verifySchema<T extends z.Schema>(
21
22
  hint: string | ((id: string | undefined) => string),
22
23
  ): z.output<T> {
23
24
  const parsed = schema.safeParse(toVerify, {})
24
- if (!parsed.success) {
25
- throwParseError(toVerify, errorMessage, hint, parsed)
25
+ if (parsed.success) {
26
+ return parsed.data
26
27
  }
27
- return parsed.data
28
+
29
+ throwParseError(toVerify, errorMessage, hint, parsed)
28
30
  }
29
31
 
30
32
  function throwParseError(
31
33
  toVerify: unknown,
32
34
  errorMessage: string | ((id: string | undefined) => string),
33
35
  hint: string | ((id: string | undefined) => string),
34
- parsed: z.SafeParseError<unknown>,
35
- ) {
36
+ parsed: z.ZodSafeParseError<unknown>,
37
+ ): never {
36
38
  const id = z.object({ id: z.string() }).safeParse(toVerify).data?.id
37
39
  const message =
38
40
  typeof errorMessage === "string" ? errorMessage : errorMessage(id)
39
41
  const hintFinal = typeof hint === "string" ? hint : hint(id)
40
- const issues = parsed.error.errors
41
- .map((e) => `- ${e.path.join(".")}: ${e.message}`)
42
+ const issues = parsed.error.issues
43
+ .map((issue) => `- ${issue.path.join(".")}: ${issue.message}`)
42
44
  .join("\n")
43
45
  throw new AstroError(message, `${hintFinal}\n\n${issues}`)
44
46
  }
@@ -1,6 +1,5 @@
1
1
  import { addIconSelectors } from "@iconify/tailwind"
2
2
  import typography from "@tailwindcss/typography"
3
- import daisyui from "daisyui"
4
3
  import type { Config } from "tailwindcss"
5
4
 
6
5
  const DEFAULT_COLOR_PRIMARY = "#E6B15C"
@@ -27,30 +26,7 @@ export function lightnetStyles({
27
26
  },
28
27
  },
29
28
  },
30
- daisyui: {
31
- themes: [
32
- {
33
- lightnet: {
34
- primary,
35
- secondary: primary,
36
- accent: primary,
37
- neutral: "#030712",
38
- error: "#9f1239",
39
- "base-100": "#f9fafb",
40
-
41
- "--rounded-box": "0.375rem", // border radius rounded-box utility class, used in card and other large boxes
42
- "--rounded-btn": "0.375rem", // border radius rounded-btn utility class, used in buttons and similar element
43
- "--rounded-badge": "0.375rem", // border radius rounded-badge utility class, used in badges and similar
44
- "--tab-radius": "0.375rem", // border radius of tabs
45
- },
46
- },
47
- ],
48
- base: false, // applies background color and foreground color for root element by default
49
- utils: true, // adds responsive and modifier utility classes
50
- logs: false, // Shows info about daisyUI version and used config in the console when building your CSS
51
- prefix: "dy-",
52
- },
53
- plugins: [typography, daisyui, addIconSelectors(["mdi"])],
29
+ plugins: [typography, addIconSelectors(["mdi", "lucide"])],
54
30
  }
55
31
  }
56
32
 
@@ -1,20 +0,0 @@
1
- import { expect } from "@playwright/test"
2
-
3
- import { test } from "./basics-fixture"
4
-
5
- test.describe("Edit button on details page", () => {
6
- test("Should not show `Edit` button on details page by default.", async ({
7
- page,
8
- lightnet,
9
- }) => {
10
- await lightnet()
11
-
12
- await page.getByRole("link", { name: "Faithful Freestyle" }).click()
13
- await expect(
14
- page.getByRole("heading", { name: "Faithful Freestyle" }),
15
- ).toBeVisible()
16
-
17
- const editButton = page.locator("#edit-btn")
18
- await expect(editButton).toBeHidden()
19
- })
20
- })
@@ -1,77 +0,0 @@
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
- import { fileURLToPath } from "node:url"
28
-
29
- import { type Page, test as baseTest } from "@playwright/test"
30
- import { build, preview } from "astro"
31
-
32
- export { expect, type Locator } from "@playwright/test"
33
-
34
- process.env.ASTRO_TELEMETRY_DISABLED = "true"
35
- process.env.ASTRO_DISABLE_UPDATE_CHECK = "true"
36
- const root = fileURLToPath(new URL("./fixtures/basics/", import.meta.url))
37
-
38
- let server: Server | null = null
39
- const test = baseTest.extend<{
40
- lightnet: (path?: string) => Promise<LightNetPage>
41
- }>({
42
- lightnet: ({ page }, use) =>
43
- use(async (path) => {
44
- if (!server) {
45
- await build({ logLevel: "error", root })
46
- server = await preview({ logLevel: "error", root })
47
- }
48
- const ln = new LightNetPage(server, page)
49
- await ln.goto(path ?? "/")
50
- return ln
51
- }),
52
- })
53
-
54
- const teardown = async () => {
55
- await server?.stop()
56
- }
57
-
58
- // A Playwright test fixture accessible from within all tests.
59
- class LightNetPage {
60
- constructor(
61
- private readonly server: Server,
62
- private readonly page: Page,
63
- ) {}
64
-
65
- // Navigate to a URL relative to the server used during a test run and return the resource response.
66
- goto(path: string) {
67
- return this.page.goto(this.resolveURL(path))
68
- }
69
-
70
- resolveURL(path: string) {
71
- return `http://localhost:${this.server.port}${path.replace(/^\/?/, "/")}`
72
- }
73
- }
74
-
75
- type Server = Awaited<ReturnType<typeof preview>>
76
-
77
- export { teardown, test }
@@ -1,40 +0,0 @@
1
- // @ts-check
2
- import { defineConfig } from "astro/config"
3
- import lightnet from "lightnet"
4
-
5
- // https://astro.build/config
6
- export default defineConfig({
7
- site: "https://test.com",
8
- integrations: [
9
- lightnet({
10
- title: "Basic Test",
11
- logo: { src: "./src/assets/logo.png" },
12
- credits: true,
13
- languages: [
14
- {
15
- code: "en",
16
- label: "English",
17
- isDefaultSiteLanguage: true,
18
- },
19
- {
20
- code: "de",
21
- label: "Deutsch",
22
- isSiteLanguage: true,
23
- },
24
- ],
25
- favicon: [{ href: "favicon.svg" }],
26
- mainMenu: [
27
- {
28
- href: "/",
29
- label: "ln.home.title",
30
- },
31
- { href: "/media", label: "ln.search.title" },
32
- ],
33
- experimental: {
34
- admin: {
35
- enabled: true,
36
- },
37
- },
38
- }),
39
- ],
40
- })
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*|*MINGW*|*MSYS*)
6
- if command -v cygpath > /dev/null 2>&1; then
7
- basedir=`cygpath -w "$basedir"`
8
- fi
9
- ;;
10
- esac
11
-
12
- if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.17.2_@types+node@25.0.3_jiti@2.4.2_lightningcss@1.29.1_rollup@4.57.1_terser@5.39.0_typescript@5.9.3_yaml@2.8.2/node_modules/astro/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.17.2_@types+node@25.0.3_jiti@2.4.2_lightningcss@1.29.1_rollup@4.57.1_terser@5.39.0_typescript@5.9.3_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
14
- else
15
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.17.2_@types+node@25.0.3_jiti@2.4.2_lightningcss@1.29.1_rollup@4.57.1_terser@5.39.0_typescript@5.9.3_yaml@2.8.2/node_modules/astro/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/astro@5.17.2_@types+node@25.0.3_jiti@2.4.2_lightningcss@1.29.1_rollup@4.57.1_terser@5.39.0_typescript@5.9.3_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
16
- fi
17
- if [ -x "$basedir/node" ]; then
18
- exec "$basedir/node" "$basedir/../astro/astro.js" "$@"
19
- else
20
- exec node "$basedir/../astro/astro.js" "$@"
21
- fi
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*|*MINGW*|*MSYS*)
6
- if command -v cygpath > /dev/null 2>&1; then
7
- basedir=`cygpath -w "$basedir"`
8
- fi
9
- ;;
10
- esac
11
-
12
- if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/lib/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
14
- else
15
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/lib/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
16
- fi
17
- if [ -x "$basedir/node" ]; then
18
- exec "$basedir/node" "$basedir/../tailwindcss/lib/cli.js" "$@"
19
- else
20
- exec node "$basedir/../tailwindcss/lib/cli.js" "$@"
21
- fi
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*|*MINGW*|*MSYS*)
6
- if command -v cygpath > /dev/null 2>&1; then
7
- basedir=`cygpath -w "$basedir"`
8
- fi
9
- ;;
10
- esac
11
-
12
- if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/lib/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
14
- else
15
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/lib/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules/tailwindcss/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/tailwindcss@3.4.19_yaml@2.8.2/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
16
- fi
17
- if [ -x "$basedir/node" ]; then
18
- exec "$basedir/node" "$basedir/../tailwindcss/lib/cli.js" "$@"
19
- else
20
- exec node "$basedir/../tailwindcss/lib/cli.js" "$@"
21
- fi
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*|*MINGW*|*MSYS*)
6
- if command -v cygpath > /dev/null 2>&1; then
7
- basedir=`cygpath -w "$basedir"`
8
- fi
9
- ;;
10
- esac
11
-
12
- if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
14
- else
15
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
16
- fi
17
- if [ -x "$basedir/node" ]; then
18
- exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
19
- else
20
- exec node "$basedir/../typescript/bin/tsc" "$@"
21
- fi
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*|*MINGW*|*MSYS*)
6
- if command -v cygpath > /dev/null 2>&1; then
7
- basedir=`cygpath -w "$basedir"`
8
- fi
9
- ;;
10
- esac
11
-
12
- if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules"
14
- else
15
- export NODE_PATH="/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/typescript@5.9.3/node_modules:/home/runner/work/LightNet/LightNet/node_modules/.pnpm/node_modules:$NODE_PATH"
16
- fi
17
- if [ -x "$basedir/node" ]; then
18
- exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
19
- else
20
- exec node "$basedir/../typescript/bin/tsserver" "$@"
21
- fi
@@ -1,21 +0,0 @@
1
- {
2
- "name": "@e2e/basics",
3
- "type": "module",
4
- "version": "0.0.1",
5
- "private": "true",
6
- "dependencies": {
7
- "@astrojs/react": "^4.4.2",
8
- "@astrojs/tailwind": "^6.0.2",
9
- "@lightnet/decap-admin": "^3.1.4",
10
- "astro": "^5.17.2",
11
- "lightnet": "^3.12.0",
12
- "react": "^19.2.4",
13
- "react-dom": "^19.2.4",
14
- "sharp": "^0.34.5",
15
- "tailwindcss": "^3.4.19",
16
- "typescript": "^5.9.3"
17
- },
18
- "engines": {
19
- "node": ">=22"
20
- }
21
- }
@@ -1 +0,0 @@
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>