Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reorg] new Recipes section; Basics streamlined #2550

Merged
merged 108 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
f8ead78
initial sidebar reorg
sarah11918 Feb 2, 2023
596f8db
tutorials key
sarah11918 Feb 2, 2023
66c64c3
new (hidden) recipes page
sarah11918 Feb 2, 2023
0a85c2c
move ui frameworks back to guides
sarah11918 Feb 6, 2023
8aba826
add astro syntax hidden page
sarah11918 Feb 6, 2023
8440e66
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 6, 2023
0e28781
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 6, 2023
51c06ba
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 7, 2023
3aab63e
update recipes page
sarah11918 Feb 7, 2023
dc4da7b
create initial nanostores recipe page from sharing state
sarah11918 Feb 7, 2023
46e86a4
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 16, 2023
3620c7d
Update pages for content collections
delucis Feb 16, 2023
238d152
falso -> false
sarah11918 Feb 17, 2023
6d87fc5
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 17, 2023
3fd8385
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 17, 2023
4534cc6
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 17, 2023
73cf55d
new captcha recipe pulled from endpoints
sarah11918 Feb 17, 2023
57329db
add yaml support recipe
sarah11918 Feb 18, 2023
93a67cb
move some component content out
sarah11918 Feb 18, 2023
081a674
slimmed down components page
sarah11918 Feb 18, 2023
8a9800f
some simplifying/editing edits to routing
sarah11918 Feb 18, 2023
f5414f2
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 18, 2023
d737a36
update links to astro-syntax
sarah11918 Feb 18, 2023
fcfec7b
attempt CI fail fixes
sarah11918 Feb 18, 2023
a65df3e
nav.ts indentation?
sarah11918 Feb 18, 2023
48a3306
update CLI page and put in Learn menu
sarah11918 Feb 19, 2023
4e6175b
more edits to CLI page intro for friendliness
sarah11918 Feb 19, 2023
a9d8325
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 19, 2023
f2a9feb
update i18n nav.ts for sidebar updates
sarah11918 Feb 19, 2023
72f0ece
final nav.ts cleanup
sarah11918 Feb 19, 2023
89fa287
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 20, 2023
db26118
more user-friendly CLI intro
sarah11918 Feb 20, 2023
1ef6b36
even friendlier CLI!
sarah11918 Feb 20, 2023
2a0e2e2
hack so CLI is in Learn category for sidebar highlighting
sarah11918 Feb 20, 2023
8c60bf1
some Components page tidying - slots!
sarah11918 Feb 20, 2023
35dcb44
minor tidying of Astro syntax as a standalone page
sarah11918 Feb 20, 2023
5344f58
Highlight recipes when on a page in recipes folder
sarah11918 Feb 20, 2023
e43f391
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 20, 2023
7dbe4a2
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 21, 2023
0c9309b
Recipe components
sarah11918 Feb 21, 2023
b4fcc52
i18n(ja): Update nav.ts (#2693)
morinokami Feb 22, 2023
9f61360
move Routing and MD/MDX pages into guides
sarah11918 Feb 23, 2023
51e6669
rename new page Astro Template Syntax
sarah11918 Feb 23, 2023
f2a76b6
recipes folder
Jutanium Feb 23, 2023
f904e35
Move fonts back to guides
Jutanium Feb 23, 2023
f9d9edc
all recipes -> more recipes
Jutanium Feb 23, 2023
f68cb33
remove back button on recipe index
Jutanium Feb 23, 2023
6fce406
Merge branch 'main' into reorg-incl-recipes
delucis Feb 24, 2023
af2e870
Fix nav key type issue
delucis Feb 24, 2023
166f218
Move main recipes file to avoid `index.mdx`
delucis Feb 24, 2023
6977d33
i18n(zh-cn): Update nav.ts based on reorg-incl-recipes (#2687)
liruifengv Feb 24, 2023
aa7b450
update of nav (#2725)
dreyfus92 Feb 24, 2023
bbc3452
kill nanostores, replace with orig sharing state
sarah11918 Feb 24, 2023
85cb32f
add commented out original content back in to CLI
sarah11918 Feb 24, 2023
7fa3ea3
Make logos optional in `<CardsNav>`
delucis Feb 24, 2023
543c9d2
Add optional `description` support to `<CardsNav>`
delucis Feb 24, 2023
e91b428
Configure content collection schema for recipes (no tags yet)
delucis Feb 24, 2023
71cbfb3
Add `type: recipe` to recipes & write missing descriptions
delucis Feb 24, 2023
cd29df7
Very basic `<RecipesNav>` — needs tag, i18n support & styling
delucis Feb 24, 2023
c77cbd4
Replace `<RecipeBox>` with `<RecipesNav>`
delucis Feb 24, 2023
1e3c3ac
Fix es nav type error
delucis Feb 24, 2023
89977bd
sharing state -> share state between islands
Jutanium Feb 24, 2023
a511f11
Tweak card grid to work better for recipe cards
delucis Feb 24, 2023
958bff4
Style description text in `<Card>`
delucis Feb 24, 2023
b5bbf7e
Remove unneeded styles in `<CMSGuidesNav>`
delucis Feb 24, 2023
7322ab9
Fix margins on `<RecipesNav>`
delucis Feb 24, 2023
cf6dfa6
Fix `<RecipesNav>` links & remove tags
delucis Feb 24, 2023
1fd34a1
Add `<RecipeLayout>`
delucis Feb 24, 2023
a318164
move CLI Reference page back to reference, remove Learn cateogry
sarah11918 Feb 24, 2023
4f74b44
add links back to recipes from original pages
sarah11918 Feb 26, 2023
ed1e3be
nit edits in integrations-guide
sarah11918 Feb 26, 2023
d8cb016
links no longer notes; use emoji
sarah11918 Feb 26, 2023
f302d32
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 26, 2023
bec79ca
related recipes bold text instead of heading; might delete
sarah11918 Feb 26, 2023
e8259d8
updated links to recipes - one line
sarah11918 Feb 26, 2023
0e5a60b
fix broken link, move recipe to proper page!
sarah11918 Feb 26, 2023
af35eae
Merge branch 'main' into reorg-incl-recipes
sarah11918 Feb 26, 2023
cda234c
Curated -> Official
Jutanium Feb 28, 2023
126d6d3
[i18nIgnore] Add new subpage handling logic (#2758)
yanthomasdev Feb 28, 2023
bc2fbf7
Merge branch 'main' into reorg-incl-recipes
sarah11918 Mar 1, 2023
05c54a5
handle forms recipe + skeleton
Jutanium Mar 1, 2023
414644e
build forms with api routes - 3 steps, examples for 5 frameworks
Jutanium Mar 2, 2023
05f9909
captcha we -> you and formatting
Jutanium Mar 2, 2023
c2caff4
Merge branch 'main' into reorg-incl-recipes
sarah11918 Mar 2, 2023
745d662
incorporate changes from PR2404 into Astro Syntax
sarah11918 Mar 2, 2023
7d743f9
incorporated changes from 2404 into Astro Components
sarah11918 Mar 2, 2023
61ba2ff
update code example to show an Astro component vs UI framework
sarah11918 Mar 2, 2023
b840050
prereqs
Jutanium Mar 2, 2023
43acf83
yaml -> vite or rollup
Jutanium Mar 2, 2023
9a9030a
Sarah edits to HTML forms - check carefully for still needs!
sarah11918 Mar 3, 2023
29ecf94
tiny Sarah edits
sarah11918 Mar 3, 2023
a398858
Dan's improved instructions
sarah11918 Mar 4, 2023
740f4a3
no typos under Yan's watch!
sarah11918 Mar 5, 2023
9a0c6cf
removing inelegance!
sarah11918 Mar 5, 2023
549d48e
Update src/content/docs/en/recipes/build-forms.mdx
Jutanium Mar 5, 2023
7ca3ec5
Delete clipboard-check.svg
delucis Mar 6, 2023
97683f7
Merge branch 'main' into reorg-incl-recipes
delucis Mar 6, 2023
4ea24c3
Remove duplicate nav entry
delucis Mar 6, 2023
2dfc984
tweak order of guides
sarah11918 Mar 6, 2023
eeb7f7d
nod to script and style tags in components, removed dup from script page
sarah11918 Mar 6, 2023
67b5dca
remove forms recipes
Jutanium Mar 6, 2023
a54655d
Update PT-BR `nav.ts` file
yanthomasdev Mar 6, 2023
6454a39
nav tweaks esp routing
sarah11918 Mar 6, 2023
ab6f9a5
bye bye, "sits the template"
sarah11918 Mar 6, 2023
99442ac
Use translations correct in `<RecipesNav>`
delucis Mar 6, 2023
45f3fc4
Add `lang="en"` to English fallback content in `<RecipesNav>`
delucis Mar 6, 2023
d47fb67
Update PT-BR `rss.mdx` description
yanthomasdev Mar 6, 2023
5ec7b12
Also update the PT-BR `title` prop!
yanthomasdev Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/components/CMSGuidesNav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,4 @@ const links = enPages
.cms-nav > :global(*) {
margin-top: -2rem;
}

.cms-nav > :global(* + *) {
margin-top: -3rem;
}

.cms-nav :global(.scope) {
font-weight: normal;
color: var(--theme-text-lighter);
}

h3 {
margin-bottom: 0;
}
</style>
2 changes: 1 addition & 1 deletion src/components/LeftSidebar/LeftSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let activeTab: 'learn' | 'api' = 'learn';

// Certain pages are not in the sidebar nav, so we manually set the active tab based on other factors (e.g. Algolia page category).
const isReference = ['Error Reference', 'Reference'].includes(
getPageCategory(new URL(currentPage, import.meta.url))
getPageCategory({ pathname: currentPage })
);
if (isReference) {
activeTab = 'api';
Expand Down
9 changes: 3 additions & 6 deletions src/components/LeftSidebar/SidebarContent.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import { getLanguageFromURL, removeSubpageSegment } from '../../util';
import { getLanguageFromURL } from '~/util';
import { isSubPage } from '~/util/isSubPage';

export interface Props {
type: TabType;
Expand Down Expand Up @@ -44,11 +45,7 @@ const lang = getLanguageFromURL(Astro.url.pathname);
<a
href={`${Astro.site?.pathname}${lang}/${slug}/`}
aria-current={`${currentPageMatch.endsWith(slug) ? 'page' : 'false'}`}
data-current-parent={`${
removeSubpageSegment(currentPageMatch).endsWith(removeSubpageSegment(slug))
? 'true'
: 'false'
}`}
data-current-parent={`${isSubPage(currentPageMatch, slug) ? 'true' : 'false'}`}
>
<Fragment set:html={text} /> {isFallback && <sup class="fallback">EN</sup>}
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NavGrid/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BrandLogo from '../BrandLogo.astro';

export interface Props {
href: string;
logo: LogoKey;
logo?: LogoKey;
current?: boolean;
minimal?: boolean;
[key: string]: any;
Expand All @@ -14,7 +14,7 @@ const { href, logo, current, minimal, class: classes, ...attrs } = Astro.props a
---

<li class:list={['card', minimal ? 'card--minimal' : 'card--maximal', classes]} {...attrs}>
<BrandLogo brand={logo} />
{logo && <BrandLogo brand={logo} />}
<div class="stack">
<h3>
<a href={href} aria-current={current ? 'page' : 'false'}>
Expand Down
16 changes: 13 additions & 3 deletions src/components/NavGrid/CardsNav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ export interface Props {
minimal?: boolean;
links: {
title: string;
description?: string;
href: string;
logo: LogoKey;
logo?: LogoKey;
/** Map of tag IDs to translated tag display text, e.g. `{ static: 'Statisch' }`. */
tags?: Record<string, string>;
/** The language of the content if it differs from the main page language. */
lang?: string;
}[];
class?: string;
}
Expand All @@ -25,14 +28,15 @@ const currentPage = new URL(Astro.request.url).pathname;
<slot />
<Grid minimal={minimal}>
{
links.map(({ href, logo, title, tags }) => (
links.map(({ description, href, logo, title, tags, lang }) => (
<Card
{...{ minimal, logo, href }}
{...{ minimal, logo, href, lang }}
current={currentPage.includes(href)}
class={Object.keys(tags || {}).join(' ')}
>
<Fragment slot="title" set:html={title} />
<Fragment slot="details">
{description && <p class="description">{description}</p>}
{tags && (
<div class="tags">
{Object.values(tags).map((tag) => (
Expand All @@ -53,6 +57,12 @@ const currentPage = new URL(Astro.request.url).pathname;
accent-color: var(--theme-accent-secondary);
}

.description {
margin-top: 0.25rem;
color: var(--theme-text-lighter);
font-size: var(--theme-text-sm);
}

.tags {
display: flex;
gap: 0.5rem;
Expand Down
6 changes: 3 additions & 3 deletions src/components/NavGrid/Grid.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const { minimal } = Astro.props as Props;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--column-min-width), 1fr));
grid-template-columns: repeat(auto-fill, minmax(min(var(--column-min-width), 100%), 1fr));
gap: 1.5rem;
gap: 2rem;
list-style: none;
align-items: start;
}

@media (min-width: 37.75em) {
.fluid-grid {
gap: 1.5rem 2.5rem;
gap: 2rem 2.5rem;
}
}

.fluid-grid--minimal {
--column-min-width: 6rem;
gap: 1.5rem 0.75rem;
align-items: start;
}
</style>
46 changes: 46 additions & 0 deletions src/components/RecipesNav.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
import { recipePages } from '~/content';
import { createIsLangEntry, isEnglishEntry } from '~/content/config';
import { getLanguageFromURL, stripLangFromSlug } from '~/util';
import CardsNav from './NavGrid/CardsNav.astro';

export interface Props {
minimal?: boolean;
}

const lang = getLanguageFromURL(Astro.url.pathname);
const langRecipes = recipePages.filter(createIsLangEntry(lang));
const englishRecipes = recipePages.filter(isEnglishEntry);

/** An array of all recipes, using translations if available and falling back to English otherwise. */
const recipes = englishRecipes.map((fallback) => {
const slug = stripLangFromSlug(fallback.slug);
const translation = langRecipes.find((doc) => stripLangFromSlug(doc.slug) === slug);
return translation || fallback;
});
---

<div>
<CardsNav
minimal={Astro.props.minimal}
links={recipes.map(({ data, slug }) => {
const linkLang = slug.split('/').shift();
return {
title: data.title,
description: data.description,
// Fallback entries will have a slug starting with 'en/',
// so we replace that to link to the correct language.
href: '/' + slug.replace('en/', `${lang}/`) + '/',
// Fallback content will be in English, unlike the page,
// so we set an explicit `lang="en"` for these entries.
lang: linkLang !== lang ? linkLang : undefined,
};
})}
/>
</div>

<style>
div > :global(*) {
margin-top: -2rem;
}
</style>
3 changes: 2 additions & 1 deletion src/content.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCollection } from 'astro:content';
import { isEnglishEntry, isTutorialEntry } from './content/config';
import { isEnglishEntry, isRecipeEntry, isTutorialEntry } from './content/config';

export const allPages = await getCollection('docs');
export const tutorialPages = allPages.filter(isTutorialEntry);
export const recipePages = allPages.filter(isRecipeEntry);
export const englishPages = allPages.filter(isEnglishEntry);
22 changes: 20 additions & 2 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export const tutorialSchema = baseSchema.extend({
unitTitle: z.string().optional(),
});

export const recipeSchema = baseSchema.extend({
type: z.literal('recipe'),
description: z.string(),
});

export type DeployEntry = CollectionEntry<'docs'> & {
data: z.infer<typeof deploySchema>;
};
Expand All @@ -65,6 +70,10 @@ export type TutorialEntry = CollectionEntry<'docs'> & {
data: z.infer<typeof tutorialSchema>;
};

export type RecipeEntry = CollectionEntry<'docs'> & {
data: z.infer<typeof recipeSchema>;
};

export type IntegrationCategory = z.infer<typeof integrationSchema>['category'];

export function isCmsEntry(entry: CollectionEntry<'docs'>): entry is CmsEntry {
Expand All @@ -83,10 +92,18 @@ export function isMigrationEntry(entry: CollectionEntry<'docs'>): entry is Migra
return entry.data.type === 'migration';
}

export function isEnglishEntry(entry: CollectionEntry<'docs'>): boolean {
return entry.slug.startsWith('en/');
export function isRecipeEntry(entry: CollectionEntry<'docs'>): entry is RecipeEntry {
return entry.data.type === 'recipe';
}

export function createIsLangEntry(lang: string) {
return function isLangEntry(entry: CollectionEntry<'docs'>): boolean {
return entry.slug.startsWith(lang + '/');
};
}

export const isEnglishEntry = createIsLangEntry('en');

const docs = defineCollection({
schema: z.union([
baseSchema,
Expand All @@ -95,6 +112,7 @@ const docs = defineCollection({
migrationSchema,
tutorialSchema,
deploySchema,
recipeSchema,
]),
});

Expand Down
Loading