@myelophone/nuxt 0.18.2 → 0.20.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.
Files changed (37) hide show
  1. package/.devcontainer/Dockerfile +6 -6
  2. package/.editorconfig +43 -43
  3. package/.github/workflows/package.yml +72 -73
  4. package/.nuxtignore +5 -5
  5. package/.releaserc.js +1 -0
  6. package/CHANGELOG.md +159 -141
  7. package/LICENSE +77 -77
  8. package/README.md +7 -7
  9. package/app/app.vue +1 -1
  10. package/app/components/view/NotFound.vue +2 -2
  11. package/app/composables/useMultiLang.ts +8 -0
  12. package/app/locales/en/error.json +4 -4
  13. package/app/locales/en/outdated.json +5 -5
  14. package/app/locales/en/times.json +18 -18
  15. package/app/locales/pl/times.json +18 -18
  16. package/app/locales/ru/error.json +4 -4
  17. package/app/locales/ru/outdated.json +5 -5
  18. package/app/locales/ru/times.json +18 -18
  19. package/app/middleware/blog-layout.ts +3 -1
  20. package/app/modules/default-blog/index.ts +1 -1
  21. package/app/modules/htaccess/.htaccess +38 -38
  22. package/app/modules/myelophone-config/module.ts +56 -1
  23. package/app/pages/post/[...slug].server.vue +32 -0
  24. package/app/plugins/open-graph-only.ts +36 -0
  25. package/app/plugins/url-helper.client.ts +0 -1
  26. package/app/server/middleware/security-headers.ts +5 -0
  27. package/app/server/middleware/url-helper.ts +7 -0
  28. package/app/types/blog-content.d.ts +11 -0
  29. package/app/utils/blog.server.ts +3 -129
  30. package/biome.json +1 -1
  31. package/nuxt.config.ts +55 -24
  32. package/package.json +13 -10
  33. package/vite/plugins/blog-content.ts +126 -0
  34. package/vite/plugins/clean-css.ts +20 -1
  35. package/vite/plugins/nitro-profile.ts +86 -0
  36. package/app/components/ui/PostContent.server.vue +0 -23
  37. package/app/pages/post/[...slug].vue +0 -30
package/LICENSE CHANGED
@@ -1,77 +1,77 @@
1
- PolyForm Noncommercial License 1.0.0
2
-
3
- <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
-
5
- Required Notice: Copyright (c) 2026 Aliaksandr Ivanou
6
-
7
- Acceptance
8
-
9
- In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
-
11
- Copyright License
12
-
13
- The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to Distribution License and make changes or new works based on the software according to Changes and New Works License.
14
-
15
- Distribution License
16
-
17
- The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by Changes and New Works License.
18
-
19
- Notices
20
-
21
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with "Required Notice:" that the licensor provided with the software. For example:
22
-
23
- Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
-
25
- Changes and New Works License
26
-
27
- The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
-
29
- Patent License
30
-
31
- The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
-
33
- Noncommercial Purposes
34
-
35
- Any noncommercial purpose is a permitted purpose.
36
-
37
- Personal Uses
38
-
39
- Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
-
41
- Noncommercial Organizations
42
-
43
- Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
-
45
- Fair Use
46
-
47
- You may have "fair use" rights for the software under the law. These terms do not limit them.
48
-
49
- No Other Rights
50
-
51
- These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
-
53
- Patent Defense
54
-
55
- If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
-
57
- Violations
58
-
59
- The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
-
61
- No Liability
62
-
63
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
64
-
65
- Definitions
66
-
67
- The licensor is the individual or entity offering these terms, and the software is the software the licensor makes available under these terms.
68
-
69
- You refers to the individual or entity agreeing to these terms.
70
-
71
- Your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization.
72
-
73
- Control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
74
-
75
- Your licenses are all the licenses granted to you for the software under these terms.
76
-
77
- Use means anything you do with the software requiring one of your licenses.
1
+ PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ Required Notice: Copyright (c) 2026 Aliaksandr Ivanou
6
+
7
+ Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to Distribution License and make changes or new works based on the software according to Changes and New Works License.
14
+
15
+ Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by Changes and New Works License.
18
+
19
+ Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with "Required Notice:" that the licensor provided with the software. For example:
22
+
23
+ Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ No Liability
62
+
63
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
64
+
65
+ Definitions
66
+
67
+ The licensor is the individual or entity offering these terms, and the software is the software the licensor makes available under these terms.
68
+
69
+ You refers to the individual or entity agreeing to these terms.
70
+
71
+ Your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization.
72
+
73
+ Control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
74
+
75
+ Your licenses are all the licenses granted to you for the software under these terms.
76
+
77
+ Use means anything you do with the software requiring one of your licenses.
package/README.md CHANGED
@@ -100,17 +100,17 @@ export default defineNuxtConfig({
100
100
 
101
101
  ### Extend it as a Nuxt layer
102
102
 
103
- The layer can be installed directly from GitHub without registry configuration, access tokens, or GitHub Packages authentication. Add the dependency to the consuming application's `package.json`:
103
+ The layer is published on [npm](https://www.npmjs.com/package/@myelophone/nuxt). Add it to the consuming application's `package.json`:
104
104
 
105
105
  ```json
106
106
  {
107
107
  "devDependencies": {
108
- "@myelophone/nuxt": "git+https://github.com/myelophone/nuxt.git"
108
+ "@myelophone/nuxt": "^0.19.1"
109
109
  }
110
110
  }
111
111
  ```
112
112
 
113
- Install dependencies and prepare Nuxt types:
113
+ Install dependencies from npm and prepare Nuxt types:
114
114
 
115
115
  ```bash
116
116
  yarn install
@@ -542,7 +542,7 @@ const props = withDefaults(
542
542
 
543
543
  const english: ProductPageContent = {
544
544
  seo: {
545
- title: "Acme — a clearer way to work",
545
+ title: "Acme - a clearer way to work",
546
546
  description: "A short description of the complete product page.",
547
547
  },
548
548
  brand: "Acme",
@@ -558,7 +558,7 @@ const defaultContentByLocale: Record<string, ProductPageContent> = {
558
558
  en: english,
559
559
  pl: mergeReadyContent(english, {
560
560
  seo: {
561
- title: "Acme — prostszy sposób pracy",
561
+ title: "Acme - prostszy sposób pracy",
562
562
  description: "Krótki opis kompletnej strony produktu.",
563
563
  },
564
564
  hero: {
@@ -995,7 +995,7 @@ Use `SeoProfileInfo` only when the page primarily describes one person or organi
995
995
  <SeoProfileInfo
996
996
  id="https://example.com/team/ada#profile-page"
997
997
  url="https://example.com/team/ada"
998
- name="Ada Lovelace — profile"
998
+ name="Ada Lovelace - profile"
999
999
  date-created="2024-01-10T09:00:00Z"
1000
1000
  date-modified="2026-08-16T12:00:00Z"
1001
1001
  entity-id="https://example.com/team/ada#person"
@@ -2977,7 +2977,7 @@ Commits follow Conventional Commits and are checked with Commitlint. The `main`
2977
2977
  - `BREAKING CHANGE:` → major release;
2978
2978
  - documentation, tests, refactors, build, CI, style, and chores do not release by default.
2979
2979
 
2980
- The release workflow updates `CHANGELOG.md` and `package.json`, publishes to GitHub Packages, creates a GitHub release, and commits release metadata back to the repository.
2980
+ The release workflow updates `CHANGELOG.md` and `package.json`, publishes to [npm](https://www.npmjs.com/package/@myelophone/nuxt) with provenance, creates a GitHub release, and commits release metadata back to the repository.
2981
2981
 
2982
2982
  ### Compatibility checklist
2983
2983
 
package/app/app.vue CHANGED
@@ -354,7 +354,7 @@ useCommand({
354
354
  <NuxtLayout>
355
355
  <NuxtErrorBoundary>
356
356
  <main id="main" tabindex="-1">
357
- <NuxtPage :keepalive="{ max: 10 }" />
357
+ <NuxtPage />
358
358
  </main>
359
359
  <template #error="{ error, clearError }">
360
360
  <SeoNoIndex :status-code="error?.statusCode" />
@@ -59,8 +59,8 @@ onUnmounted(deactivateNotFound);
59
59
  const { t } = useMultiLang(["interface"]);
60
60
 
61
61
  useAppSeo({
62
- title: () => `404 — ${t("interface.pageNotFound")}`,
63
- description: () => `404 — ${t("interface.pageNotFoundDescription")}`,
62
+ title: () => `404 - ${t("interface.pageNotFound")}`,
63
+ description: () => `404 - ${t("interface.pageNotFoundDescription")}`,
64
64
  noIndex: true,
65
65
  });
66
66
  </script>
@@ -174,6 +174,14 @@ export function useMultiLang(namespaces: string | string[]) {
174
174
  { watch: [activeLang] },
175
175
  );
176
176
 
177
+ if (import.meta.client) {
178
+ onMounted(() => {
179
+ void Promise.all(
180
+ nsArray.map((ns) => loadNamespace(activeLang.value, ns)),
181
+ );
182
+ });
183
+ }
184
+
177
185
  const t = (
178
186
  key: string,
179
187
  arg1?: InterpolationParams | number,
@@ -1,4 +1,4 @@
1
- {
2
- "title": "Error",
3
- "tryAgain": "Try again"
4
- }
1
+ {
2
+ "title": "Error",
3
+ "tryAgain": "Try again"
4
+ }
@@ -1,5 +1,5 @@
1
- {
2
- "browserNotSupported": "Your browser is outdated and not supported",
3
- "useModernBrowser": "Please use a modern browser to access this website",
4
- "close": "Close"
5
- }
1
+ {
2
+ "browserNotSupported": "Your browser is outdated and not supported",
3
+ "useModernBrowser": "Please use a modern browser to access this website",
4
+ "close": "Close"
5
+ }
@@ -1,18 +1,18 @@
1
- {
2
- "day1": "day",
3
- "day2": "days",
4
- "day5": "days",
5
- "hour1": "hour",
6
- "hour2": "hours",
7
- "hour5": "hours",
8
- "minute1": "minute",
9
- "minute2": "minutes",
10
- "minute5": "minutes",
11
- "second1": "second",
12
- "second2": "seconds",
13
- "second5": "seconds",
14
- "secondshort": "s",
15
- "minuteshort": "m",
16
- "hourshort": "h",
17
- "dayshort": "d"
18
- }
1
+ {
2
+ "day1": "day",
3
+ "day2": "days",
4
+ "day5": "days",
5
+ "hour1": "hour",
6
+ "hour2": "hours",
7
+ "hour5": "hours",
8
+ "minute1": "minute",
9
+ "minute2": "minutes",
10
+ "minute5": "minutes",
11
+ "second1": "second",
12
+ "second2": "seconds",
13
+ "second5": "seconds",
14
+ "secondshort": "s",
15
+ "minuteshort": "m",
16
+ "hourshort": "h",
17
+ "dayshort": "d"
18
+ }
@@ -1,18 +1,18 @@
1
- {
2
- "day1": "dzień",
3
- "day2": "dni",
4
- "day5": "dni",
5
- "hour1": "godzina",
6
- "hour2": "godziny",
7
- "hour5": "godzin",
8
- "minute1": "minuta",
9
- "minute2": "minuty",
10
- "minute5": "minut",
11
- "second1": "sekunda",
12
- "second2": "sekundy",
13
- "second5": "sekund",
14
- "secondshort": "s",
15
- "minuteshort": "m",
16
- "hourshort": "g",
17
- "dayshort": "d"
18
- }
1
+ {
2
+ "day1": "dzień",
3
+ "day2": "dni",
4
+ "day5": "dni",
5
+ "hour1": "godzina",
6
+ "hour2": "godziny",
7
+ "hour5": "godzin",
8
+ "minute1": "minuta",
9
+ "minute2": "minuty",
10
+ "minute5": "minut",
11
+ "second1": "sekunda",
12
+ "second2": "sekundy",
13
+ "second5": "sekund",
14
+ "secondshort": "s",
15
+ "minuteshort": "m",
16
+ "hourshort": "g",
17
+ "dayshort": "d"
18
+ }
@@ -1,4 +1,4 @@
1
- {
2
- "title": "Ошибка",
3
- "tryAgain": "Попробовать снова"
4
- }
1
+ {
2
+ "title": "Ошибка",
3
+ "tryAgain": "Попробовать снова"
4
+ }
@@ -1,5 +1,5 @@
1
- {
2
- "browserNotSupported": "Ваш браузер не поддерживается",
3
- "useModernBrowser": "Для корректной работы сайта используйте один из современных браузеров",
4
- "close": "Закрыть"
5
- }
1
+ {
2
+ "browserNotSupported": "Ваш браузер не поддерживается",
3
+ "useModernBrowser": "Для корректной работы сайта используйте один из современных браузеров",
4
+ "close": "Закрыть"
5
+ }
@@ -1,18 +1,18 @@
1
- {
2
- "day1": "день",
3
- "day2": "дня",
4
- "day5": "дней",
5
- "hour1": "час",
6
- "hour2": "часа",
7
- "hour5": "часов",
8
- "minute1": "минута",
9
- "minute2": "минуты",
10
- "minute5": "минут",
11
- "second1": "секунда",
12
- "second2": "секунды",
13
- "second5": "секунд",
14
- "secondshort": "с",
15
- "minuteshort": "м",
16
- "hourshort": "ч",
17
- "dayshort": "д"
18
- }
1
+ {
2
+ "day1": "день",
3
+ "day2": "дня",
4
+ "day5": "дней",
5
+ "hour1": "час",
6
+ "hour2": "часа",
7
+ "hour5": "часов",
8
+ "minute1": "минута",
9
+ "minute2": "минуты",
10
+ "minute5": "минут",
11
+ "second1": "секунда",
12
+ "second2": "секунды",
13
+ "second5": "секунд",
14
+ "secondshort": "с",
15
+ "minuteshort": "м",
16
+ "hourshort": "ч",
17
+ "dayshort": "д"
18
+ }
@@ -21,7 +21,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
21
21
  if (!post) {
22
22
  const event = useRequestEvent();
23
23
 
24
- if (event) {
24
+ const isIslandRequest = Boolean(useNuxtApp().ssrContext?.islandContext);
25
+
26
+ if (event && !isIslandRequest) {
25
27
  setResponseStatus(event, 404, 'Not Found');
26
28
  }
27
29
  }
@@ -20,7 +20,7 @@ function processPages(pages: NuxtPage[], blogEnabled: boolean) {
20
20
  for (let i = pages.length - 1; i >= 0; i--) {
21
21
  const page = pages[i]!;
22
22
 
23
- if (page.file?.endsWith('/post/[...slug].vue')) {
23
+ if (page.file?.endsWith('/post/[...slug].server.vue')) {
24
24
  if (!blogEnabled) {
25
25
  pages.splice(i, 1);
26
26
  continue;
@@ -1,38 +1,38 @@
1
- <IfModule mod_rewrite.c>
2
- RewriteEngine On
3
- RewriteBase /
4
-
5
- RewriteCond %{REQUEST_FILENAME} !-f
6
- RewriteCond %{REQUEST_FILENAME} !-d
7
- RewriteCond %{REQUEST_FILENAME}.html -f
8
- RewriteRule ^(.+?)/?$ $1.html [L]
9
- </IfModule>
10
-
11
- <IfModule mod_expires.c>
12
- ExpiresActive On
13
- ExpiresByType text/html "access plus 5 minutes"
14
- ExpiresByType text/css "access plus 1 year"
15
- ExpiresByType application/javascript "access plus 1 year"
16
- ExpiresByType image/webp "access plus 1 year"
17
- ExpiresByType image/avif "access plus 1 year"
18
- ExpiresByType image/png "access plus 1 year"
19
- ExpiresByType image/jpeg "access plus 1 year"
20
- ExpiresByType image/svg+xml "access plus 1 year"
21
- ExpiresByType font/woff2 "access plus 1 year"
22
- </IfModule>
23
-
24
- <IfModule mod_headers.c>
25
- <FilesMatch "\.html$">
26
- Header set Cache-Control "public, max-age=300, must-revalidate"
27
- </FilesMatch>
28
- <FilesMatch "\.(css|js|woff2|png|jpe?g|webp|avif|svg)$">
29
- Header set Cache-Control "public, max-age=31536000, immutable"
30
- </FilesMatch>
31
- Header always set X-Content-Type-Options "nosniff"
32
- Header always set X-Frame-Options "SAMEORIGIN"
33
- Header always set Referrer-Policy "strict-origin-when-cross-origin"
34
- </IfModule>
35
-
36
- <IfModule mod_deflate.c>
37
- AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
38
- </IfModule>
1
+ <IfModule mod_rewrite.c>
2
+ RewriteEngine On
3
+ RewriteBase /
4
+
5
+ RewriteCond %{REQUEST_FILENAME} !-f
6
+ RewriteCond %{REQUEST_FILENAME} !-d
7
+ RewriteCond %{REQUEST_FILENAME}.html -f
8
+ RewriteRule ^(.+?)/?$ $1.html [L]
9
+ </IfModule>
10
+
11
+ <IfModule mod_expires.c>
12
+ ExpiresActive On
13
+ ExpiresByType text/html "access plus 5 minutes"
14
+ ExpiresByType text/css "access plus 1 year"
15
+ ExpiresByType application/javascript "access plus 1 year"
16
+ ExpiresByType image/webp "access plus 1 year"
17
+ ExpiresByType image/avif "access plus 1 year"
18
+ ExpiresByType image/png "access plus 1 year"
19
+ ExpiresByType image/jpeg "access plus 1 year"
20
+ ExpiresByType image/svg+xml "access plus 1 year"
21
+ ExpiresByType font/woff2 "access plus 1 year"
22
+ </IfModule>
23
+
24
+ <IfModule mod_headers.c>
25
+ <FilesMatch "\.html$">
26
+ Header set Cache-Control "public, max-age=300, must-revalidate"
27
+ </FilesMatch>
28
+ <FilesMatch "\.(css|js|woff2|png|jpe?g|webp|avif|svg)$">
29
+ Header set Cache-Control "public, max-age=31536000, immutable"
30
+ </FilesMatch>
31
+ Header always set X-Content-Type-Options "nosniff"
32
+ Header always set X-Frame-Options "SAMEORIGIN"
33
+ Header always set Referrer-Policy "strict-origin-when-cross-origin"
34
+ </IfModule>
35
+
36
+ <IfModule mod_deflate.c>
37
+ AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
38
+ </IfModule>
@@ -33,6 +33,52 @@ const enableDefaultRouteStreaming = (routeRules: Record<string, any>) => {
33
33
  };
34
34
  };
35
35
 
36
+ const disablePostRouteStreaming = (
37
+ routeRules: Record<string, any>,
38
+ locales: string[],
39
+ ) => {
40
+ const postRoutes = new Set([
41
+ '/post/**',
42
+ ...locales.map((locale) => `/${locale}/post/**`),
43
+ ]);
44
+
45
+ for (const route of postRoutes) {
46
+ routeRules[route] = {
47
+ ...(routeRules[route] && typeof routeRules[route] === 'object'
48
+ ? routeRules[route]
49
+ : {}),
50
+ streaming: false,
51
+ };
52
+ }
53
+ };
54
+
55
+ const addSWRPayloadRoutes = (routeRules: Record<string, any>) => {
56
+ for (const [route, rule] of Object.entries(routeRules)) {
57
+ if (!rule || typeof rule !== 'object' || rule.swr === false) {
58
+ continue;
59
+ }
60
+
61
+ if ('swr' in rule) {
62
+ const payloadRoute = `${route === '/' ? '' : route.replace(/\/$/, '')}/_payload.json`;
63
+ const current = routeRules[payloadRoute];
64
+ const cache =
65
+ rule.cache && typeof rule.cache === 'object'
66
+ ? rule.cache
67
+ : {
68
+ swr: true,
69
+ ...(typeof rule.swr === 'number'
70
+ ? { maxAge: rule.swr }
71
+ : {}),
72
+ };
73
+
74
+ routeRules[payloadRoute] = {
75
+ ...(current && typeof current === 'object' ? current : {}),
76
+ cache,
77
+ };
78
+ }
79
+ }
80
+ };
81
+
36
82
  const defaultCookieScripts = {
37
83
  necessary: [],
38
84
  analytics: [],
@@ -179,6 +225,10 @@ export default defineNuxtModule<MyelophoneConfig>({
179
225
  if (isStreamingSSR) {
180
226
  nuxt.options.routeRules ||= {};
181
227
  enableDefaultRouteStreaming(nuxt.options.routeRules);
228
+ disablePostRouteStreaming(
229
+ nuxt.options.routeRules,
230
+ myelophone.multi18n.locales,
231
+ );
182
232
  }
183
233
 
184
234
  nuxt.hook('build:before', () => {
@@ -193,10 +243,15 @@ export default defineNuxtModule<MyelophoneConfig>({
193
243
  nuxt.hook('nitro:config', (nitroConfig) => {
194
244
  nitroConfig.runtimeConfig ||= {};
195
245
  nitroConfig.runtimeConfig.myelophone = myelophone;
246
+ nitroConfig.routeRules ||= {};
247
+ addSWRPayloadRoutes(nitroConfig.routeRules);
196
248
 
197
249
  if (isStreamingSSR) {
198
- nitroConfig.routeRules ||= {};
199
250
  enableDefaultRouteStreaming(nitroConfig.routeRules);
251
+ disablePostRouteStreaming(
252
+ nitroConfig.routeRules,
253
+ myelophone.multi18n.locales,
254
+ );
200
255
  }
201
256
  });
202
257
 
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import { getPost } from "#myelophone/app/utils/blog.server";
3
+
4
+ const route = useRoute();
5
+ const param = "slug" in route.params ? route.params.slug : undefined;
6
+ const slug = Array.isArray(param) ? param.join("/") : (param ?? "");
7
+ const post = await getPost(slug);
8
+
9
+ if (!post) {
10
+ const event = useRequestEvent();
11
+ const isIslandRequest = Boolean(useNuxtApp().ssrContext?.islandContext);
12
+
13
+ if (event && !isIslandRequest) {
14
+ setResponseStatus(event, 404, "Not Found");
15
+ }
16
+ } else {
17
+ useAppSeo({
18
+ title: post.meta.title,
19
+ description: post.meta.description,
20
+ image: post.meta.image,
21
+ });
22
+ }
23
+
24
+ const html = post?.html ?? "";
25
+ </script>
26
+
27
+ <template>
28
+ <div class="post-content-page">
29
+ <ViewNotFound v-if="!post" :set-response-status="false" />
30
+ <article v-else class="post-content" v-html="html" />
31
+ </div>
32
+ </template>
@@ -0,0 +1,36 @@
1
+ export default defineNuxtPlugin(() => {
2
+ const head = injectHead();
3
+
4
+ if (!head) return;
5
+ const hooks = head.hooks;
6
+
7
+ if (!hooks) return;
8
+
9
+ hooks.hook('entries:normalize', ({ tags }) => {
10
+ for (let index = tags.length - 1; index >= 0; index--) {
11
+ const tag = tags[index];
12
+ if (!tag) continue;
13
+
14
+ if (
15
+ tag.tag === 'meta' &&
16
+ tag.props.name?.toLowerCase() === 'twitter:card'
17
+ ) {
18
+ tags.splice(index, 1);
19
+ }
20
+ }
21
+ });
22
+
23
+ hooks.hook('tags:beforeResolve', ({ tags }) => {
24
+ for (let index = tags.length - 1; index >= 0; index--) {
25
+ const tag = tags[index];
26
+ if (!tag) continue;
27
+
28
+ if (
29
+ tag.tag === 'meta' &&
30
+ tag.props.name?.toLowerCase() === 'twitter:card'
31
+ ) {
32
+ tags.splice(index, 1);
33
+ }
34
+ }
35
+ });
36
+ });