@terrafirmagreg-team/changelog 1.2.2 → 1.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/changelog",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "description": "Changelog section",
6
6
  "license": "LGPL-3.0-only",
@@ -18,7 +18,7 @@
18
18
  "./types": "./src/types/index.ts"
19
19
  },
20
20
  "dependencies": {
21
- "@terrafirmagreg-team/kit": "1.2.2",
21
+ "@terrafirmagreg-team/kit": "1.2.3",
22
22
  "@terrafirmagreg-team/mdx": "1.2.1",
23
23
  "@terrafirmagreg-team/translate": "1.2.3",
24
24
  "@terrafirmagreg-team/ui": "1.2.2",
@@ -0,0 +1,164 @@
1
+ import { redirect } from 'next/navigation';
2
+ import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
3
+ import {
4
+ ChangelogTimeline,
5
+ type ChangelogTimelineEntry,
6
+ } from '@terrafirmagreg-team/changelog/components/timeline';
7
+ import {
8
+ WorkspaceBody,
9
+ WorkspaceDescription,
10
+ WorkspaceTitle,
11
+ } from '@terrafirmagreg-team/ui/components/layouts/workspace';
12
+ import { PageActions } from '@terrafirmagreg-team/kit/components/page-actions';
13
+ import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
14
+ import type {
15
+ SectionPageView,
16
+ SectionWorkspaceProps,
17
+ } from '@terrafirmagreg-team/kit/components/views/section';
18
+ import type {
19
+ SectionFeatures,
20
+ SectionPageContext,
21
+ } from '@terrafirmagreg-team/kit/types/features';
22
+ import { sectionConfig } from '@terrafirmagreg-team/kit/lib/config';
23
+ import { UntranslatedCallout } from '@terrafirmagreg-team/ui/components/blocks/lang/untranslated-callout';
24
+ import { getMDXComponents } from '@terrafirmagreg-team/mdx/components/mdx-components';
25
+ import { loadLocaleRegistry } from '@terrafirmagreg-team/translate/server';
26
+ import { stripLangFromUrl } from '@terrafirmagreg-team/translate/lib/slug';
27
+ import type { TranslationState } from '@terrafirmagreg-team/translate/server';
28
+ import type { MDXContent } from 'mdx/types';
29
+ import type { TableOfContents } from '@terrafirmagreg-team/kit/components/toc/base';
30
+ import type { SectionPage } from '@terrafirmagreg-team/kit/types';
31
+
32
+ export type ChangelogPageContext = SectionPageContext;
33
+
34
+ export type ChangelogPageFeatures = SectionFeatures;
35
+
36
+ export function ChangelogBrowser({
37
+ entries,
38
+ lang,
39
+ }: {
40
+ entries: ChangelogTimelineEntry[];
41
+ lang: Lang;
42
+ }) {
43
+ return <ChangelogTimeline entries={entries} lang={lang} />;
44
+ }
45
+
46
+ export function ChangelogPageChrome({
47
+ page,
48
+ body,
49
+ copied,
50
+ ctx,
51
+ dataset,
52
+ features,
53
+ }: {
54
+ page: SectionPage;
55
+ body: React.ReactNode;
56
+ copied?: TranslationState;
57
+ ctx: ChangelogPageContext;
58
+ dataset?: { crowdin?: string };
59
+ features: ChangelogPageFeatures;
60
+ }) {
61
+ const { languages } = loadLocaleRegistry();
62
+ return (
63
+ <>
64
+ <UntranslatedCallout copied={copied} />
65
+ <WorkspaceTitle>{page.data.title}</WorkspaceTitle>
66
+ <WorkspaceDescription className="mb-0">
67
+ {page.data.description}
68
+ </WorkspaceDescription>
69
+ <div className="flex flex-row gap-2 items-center border-b pb-6">
70
+ <PageActions
71
+ copied={copied}
72
+ crowdinUrl={dataset?.crowdin}
73
+ title={page.data.title}
74
+ mdUrl={`${stripLangFromUrl(page.url, [...languages])}.md${
75
+ page.locale ? `?lang=${page.locale}` : ''
76
+ }`}
77
+ githubUrl={features.fileUrl?.(ctx.filePath)}
78
+ />
79
+ {features.actionsRight?.(ctx)}
80
+ </div>
81
+ <WorkspaceBody>
82
+ {features.wrapBody ? (
83
+ features.wrapBody(body, ctx)
84
+ ) : (
85
+ <div data-md-root className="contents">
86
+ {body}
87
+ </div>
88
+ )}
89
+ </WorkspaceBody>
90
+ {features.footer?.(ctx)}
91
+ {page.data.comments !== false ? features.comments?.(ctx) : null}
92
+ </>
93
+ );
94
+ }
95
+
96
+ export async function changelogPage({
97
+ page,
98
+ link,
99
+ contentDir,
100
+ copied,
101
+ crumbs = [],
102
+ previews,
103
+ footer,
104
+ history = true,
105
+ features = {},
106
+ }: SectionWorkspaceProps & {
107
+ features?: ChangelogPageFeatures;
108
+ }): Promise<SectionPageView> {
109
+ if (page.data.redirect) redirect(page.data.redirect);
110
+ const { body: MDX, toc } = (await (
111
+ page.data as unknown as {
112
+ load(): Promise<{ body: MDXContent; toc: TableOfContents }>;
113
+ }
114
+ ).load()) as { body: MDXContent; toc: TableOfContents };
115
+ const filePath = `${contentDir}/${page.path.replace(/\\/g, '/')}`;
116
+ const datasetId = page.url.split('/').filter(Boolean)[1];
117
+ const dataset = datasetId
118
+ ? sectionConfig().datasetConfig[datasetId]
119
+ : undefined;
120
+ const ctx: ChangelogPageContext = {
121
+ page,
122
+ filePath,
123
+ datasetId,
124
+ copied,
125
+ history,
126
+ };
127
+ const body = <MDX components={getMDXComponents({ a: link })} />;
128
+ return {
129
+ node: (
130
+ <ChangelogPageChrome
131
+ page={page}
132
+ body={body}
133
+ copied={copied}
134
+ ctx={ctx}
135
+ dataset={dataset}
136
+ features={features}
137
+ />
138
+ ),
139
+ workspace: {
140
+ toc,
141
+ full: page.data.full,
142
+ className: 'min-h-full',
143
+ breadcrumb: { items: crumbs, previews },
144
+ pagination: { items: footer },
145
+ },
146
+ };
147
+ }
148
+
149
+ export function ChangelogBrowserFallback() {
150
+ return (
151
+ <div className="flex flex-col gap-8 pt-6">
152
+ {Array.from({ length: 3 }, (_, i) => (
153
+ <div key={i} className="flex flex-col gap-3">
154
+ <Skeleton className="h-6 w-32" />
155
+ <div className="flex flex-col gap-2.5 border-l border-border ps-4">
156
+ <Skeleton className="h-4 w-2/3" />
157
+ <Skeleton className="h-4 w-4/5" />
158
+ <Skeleton className="h-4 w-1/2" />
159
+ </div>
160
+ </div>
161
+ ))}
162
+ </div>
163
+ );
164
+ }
@@ -0,0 +1,54 @@
1
+ import { sectionConfig } from '@terrafirmagreg-team/kit/lib/config';
2
+ import type {
3
+ SectionLandingProps,
4
+ SectionLandingView,
5
+ } from '@terrafirmagreg-team/kit/components/views/routes';
6
+ import type { SectionSource } from '@terrafirmagreg-team/kit/types';
7
+ import { Suspense } from 'react';
8
+ import { timelineEntries } from '@terrafirmagreg-team/changelog/components/entries';
9
+ import {
10
+ ChangelogBrowser,
11
+ ChangelogBrowserFallback,
12
+ } from '@terrafirmagreg-team/changelog/components/views/browser';
13
+ import {
14
+ groupByMonth,
15
+ monthAnchor,
16
+ } from '@terrafirmagreg-team/changelog/components/timeline';
17
+ import { ChangelogMonthLabel } from '@terrafirmagreg-team/changelog/components/month-label';
18
+
19
+ export async function changelogLanding({
20
+ page,
21
+ lang,
22
+ source,
23
+ route,
24
+ }: SectionLandingProps<SectionSource>): Promise<SectionLandingView> {
25
+ const dataset = page.dataset.id;
26
+ const entries = await timelineEntries(
27
+ source,
28
+ route,
29
+ dataset,
30
+ lang,
31
+ sectionConfig().datasetConfig[dataset]?.repo,
32
+ );
33
+ return {
34
+ node: (
35
+ <Suspense fallback={<ChangelogBrowserFallback />}>
36
+ <ChangelogBrowser entries={entries} lang={lang} />
37
+ </Suspense>
38
+ ),
39
+ workspace: {
40
+ toc: groupByMonth(entries, lang).map((month) => ({
41
+ title: <ChangelogMonthLabel monthKey={month.key} />,
42
+ url: `#${monthAnchor(month.key)}`,
43
+ depth: 2,
44
+ })),
45
+ breadcrumb: {
46
+ items: [
47
+ { name: 'Changelog', url: route },
48
+ { name: page.datasetTitle ?? dataset },
49
+ ],
50
+ },
51
+ pagination: false,
52
+ },
53
+ };
54
+ }
@@ -0,0 +1,6 @@
1
+ import { Layout } from '@terrafirmagreg-team/kit/components/layouts/layout';
2
+ import type { SectionLayoutViewProps } from '@terrafirmagreg-team/kit/components/views/routes';
3
+
4
+ export function ChangelogLayout(props: SectionLayoutViewProps) {
5
+ return <Layout {...props} />;
6
+ }
@@ -1,25 +0,0 @@
1
- import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
2
- import type { SectionSource } from '@terrafirmagreg-team/kit/lib/page';
3
- import { timelineEntries } from '../entries';
4
- import { ChangelogTimeline } from '../timeline';
5
-
6
- export async function ChangelogTimelineView({
7
- source,
8
- route,
9
- dataset,
10
- lang,
11
- repo,
12
- }: {
13
- source: SectionSource;
14
- route: string;
15
- dataset: string;
16
- lang: Lang;
17
- repo?: `${string}/${string}`;
18
- }) {
19
- return (
20
- <ChangelogTimeline
21
- entries={await timelineEntries(source, route, dataset, lang, repo)}
22
- lang={lang}
23
- />
24
- );
25
- }