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,41 @@
|
|
|
1
|
+
import { marked } from "marked"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remove markdown syntax and return plain text.
|
|
5
|
+
*
|
|
6
|
+
* @param markdown string
|
|
7
|
+
* @returns plain text
|
|
8
|
+
*/
|
|
9
|
+
export function markdownToText(markdown?: string) {
|
|
10
|
+
if (!markdown) {
|
|
11
|
+
return markdown
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
markdown
|
|
15
|
+
//headers
|
|
16
|
+
.replaceAll(/^#+ ?/gm, "")
|
|
17
|
+
// lists
|
|
18
|
+
.replaceAll(/^- /gm, "")
|
|
19
|
+
// block quotes
|
|
20
|
+
.replaceAll(/^>+ ?/gm, "")
|
|
21
|
+
// bold and italics
|
|
22
|
+
.replaceAll(/[*_]/g, "")
|
|
23
|
+
// images
|
|
24
|
+
.replaceAll(/!\[(.*?)\]\(.*?\)/g, (_, imgAlt) => imgAlt)
|
|
25
|
+
// links
|
|
26
|
+
.replaceAll(/\[(.*?)\]\(.*?\)/g, (_, linkLabel) => linkLabel)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Converts markdown to a html string
|
|
32
|
+
*
|
|
33
|
+
* @param markdown string
|
|
34
|
+
* @returns html
|
|
35
|
+
*/
|
|
36
|
+
export function markdownToHtml(markdown?: string) {
|
|
37
|
+
if (!markdown) {
|
|
38
|
+
return markdown
|
|
39
|
+
}
|
|
40
|
+
return marked.parse(markdown)
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build path to media item page.
|
|
3
|
+
*
|
|
4
|
+
* @param language current locale
|
|
5
|
+
* @param mediaItem media item
|
|
6
|
+
* @returns path to media item page eg. '/en/media/my-book'
|
|
7
|
+
*/
|
|
8
|
+
export function detailsPagePath(
|
|
9
|
+
locale: string | undefined,
|
|
10
|
+
{ id }: { id: string },
|
|
11
|
+
) {
|
|
12
|
+
return localizePath(locale, `/media/${id}`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Build path to the search page.
|
|
17
|
+
*
|
|
18
|
+
* @param language current locale
|
|
19
|
+
* @param query search query params
|
|
20
|
+
* @returns path to the search page eg. '/en/media?category=comics'
|
|
21
|
+
*/
|
|
22
|
+
export function searchPagePath(
|
|
23
|
+
language: string | undefined,
|
|
24
|
+
filter?: { category: string },
|
|
25
|
+
) {
|
|
26
|
+
const searchParams = new URLSearchParams()
|
|
27
|
+
if (filter?.category) {
|
|
28
|
+
searchParams.append("category", filter.category)
|
|
29
|
+
}
|
|
30
|
+
return localizePath(
|
|
31
|
+
language,
|
|
32
|
+
`/media${searchParams.size ? `?${searchParams.toString()}` : ""}`,
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a path for a given locale.
|
|
38
|
+
*
|
|
39
|
+
* @param locale current locale
|
|
40
|
+
* @param path to be resolved. A '/' at the beginning of the path is not required.
|
|
41
|
+
* @returns resolved path. Eg. '/en/about' for input "en" and "/about"
|
|
42
|
+
*/
|
|
43
|
+
export function localizePath(locale: string | undefined, path: string) {
|
|
44
|
+
return `${locale ? `/${locale}` : ""}/${path.replace(/^\//, "")}`
|
|
45
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import config from "virtual:lightnet/config"
|
|
2
|
+
import projectContext from "virtual:lightnet/project-context"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Test if a given url is outside this site.
|
|
6
|
+
* Will return false if the url is relative or if it
|
|
7
|
+
* starts with the site config from astro config.
|
|
8
|
+
*
|
|
9
|
+
* @param url to test
|
|
10
|
+
* @returns is the url external?
|
|
11
|
+
*/
|
|
12
|
+
export function isExternalUrl(url: string) {
|
|
13
|
+
let parsedUrl
|
|
14
|
+
try {
|
|
15
|
+
// test if url is absolute
|
|
16
|
+
parsedUrl = new URL(url)
|
|
17
|
+
} catch {
|
|
18
|
+
// url is relative
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
if (config.internalDomains.includes(parsedUrl.hostname)) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
const { site } = projectContext
|
|
25
|
+
if (!site) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
return !url.startsWith(site)
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AstroError } from "astro/errors"
|
|
2
|
+
import { z } from "astro/zod"
|
|
3
|
+
import { fromZodError } from "zod-validation-error"
|
|
4
|
+
|
|
5
|
+
export async function verifySchemaAsync<T extends z.Schema>(
|
|
6
|
+
schema: T,
|
|
7
|
+
toVerify: unknown,
|
|
8
|
+
errorMessage: string | ((id: string | undefined) => string),
|
|
9
|
+
): Promise<z.output<T>> {
|
|
10
|
+
const parsed = await schema.safeParseAsync(toVerify)
|
|
11
|
+
if (!parsed.success) {
|
|
12
|
+
throwParseError(toVerify, errorMessage, parsed)
|
|
13
|
+
}
|
|
14
|
+
return parsed.data
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function verifySchema<T extends z.Schema>(
|
|
18
|
+
schema: T,
|
|
19
|
+
toVerify: unknown,
|
|
20
|
+
errorMessage: string | ((id: string | undefined) => string),
|
|
21
|
+
): z.output<T> {
|
|
22
|
+
const parsed = schema.safeParse(toVerify, {})
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throwParseError(toVerify, errorMessage, parsed)
|
|
25
|
+
}
|
|
26
|
+
return parsed.data
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function throwParseError(
|
|
30
|
+
toVerify: unknown,
|
|
31
|
+
errorMessage: string | ((id: string | undefined) => string),
|
|
32
|
+
parsed: z.SafeParseError<unknown>,
|
|
33
|
+
) {
|
|
34
|
+
const id = z.object({ id: z.string() }).safeParse(toVerify).data?.id
|
|
35
|
+
const message =
|
|
36
|
+
typeof errorMessage === "string" ? errorMessage : errorMessage(id)
|
|
37
|
+
throw new AstroError(message, fromZodError(parsed.error).toString())
|
|
38
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { addIconSelectors } from "@iconify/tailwind"
|
|
2
|
+
import typography from "@tailwindcss/typography"
|
|
3
|
+
import daisyui from "daisyui"
|
|
4
|
+
import type { Config } from "tailwindcss"
|
|
5
|
+
|
|
6
|
+
const DEFAULT_COLOR_PRIMARY = "#E6B15C"
|
|
7
|
+
|
|
8
|
+
export function lightnetStyles({
|
|
9
|
+
primaryColor,
|
|
10
|
+
}: {
|
|
11
|
+
primaryColor?: string
|
|
12
|
+
}): Partial<Config> {
|
|
13
|
+
const primary = primaryColor ?? DEFAULT_COLOR_PRIMARY
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
"./node_modules/lightnet/src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}",
|
|
17
|
+
"./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}",
|
|
18
|
+
"./src/content/media-types/*.json",
|
|
19
|
+
],
|
|
20
|
+
theme: {
|
|
21
|
+
extend: {
|
|
22
|
+
colors: {
|
|
23
|
+
primary,
|
|
24
|
+
},
|
|
25
|
+
backgroundImage: {
|
|
26
|
+
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
daisyui: {
|
|
31
|
+
themes: [
|
|
32
|
+
{
|
|
33
|
+
lightnet: {
|
|
34
|
+
primary,
|
|
35
|
+
secondary: primary,
|
|
36
|
+
accent: primary,
|
|
37
|
+
neutral: "#030712",
|
|
38
|
+
"base-100": "#f9fafb",
|
|
39
|
+
|
|
40
|
+
"--rounded-box": "0.375rem", // border radius rounded-box utility class, used in card and other large boxes
|
|
41
|
+
"--rounded-btn": "0.375rem", // border radius rounded-btn utility class, used in buttons and similar element
|
|
42
|
+
"--rounded-badge": "0.375rem", // border radius rounded-badge utility class, used in badges and similar
|
|
43
|
+
"--tab-radius": "0.375rem", // border radius of tabs
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
base: false, // applies background color and foreground color for root element by default
|
|
48
|
+
utils: true, // adds responsive and modifier utility classes
|
|
49
|
+
logs: false, // Shows info about daisyUI version and used config in the console when building your CSS
|
|
50
|
+
prefix: "dy-",
|
|
51
|
+
},
|
|
52
|
+
plugins: [typography, daisyui, addIconSelectors(["mdi"])],
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default lightnetStyles({})
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config"
|
|
2
|
+
|
|
3
|
+
import { vitePluginLightnetConfig } from "./src/astro-integration/vite-plugin-lightnet-config"
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
test: {
|
|
7
|
+
include: ["__tests__/**/*.spec.ts"],
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
vitePluginLightnetConfig(
|
|
11
|
+
{
|
|
12
|
+
title: "Sk8 Ministries",
|
|
13
|
+
logo: { src: "./logo.svg" },
|
|
14
|
+
languages: [{ code: "en", label: "English" }],
|
|
15
|
+
},
|
|
16
|
+
{ site: "https://sk8-ministries.dev" },
|
|
17
|
+
),
|
|
18
|
+
],
|
|
19
|
+
})
|