lightnet 4.6.2 → 4.7.0
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# lightnet
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#465](https://github.com/LightNetDev/LightNet/pull/465) [`24f5b61`](https://github.com/LightNetDev/LightNet/commit/24f5b614c50ef355f595644b9b0763e00a2210cd) - Generate XML sitemaps automatically using Astro's sitemap integration and LightNet's site languages. Respect an explicitly configured `@astrojs/sitemap` integration for custom sitemap behavior.
|
|
8
|
+
|
|
9
|
+
- [#465](https://github.com/LightNetDev/LightNet/pull/465) [`24f5b61`](https://github.com/LightNetDev/LightNet/commit/24f5b614c50ef355f595644b9b0763e00a2210cd) - Automatically generate robots.txt allowing crawling and linking to the sitemap index using Astro's site and base configuration. Preserve user-provided robots.txt files in the public directory and skip generation when search indexing is disabled.
|
|
10
|
+
|
|
11
|
+
## 4.6.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#458](https://github.com/LightNetDev/LightNet/pull/458) [`c1eb520`](https://github.com/LightNetDev/LightNet/commit/c1eb520dceae028e46c7b6b93a8a02c2a5169ccb) - Inline the view transition opt-in CSS in the page head to prevent browsers from aborting page transitions before the external stylesheet loads.
|
|
16
|
+
|
|
3
17
|
## 4.6.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "LightNet makes it easy to run your own digital media library.",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "4.
|
|
6
|
+
"version": "4.7.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/LightNetDev/lightnet",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"./pages/SearchPageRoute.astro": "./src/pages/search-page/SearchPageRoute.astro",
|
|
43
43
|
"./pages/DetailsPageRoute.astro": "./src/pages/details-page/DetailsPageRoute.astro",
|
|
44
44
|
"./api/internal/search.ts": "./src/pages/search-page/api/search.ts",
|
|
45
|
-
"./api/versions.ts": "./src/api/versions.ts"
|
|
45
|
+
"./api/versions.ts": "./src/api/versions.ts",
|
|
46
|
+
"./api/robots.ts": "./src/api/robots.ts"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"astro": "^6.0.0",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@astrojs/react": "^5.0.7",
|
|
56
|
+
"@astrojs/sitemap": "^3.7.4",
|
|
55
57
|
"@iconify-json/lucide": "^1.2.145",
|
|
56
58
|
"@iconify-json/mdi": "^1.2.3",
|
|
57
59
|
"@iconify/tailwind": "^1.2.0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { APIRoute } from "astro"
|
|
2
|
+
|
|
3
|
+
export const GET: APIRoute = ({ site }) => {
|
|
4
|
+
const base = new URL(import.meta.env.BASE_URL, site)
|
|
5
|
+
if (!base.pathname.endsWith("/")) base.pathname += "/"
|
|
6
|
+
const sitemap = new URL("sitemap-index.xml", base)
|
|
7
|
+
|
|
8
|
+
return new Response(`User-agent: *\nAllow: /\n\nSitemap: ${sitemap.href}\n`, {
|
|
9
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/// <reference path="../i18n/locals.d.ts" />
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
3
|
+
|
|
2
4
|
import react from "@astrojs/react"
|
|
3
5
|
import type { AstroIntegration } from "astro"
|
|
4
6
|
import { AstroError } from "astro/errors"
|
|
5
7
|
|
|
6
8
|
import { verifySchema } from "../utils/verify-schema"
|
|
7
9
|
import { extendedConfigSchema, type LightnetConfig } from "./config"
|
|
10
|
+
import { sitemap } from "./sitemap"
|
|
8
11
|
import tailwind from "./tailwind"
|
|
9
12
|
import { vitePluginLightnetConfig } from "./vite-plugin-lightnet-config"
|
|
10
13
|
|
|
@@ -33,6 +36,17 @@ export function lightnet(lightnetConfig: LightnetConfig): AstroIntegration {
|
|
|
33
36
|
"Fix these errors on the LightNet configuration:",
|
|
34
37
|
)
|
|
35
38
|
|
|
39
|
+
if (
|
|
40
|
+
!config.disallowSearchIndexing &&
|
|
41
|
+
!existsSync(new URL("robots.txt", astroConfig.publicDir))
|
|
42
|
+
) {
|
|
43
|
+
injectRoute({
|
|
44
|
+
pattern: "/robots.txt",
|
|
45
|
+
entrypoint: "lightnet/api/robots.ts",
|
|
46
|
+
prerender: true,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
injectRoute({
|
|
37
51
|
pattern: "404",
|
|
38
52
|
entrypoint: "lightnet/pages/404Route.astro",
|
|
@@ -72,7 +86,7 @@ export function lightnet(lightnetConfig: LightnetConfig): AstroIntegration {
|
|
|
72
86
|
addMiddleware({ entrypoint: "lightnet/locals", order: "pre" })
|
|
73
87
|
|
|
74
88
|
updateConfig({
|
|
75
|
-
integrations: [tailwind(), react()],
|
|
89
|
+
integrations: [tailwind(), react(), ...sitemap(config, astroConfig)],
|
|
76
90
|
vite: {
|
|
77
91
|
plugins: [vitePluginLightnetConfig(config, astroConfig, logger)],
|
|
78
92
|
},
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import astroSitemap from "@astrojs/sitemap"
|
|
2
|
+
import type { AstroConfig, AstroIntegration } from "astro"
|
|
3
|
+
|
|
4
|
+
import type { ExtendedLightnetConfig } from "./config"
|
|
5
|
+
|
|
6
|
+
export const sitemap = (
|
|
7
|
+
lightnetConfig: ExtendedLightnetConfig,
|
|
8
|
+
astroConfig: AstroConfig,
|
|
9
|
+
): AstroIntegration[] => {
|
|
10
|
+
if (
|
|
11
|
+
astroConfig.integrations.some(({ name }) => name === "@astrojs/sitemap")
|
|
12
|
+
) {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (lightnetConfig.disallowSearchIndexing) {
|
|
17
|
+
return []
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let adminRoutePatterns: RegExp[] = []
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "lightnet/sitemap-exclusions",
|
|
25
|
+
hooks: {
|
|
26
|
+
"astro:routes:resolved": ({ routes }) => {
|
|
27
|
+
// Astro resolves the package entrypoint to its source file, including
|
|
28
|
+
// workspace paths when the admin package is linked locally.
|
|
29
|
+
adminRoutePatterns = routes
|
|
30
|
+
.filter(({ entrypoint }) =>
|
|
31
|
+
/(?:^|\/)sveltia-admin\/src\/Admin\.astro$/.test(entrypoint),
|
|
32
|
+
)
|
|
33
|
+
.map(({ patternRegex }) => patternRegex)
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
astroSitemap({
|
|
38
|
+
filter: (page) =>
|
|
39
|
+
!adminRoutePatterns.some((pattern) =>
|
|
40
|
+
pattern.test(new URL(page).pathname),
|
|
41
|
+
),
|
|
42
|
+
i18n: {
|
|
43
|
+
defaultLocale: lightnetConfig.defaultLocale,
|
|
44
|
+
locales: Object.fromEntries(
|
|
45
|
+
lightnetConfig.locales.map((locale) => [locale, locale]),
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
]
|
|
50
|
+
}
|