Skip to content

Commit 7d487c4

Browse files
authored
Merge branch 'main' into feat/infer-remote-function
2 parents 55c9422 + 37bd761 commit 7d487c4

40 files changed

+1298
-127
lines changed

astro.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default defineConfig({
3232
TableOfContents: './src/components/starlight/TableOfContents.astro',
3333
PageSidebar: './src/components/starlight/PageSidebar.astro',
3434
Pagination: './src/components/starlight/Pagination.astro',
35+
Footer: './src/components/starlight/Footer.astro',
3536
SiteTitle: './src/components/starlight/SiteTitle.astro',
3637
Search: './src/components/starlight/Search.astro',
3738
Sidebar: './src/components/starlight/Sidebar.astro',

netlify.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[build]
22
command = "NODE_OPTIONS=--max_old_space_size=4096 pnpm netlify:build"
3+
4+
[[plugins]]
5+
package = "./netlify/cache-plugin"

netlify/cache-plugin/index.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const paths = ['node_modules/.astro', 'node_modules/.astro-og-canvas'];
2+
3+
// Based on work by Jake Jarvis
4+
// https://github.com/jakejarvis/netlify-plugin-cache/blob/master/index.js
5+
6+
// MIT License
7+
8+
// Copyright (c) 2020 Jake Jarvis
9+
10+
// Permission is hereby granted, free of charge, to any person obtaining a copy
11+
// of this software and associated documentation files (the "Software"), to deal
12+
// in the Software without restriction, including without limitation the rights
13+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
// copies of the Software, and to permit persons to whom the Software is
15+
// furnished to do so, subject to the following conditions:
16+
17+
// The above copyright notice and this permission notice shall be included in all
18+
// copies or substantial portions of the Software.
19+
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
// SOFTWARE.
27+
28+
module.exports = {
29+
// Try to restore cache before build begins, if it exists
30+
onPreBuild: async ({ utils }) => {
31+
if (await utils.cache.restore(paths)) {
32+
const files = await utils.cache.list(paths);
33+
console.log(`Successfully restored: ${paths.join(', ')} ... ${files.length} files in total.`);
34+
} else {
35+
console.log(`A cache of '${paths.join(', ')}' doesn't exist (yet).`);
36+
}
37+
},
38+
39+
// Only save/update cache if build was successful
40+
onSuccess: async ({ utils }) => {
41+
if (await utils.cache.save(paths)) {
42+
const files = await utils.cache.list(paths);
43+
console.log(`Successfully cached: ${paths.join(', ')} ... ${files.length} files in total.`);
44+
45+
// Show success & more detail in deploy summary
46+
utils.status.show({
47+
title: `${files.length} files cached`,
48+
summary: 'These will be restored on the next build! ⚡',
49+
text: `${paths.join(', ')}`,
50+
});
51+
} else {
52+
// This probably happened because the default `paths` is set, so provide instructions to fix
53+
console.log(`Attempted to cache: ${paths.join(', ')} ... but failed. :(`);
54+
}
55+
},
56+
};

netlify/cache-plugin/manifest.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: netlify-cache-plugin

src/components/FooterLinks.astro

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
import { Icon } from '@astrojs/starlight/components';
3+
import FeedbackButton from '../components/tutorial/FeedbackButton.astro';
4+
import { useTranslations } from '~/i18n/util';
5+
import { getLanguageFromURL } from '~/util';
6+
7+
const t = useTranslations(Astro);
8+
const lang = getLanguageFromURL(Astro.url.pathname);
9+
---
10+
11+
<section class="sl-flex">
12+
<a href={`/${lang}/contribute/`} class="sl-flex">
13+
<Icon name="open-book" size="1.2em" />
14+
{t('rightSidebar.contribute')}
15+
</a>
16+
17+
<FeedbackButton />
18+
19+
<a href="https://community.astro.build" class="sl-flex">
20+
<Icon name="heart" size="1.2em" />
21+
{t('rightSidebar.community')}
22+
</a>
23+
</section>
24+
25+
<style>
26+
section {
27+
justify-content: center;
28+
flex-wrap: wrap;
29+
gap: 0.5rem 1.5rem;
30+
font-size: var(--sl-text-sm);
31+
}
32+
33+
a {
34+
align-items: center;
35+
text-decoration: none;
36+
gap: 0.5rem;
37+
color: var(--sl-color-gray-3);
38+
}
39+
40+
a:hover {
41+
color: var(--sl-color-white);
42+
}
43+
</style>

src/components/starlight/EditLink.astro

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
import { Icon } from '@astrojs/starlight/components';
33
import type { Props } from '@astrojs/starlight/props';
4+
import { useTranslations } from '~/i18n/util';
45
56
const { editUrl, labels, entry, locale, isFallback } = Astro.props;
67
8+
const t = useTranslations(Astro);
79
const githubEditUrl =
810
entry.data.githubURL && (locale === 'en' || isFallback)
911
? `${entry.data.githubURL}${entry.data.hasREADME ? 'README.md' : ''}`
@@ -12,14 +14,24 @@ const githubEditUrl =
1214

1315
{
1416
editUrl && (
15-
<a href={githubEditUrl} class="sl-flex">
16-
<Icon name="pencil" size="1.2em" />
17-
{labels['page.editLink']}
18-
</a>
17+
<div class="sl-flex">
18+
<a href={githubEditUrl} class="sl-flex">
19+
<Icon name="pencil" size="1.2em" />
20+
{labels['page.editLink']}
21+
</a>
22+
<a href="https://contribute.docs.astro.build/guides/i18n/" class="sl-flex">
23+
<Icon name="translate" size="1.2em" /> {t('rightSidebar.translatePage')}
24+
</a>
25+
</div>
1926
)
2027
}
2128

2229
<style>
30+
div {
31+
flex-wrap: wrap;
32+
gap: 0.5rem 1.5rem;
33+
font-size: var(--sl-text-sm);
34+
}
2335
a {
2436
gap: 0.5rem;
2537
align-items: center;

src/components/starlight/Footer.astro

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
import DefaultFooter from '@astrojs/starlight/components/Footer.astro';
3+
import FooterLinks from '../FooterLinks.astro';
4+
import type { Props } from '@astrojs/starlight/props';
5+
---
6+
7+
<DefaultFooter {...Astro.props} />
8+
<FooterLinks />

src/components/starlight/TableOfContents.astro

+2-45
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ import { useTranslations as useStarlightTranslations } from '@astrojs/starlight/
44
import TableOfContentsList from '../../../node_modules/@astrojs/starlight/components/TableOfContents/TableOfContentsList.astro';
55
import type { Props } from '@astrojs/starlight/props';
66
import TutorialNav from '../tutorial/TutorialNav.astro';
7-
import { Icon } from '@astrojs/starlight/components';
8-
import FeedbackButton from '../tutorial/FeedbackButton.astro';
97
108
const isTutorial = Astro.props.entry.slug.split('/')[1] === 'tutorial';
119
12-
const { locale, toc, editUrl, entry, isFallback } = Astro.props;
10+
const { locale, toc } = Astro.props;
1311
const t = useTranslations(Astro);
1412
const starlightTranslations = useStarlightTranslations(locale);
15-
16-
const githubEditUrl =
17-
entry.data.githubURL && (locale === 'en' || isFallback)
18-
? `${entry.data.githubURL}${entry.data.hasREADME ? 'README.md' : ''}`
19-
: editUrl;
2013
---
2114

2215
{
@@ -28,47 +21,11 @@ const githubEditUrl =
2821
? t('tutorial.trackerLabel')
2922
: starlightTranslations('tableOfContents.onThisPage')}
3023
</h2>
31-
{isTutorial ? (
32-
<TutorialNav {...Astro.props} />
33-
) : (
34-
<>
35-
<TableOfContentsList toc={toc.items} />
36-
<h2 class="contribute">{t('rightSidebar.contribute')}</h2>
37-
<ul>
38-
<li>
39-
<a href={`/${locale}/contribute/`}>
40-
<Icon name="open-book" /> {t('rightSidebar.contribute')}
41-
</a>
42-
</li>
43-
<li>
44-
<a href={githubEditUrl}>
45-
<Icon name="pencil" /> {t('rightSidebar.editPage')}
46-
</a>
47-
</li>
48-
<li>
49-
<a href="https://contribute.docs.astro.build/guides/i18n/">
50-
<Icon name="translate" /> {t('rightSidebar.translatePage')}
51-
</a>
52-
</li>
53-
</ul>
54-
<FeedbackButton />
55-
</>
56-
)}
24+
{isTutorial ? <TutorialNav {...Astro.props} /> : <TableOfContentsList toc={toc.items} />}
5725
</nav>
5826
</starlight-toc>
5927
)
6028
}
6129

62-
<style>
63-
ul {
64-
padding: 0;
65-
list-style: none;
66-
}
67-
68-
.contribute {
69-
margin-top: 1rem;
70-
}
71-
</style>
72-
7330
<script src="../../../node_modules/@astrojs/starlight/components/TableOfContents/starlight-toc"
7431
></script>

src/components/tutorial/FeedbackButton.astro

+20-11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const instanceId = Math.round(Math.random() * 10e9).toString(36);
2626

2727
<feedback-form>
2828
<button data-open-modal disabled>
29+
<Icon name="comment-alt" size="1.2em" />
2930
<UIString key="feedback.button" />
3031
</button>
3132

@@ -234,6 +235,17 @@ const instanceId = Math.round(Math.random() * 10e9).toString(36);
234235
--feedback-form-close-icon-size: 1.5rem;
235236
}
236237

238+
button[data-open-modal] {
239+
display: flex;
240+
align-items: center;
241+
gap: 0.5rem;
242+
color: var(--sl-color-gray-3);
243+
}
244+
245+
button[data-open-modal]:hover {
246+
color: var(--sl-color-white);
247+
}
248+
237249
dialog {
238250
font-size: var(--theme-text-base);
239251
margin: 1.5rem auto auto;
@@ -368,6 +380,8 @@ const instanceId = Math.round(Math.random() * 10e9).toString(36);
368380
height: 100%;
369381
font-size: var(--sl-text-2xl);
370382
cursor: pointer;
383+
text-decoration: none;
384+
color: var(--sl-color-white);
371385
}
372386

373387
.select-buttons > button {
@@ -381,6 +395,11 @@ const instanceId = Math.round(Math.random() * 10e9).toString(36);
381395
}
382396

383397
.select-buttons h2 {
398+
font-size: var(--sl-text-h5);
399+
font-weight: 600;
400+
line-height: var(--sl-line-height-headings);
401+
margin-bottom: 0.5rem;
402+
text-decoration: none;
384403
color: var(--sl-color-white);
385404
}
386405

@@ -458,19 +477,9 @@ const instanceId = Math.round(Math.random() * 10e9).toString(36);
458477
}
459478

460479
button[data-open-modal] {
461-
margin-top: 0.5rem;
462-
border: 1px solid var(--sl-color-gray-1);
463-
border-radius: 1rem;
464480
background-color: transparent;
465481
cursor: pointer;
466-
font-size: var(--sl-text-xs);
467-
line-height: calc(1 / var(--theme-text-xs));
468-
padding: 0.25rem 0.75rem;
469-
}
470-
471-
button[data-open-modal]:hover,
472-
button[data-open-modal]:focus {
473-
background-color: var(--sl-color-gray-6);
482+
border: none;
474483
}
475484

476485
button[data-open-modal]:focus:not(:focus-visible) {

0 commit comments

Comments
 (0)