Skip to content

Commit 8768502

Browse files
authored
Update website & Add list for local private documents (#2)
1 parent 1191211 commit 8768502

File tree

8 files changed

+217
-94
lines changed

8 files changed

+217
-94
lines changed

app/app/src/components/I18n.astro

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
import { Fragment } from 'astro/jsx-runtime'
3+
4+
import { i18nFactory } from '~/i18n'
5+
const _ = i18nFactory(Astro.currentLocale as any)
6+
7+
const {
8+
type: elementType,
9+
...i18nProps
10+
} = Astro.props
11+
12+
const ElementType = elementType || Fragment
13+
14+
for (const key in Astro.slots)
15+
{
16+
if (Astro.slots.has(key))
17+
{
18+
const content = await Astro.slots.render(key)
19+
i18nProps[key] = content
20+
}
21+
}
22+
---
23+
24+
<ElementType>
25+
{_(i18nProps as any)}
26+
</ElementType>

app/app/src/pages/[document].astro renamed to app/app/src/components/RenderDocument.astro

Lines changed: 40 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
11
---
2-
import { getCollection } from 'astro:content'
3-
4-
import Layout from '~/layouts/Layout.astro'
5-
62
import logosrc from '~/assets/logo.png?url'
73
8-
import '@fontsource-variable/noto-serif'
9-
10-
export async function getStaticPaths()
11-
{
12-
const blogEntries = await getCollection('documents');
13-
return blogEntries.map((entry: any) =>
14-
({
15-
params: {
16-
document: entry.slug,
17-
},
18-
props: {
19-
entry,
20-
},
21-
})
22-
)
23-
}
24-
25-
const { entry } = Astro.props
26-
const { Content, headings } = await (entry as any).render()
27-
284
function splitHash(hash: string)
295
{
306
const numParts = Math.max(1, Math.min(4, Math.floor(hash.length / 4)))
@@ -42,66 +18,59 @@ function splitHash(hash: string)
4218
}
4319
---
4420

45-
<Layout title={headings[0].text}>
46-
47-
<div class="main">
48-
<div class="content-wrapper">
49-
50-
<div class="content-header">
51-
<!-- <div class="side">
52-
&nbsp;
53-
</div> -->
54-
<img src={logosrc} alt="FluffEvent logo" />
55-
<div class="overlay">
56-
<p class="version">
57-
<Fragment set:html={splitHash(import.meta.env.GITHUB_SHA || 'dev').join('<br />')} />
58-
</p>
59-
</div>
21+
<div class="main">
22+
<div class="content-wrapper">
23+
24+
<div class="content-header">
25+
<!-- <div class="side">
26+
&nbsp;
27+
</div> -->
28+
<img src={logosrc} alt="FluffEvent logo" />
29+
<div class="overlay">
30+
<p class="version">
31+
<Fragment set:html={splitHash(import.meta.env.GITHUB_SHA || 'dev').join('<br />')} />
32+
</p>
6033
</div>
34+
</div>
6135

62-
{!import.meta.env.GITHUB_SHA && (
63-
<div class="content-watermark">
64-
<p class="specimen">
65-
SPECIMEN
66-
</p>
67-
</div>
68-
)}
36+
{!import.meta.env.GITHUB_SHA && (
37+
<div class="content-watermark">
38+
<p class="specimen">
39+
SPECIMEN
40+
</p>
41+
</div>
42+
)}
6943

70-
<!-- Table hack for print layout -->
71-
<!-- https://medium.com/@Idan_Co/the-ultimate-print-html-template-with-header-footer-568f415f6d2a -->
72-
<table>
73-
<thead><tr><td>
44+
<!-- Table hack for print layout -->
45+
<!-- https://medium.com/@Idan_Co/the-ultimate-print-html-template-with-header-footer-568f415f6d2a -->
46+
<table>
47+
<thead><tr><td>
7448

75-
<div class="header-space">
76-
&nbsp;
77-
</div>
49+
<div class="header-space">
50+
&nbsp;
51+
</div>
7852

79-
</td></tr></thead>
80-
<tbody><tr><td>
53+
</td></tr></thead>
54+
<tbody><tr><td>
8155

82-
<div class="content-body">
83-
<Content />
84-
</div>
56+
<div class="content-body">
57+
<slot /> <!-- Rendered content -->
58+
</div>
8559

86-
</td></tr></tbody>
87-
<tfoot><tr><td>
60+
</td></tr></tbody>
61+
<tfoot><tr><td>
8862

89-
<div class="footer-space">
90-
&nbsp;
91-
</div>
63+
<div class="footer-space">
64+
&nbsp;
65+
</div>
9266

93-
</td></tr></tfoot>
94-
</table>
67+
</td></tr></tfoot>
68+
</table>
9569

96-
</div>
9770
</div>
98-
99-
</Layout>
71+
</div>
10072

10173
<style lang="scss" is:global>
102-
@media print {
103-
}
104-
10574
@page {
10675
size: A4;
10776
margin-top: 13.2mm; // Instead of 19mm for the header
@@ -209,12 +178,6 @@ function splitHash(hash: string)
209178
}
210179
}
211180

212-
:global(p) {
213-
+ :global(ul), + :global(ol) {
214-
@apply -mt-4;
215-
}
216-
}
217-
218181
:global(ul), :global(ol) {
219182
@apply ml-8 list-outside;
220183
list-style-type: '-';

app/app/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { AstroUserConfig } from 'astro/config'
22

33
export const i18n =
44
{
5-
defaultLocale: 'en',
5+
defaultLocale: 'fr',
66
locales: [
77
{
88
codes: ['en', 'en-US'],

app/app/src/content/private-documents/.gitkeep

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
import { getCollection } from 'astro:content'
3+
4+
import Layout from '~/layouts/Layout.astro'
5+
import RenderDocument from '~/components/RenderDocument.astro'
6+
7+
import '@fontsource-variable/noto-serif'
8+
9+
export async function getStaticPaths()
10+
{
11+
const blogEntries = await getCollection('documents');
12+
return blogEntries.map((entry: any) =>
13+
({
14+
params: {
15+
document: entry.slug,
16+
},
17+
props: {
18+
entry,
19+
},
20+
})
21+
)
22+
}
23+
24+
const { entry } = Astro.props
25+
const { Content, headings } = await (entry as any).render()
26+
---
27+
28+
<Layout title={headings[0].text}>
29+
30+
<RenderDocument>
31+
<Content />
32+
</RenderDocument>
33+
34+
</Layout>

app/app/src/pages/index.astro

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,118 @@
22
import { getCollection, getEntry } from 'astro:content'
33
import Layout from '~/layouts/Layout.astro'
44
5+
import logosrc from '~/assets/logo.png?url'
6+
57
import { i18nFactory } from '~/i18n'
68
const _ = i18nFactory(Astro.currentLocale as any)
79
810
const documents = await getCollection('documents')
11+
const privateDocuments = await getCollection('private-documents')
12+
13+
function getTitleFromBody(body: string): string | undefined
14+
{
15+
// Get text from heading 1 in markdown body
16+
const match = body.match(/^#\s+(.*)$/m)
17+
return match ? match[1] : undefined
18+
}
919
---
1020

1121
<Layout>
1222

23+
<div class="header">
24+
<img src={logosrc} alt="Logo" />
25+
<h1>
26+
{_({
27+
fr: 'Documents de l\'association Fluff Event',
28+
en: 'Fluff Event Association Documents',
29+
})}
30+
</h1>
31+
</div>
32+
1333
<div class="main">
1434

1535
<p>
1636
<span class="icon icon-[mdi--hand-wave] icon-align icon-fw"></span>
1737
{_({
18-
en: 'Welcome!',
1938
fr: 'Bienvenue !',
39+
en: 'Welcome!',
2040
})}
2141
</p>
2242

23-
<p>
24-
{_({
25-
en: 'See association documents:',
26-
fr: 'Voir les documents de l\'association :',
27-
})}
28-
</p>
43+
{documents.length > 0
44+
? (
45+
<p>
46+
{_({
47+
fr: 'Consulter les documents de l\'association :',
48+
en: 'See association documents:',
49+
})}
50+
</p>
51+
52+
<ul>
53+
{documents.map((document) => (
54+
<li>
55+
<a href={`/documents/${document.slug}`}>{getTitleFromBody(document.body) || document.slug}</a>
56+
</li>
57+
))}
58+
</ul>
59+
)
60+
: (
61+
<p>
62+
{_({
63+
fr: 'Aucun document disponible.',
64+
en: 'No documents available.',
65+
})}
66+
</p>
67+
)
68+
}
69+
70+
{privateDocuments.length > 0 && (
71+
<p>
72+
{_({
73+
fr: 'Consulter les documents privés de l\'association :',
74+
en: 'See association private documents:',
75+
})}
76+
</p>
2977

30-
<ul>
31-
{documents.map(({ slug }) => (
32-
<li>
33-
<a href={`/${slug}`}>{slug}</a>
34-
</li>
35-
))}
36-
</ul>
78+
<ul>
79+
{privateDocuments.map((document) => (
80+
<li>
81+
<a href={`/private-documents/${document.slug}`}>{getTitleFromBody(document.body) || document.slug}</a>
82+
</li>
83+
))}
84+
</ul>
85+
)}
3786

3887
</div>
3988

4089
</Layout>
4190

4291
<style lang="scss">
43-
.main {
44-
@apply m-2 border-l-2 border-gray-300 px-6 py-4;
92+
:global(body) {
93+
@apply p-6;
94+
}
95+
96+
.header, .main {
97+
@apply mb-8;
98+
}
99+
100+
.header {
101+
@apply flex items-center gap-4;
45102
}
46103

47104
*:last-child {
48105
@apply mb-0;
49106
}
50107

108+
h1 {
109+
@apply text-2xl font-bold;
110+
}
111+
112+
113+
.header img {
114+
@apply max-h-12;
115+
}
116+
51117
p {
52118
@apply mb-2;
53119
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
import { getCollection } from 'astro:content'
3+
4+
import Layout from '~/layouts/Layout.astro'
5+
import RenderDocument from '~/components/RenderDocument.astro'
6+
7+
import '@fontsource-variable/noto-serif'
8+
9+
export async function getStaticPaths()
10+
{
11+
const blogEntries = await getCollection('documents');
12+
return blogEntries.map((entry: any) =>
13+
({
14+
params: {
15+
document: entry.slug,
16+
},
17+
props: {
18+
entry,
19+
},
20+
})
21+
)
22+
}
23+
24+
const { entry } = Astro.props
25+
const { Content, headings } = await (entry as any).render()
26+
---
27+
28+
<Layout title={headings[0].text}>
29+
30+
<RenderDocument>
31+
<Content />
32+
</RenderDocument>
33+
34+
</Layout>

0 commit comments

Comments
 (0)