@brimsites/brimjs 0.0.0-stage → 1.0.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.
- package/LICENSE +110 -0
- package/README.md +22 -2
- package/bin/brim.js +5 -0
- package/dist/cli.js +3802 -0
- package/editor-dist/editor.css +1 -0
- package/editor-dist/editor.js +91 -0
- package/package.json +71 -3
- package/skills/brim-convert/SKILL.md +256 -0
- package/skills/brim-hosting/SKILL.md +221 -0
- package/src/astro-shim.d.ts +5 -0
- package/src/auth/accounts.ts +341 -0
- package/src/auth/password.ts +34 -0
- package/src/auth/permissions.ts +44 -0
- package/src/blocks/accordion/Accordion.astro +48 -0
- package/src/blocks/accordion/accordion.css +63 -0
- package/src/blocks/analytics/Analytics.astro +45 -0
- package/src/blocks/analytics/ConsentBanner.astro +41 -0
- package/src/blocks/analytics/analytics.client.ts +125 -0
- package/src/blocks/analytics/analytics.css +51 -0
- package/src/blocks/analytics/consent.ts +51 -0
- package/src/blocks/button/Button.astro +64 -0
- package/src/blocks/button/button.css +100 -0
- package/src/blocks/carousel/Carousel.astro +140 -0
- package/src/blocks/carousel/carousel.client.ts +153 -0
- package/src/blocks/carousel/carousel.css +181 -0
- package/src/blocks/data/icons.ts +285 -0
- package/src/blocks/data/image-shapes.ts +91 -0
- package/src/blocks/data/social-icons.ts +41 -0
- package/src/blocks/data/social-networks.ts +256 -0
- package/src/blocks/divider/Divider.astro +27 -0
- package/src/blocks/divider/divider.css +17 -0
- package/src/blocks/form/Captcha.astro +27 -0
- package/src/blocks/form/Form.astro +250 -0
- package/src/blocks/form/FormField.astro +138 -0
- package/src/blocks/form/Newsletter.astro +80 -0
- package/src/blocks/form/form.client.ts +339 -0
- package/src/blocks/form/form.css +271 -0
- package/src/blocks/gallery/ImageGallery.astro +126 -0
- package/src/blocks/gallery/gallery.css +43 -0
- package/src/blocks/gallery/lightbox.client.ts +178 -0
- package/src/blocks/gallery/lightbox.css +134 -0
- package/src/blocks/icon/Icon.astro +41 -0
- package/src/blocks/icon/icon.css +16 -0
- package/src/blocks/image/Image.astro +158 -0
- package/src/blocks/image/image.css +42 -0
- package/src/blocks/images.ts +64 -0
- package/src/blocks/in-editor.client.ts +8 -0
- package/src/blocks/listing/Listing.astro +288 -0
- package/src/blocks/listing/ListingCards.astro +48 -0
- package/src/blocks/listing/listing.css +136 -0
- package/src/blocks/listing/query.ts +363 -0
- package/src/blocks/map/Map.astro +75 -0
- package/src/blocks/map/map.css +32 -0
- package/src/blocks/schemas/accordion.ts +118 -0
- package/src/blocks/schemas/button.ts +78 -0
- package/src/blocks/schemas/carousel.ts +133 -0
- package/src/blocks/schemas/divider.ts +29 -0
- package/src/blocks/schemas/form-field-types.ts +29 -0
- package/src/blocks/schemas/form.ts +350 -0
- package/src/blocks/schemas/icon.ts +24 -0
- package/src/blocks/schemas/image-gallery.ts +54 -0
- package/src/blocks/schemas/image.ts +87 -0
- package/src/blocks/schemas/index.ts +33 -0
- package/src/blocks/schemas/listing.ts +14 -0
- package/src/blocks/schemas/map.ts +81 -0
- package/src/blocks/schemas/newsletter.ts +324 -0
- package/src/blocks/schemas/social-media.ts +348 -0
- package/src/blocks/schemas/text.ts +151 -0
- package/src/blocks/schemas/video.ts +57 -0
- package/src/blocks/search/Search.astro +147 -0
- package/src/blocks/search/search.css +69 -0
- package/src/blocks/search/state.ts +28 -0
- package/src/blocks/settings.ts +94 -0
- package/src/blocks/social/SocialMedia.astro +102 -0
- package/src/blocks/social/social-links.ts +16 -0
- package/src/blocks/social/social.css +31 -0
- package/src/blocks/theme.ts +35 -0
- package/src/blocks/types.ts +52 -0
- package/src/blocks/video/Video.astro +90 -0
- package/src/blocks/video/video-source.ts +77 -0
- package/src/blocks/video/video.client.ts +43 -0
- package/src/blocks/video/video.css +29 -0
- package/src/check.ts +1119 -0
- package/src/cli.ts +493 -0
- package/src/components/Blocks.astro +68 -0
- package/src/components/Field.astro +61 -0
- package/src/components/Footer.astro +36 -0
- package/src/components/Link.astro +18 -0
- package/src/components/MobileMenu.astro +77 -0
- package/src/components/Navbar.astro +42 -0
- package/src/components/RichText.astro +32 -0
- package/src/components/Seo.astro +202 -0
- package/src/components/Setting.astro +46 -0
- package/src/components/Shared.astro +17 -0
- package/src/components/Text.astro +91 -0
- package/src/components/blocks.css +86 -0
- package/src/components/index.ts +27 -0
- package/src/components/mobile-menu.client.ts +21 -0
- package/src/components/mobile-menu.css +52 -0
- package/src/components/text.css +48 -0
- package/src/config.ts +413 -0
- package/src/content/block-layout.ts +63 -0
- package/src/content/block-values.ts +48 -0
- package/src/content/content-check.ts +174 -0
- package/src/content/content-types.ts +408 -0
- package/src/content/drafts.ts +115 -0
- package/src/content/feed.ts +237 -0
- package/src/content/field-types.ts +107 -0
- package/src/content/history.ts +140 -0
- package/src/content/ids.ts +50 -0
- package/src/content/image-size.ts +212 -0
- package/src/content/image-sizes.ts +126 -0
- package/src/content/item-fields.ts +110 -0
- package/src/content/item-head.ts +126 -0
- package/src/content/item-image.ts +26 -0
- package/src/content/item-path.ts +122 -0
- package/src/content/items.ts +580 -0
- package/src/content/language-scopes.ts +40 -0
- package/src/content/media.ts +271 -0
- package/src/content/menus.ts +51 -0
- package/src/content/page-templates.ts +52 -0
- package/src/content/redirects.ts +112 -0
- package/src/content/references.ts +165 -0
- package/src/content/rich-text.ts +63 -0
- package/src/content/search.ts +167 -0
- package/src/content/seed.ts +229 -0
- package/src/content/site-settings.ts +111 -0
- package/src/content/sitemap.ts +143 -0
- package/src/content/store.ts +225 -0
- package/src/content/tags.ts +67 -0
- package/src/content/text-default.ts +139 -0
- package/src/content/types.ts +137 -0
- package/src/content/validate.ts +253 -0
- package/src/content/validation-error.ts +2 -0
- package/src/db/cached.ts +140 -0
- package/src/db/database.ts +15 -0
- package/src/db/libsql.ts +29 -0
- package/src/db/schema.ts +189 -0
- package/src/db/url.ts +44 -0
- package/src/editor/client/BlockSettings.tsx +1063 -0
- package/src/editor/client/Chrome.tsx +284 -0
- package/src/editor/client/ContentBrowser.tsx +1299 -0
- package/src/editor/client/Editor.tsx +1756 -0
- package/src/editor/client/HistoryPanel.tsx +114 -0
- package/src/editor/client/ImagesWidget.tsx +113 -0
- package/src/editor/client/Inspector.tsx +127 -0
- package/src/editor/client/ItemForm.tsx +535 -0
- package/src/editor/client/LinkWidget.tsx +440 -0
- package/src/editor/client/ListingPanel.tsx +99 -0
- package/src/editor/client/Login.tsx +338 -0
- package/src/editor/client/Menu.tsx +64 -0
- package/src/editor/client/PageSettings.tsx +270 -0
- package/src/editor/client/RedirectsSettings.tsx +130 -0
- package/src/editor/client/Resize.tsx +204 -0
- package/src/editor/client/Sidebar.tsx +51 -0
- package/src/editor/client/SiteMap.tsx +568 -0
- package/src/editor/client/SiteSettings.tsx +409 -0
- package/src/editor/client/TextTools.tsx +391 -0
- package/src/editor/client/Toolbar.tsx +449 -0
- package/src/editor/client/VideoUpload.tsx +251 -0
- package/src/editor/client/api.ts +417 -0
- package/src/editor/client/brand.ts +20 -0
- package/src/editor/client/connection.ts +98 -0
- package/src/editor/client/context.ts +19 -0
- package/src/editor/client/css.d.ts +2 -0
- package/src/editor/client/editor.css +4656 -0
- package/src/editor/client/fields.tsx +812 -0
- package/src/editor/client/icons.tsx +174 -0
- package/src/editor/client/keys.ts +15 -0
- package/src/editor/client/kinds.ts +289 -0
- package/src/editor/client/languages.ts +32 -0
- package/src/editor/client/main.tsx +100 -0
- package/src/editor/client/responses.ts +26 -0
- package/src/editor/client/rich-text.ts +326 -0
- package/src/editor/client/site-tree.ts +239 -0
- package/src/editor/client/theme.ts +55 -0
- package/src/editor/client/tsconfig.json +18 -0
- package/src/editor/client/tus.ts +137 -0
- package/src/editor/client/use-rect.ts +50 -0
- package/src/editor/client/widgets.tsx +1218 -0
- package/src/forms/captcha.ts +83 -0
- package/src/forms/define.ts +166 -0
- package/src/forms/fields.ts +197 -0
- package/src/forms/file-types.ts +108 -0
- package/src/forms/files.ts +216 -0
- package/src/forms/form-page.ts +9 -0
- package/src/forms/handler.ts +622 -0
- package/src/forms/spec.ts +89 -0
- package/src/forms/store.ts +96 -0
- package/src/forms/work.ts +50 -0
- package/src/icons/library.ts +144 -0
- package/src/icons/load.ts +63 -0
- package/src/index.ts +99 -0
- package/src/init.ts +257 -0
- package/src/integration.ts +469 -0
- package/src/mail/mailer.ts +197 -0
- package/src/mail/notify.ts +272 -0
- package/src/mail/settings.ts +173 -0
- package/src/mail/templates.ts +191 -0
- package/src/mcp/page-nodes.ts +209 -0
- package/src/mcp/server.ts +111 -0
- package/src/mcp/tools.ts +637 -0
- package/src/runtime/TemplatePage.astro +39 -0
- package/src/runtime/TemplatePageStatic.astro +13 -0
- package/src/runtime/admin-route.ts +80 -0
- package/src/runtime/connect.ts +53 -0
- package/src/runtime/content.ts +188 -0
- package/src/runtime/context.ts +131 -0
- package/src/runtime/form-files.ts +18 -0
- package/src/runtime/forms-route.ts +33 -0
- package/src/runtime/forms.ts +28 -0
- package/src/runtime/icons.ts +5 -0
- package/src/runtime/media.ts +175 -0
- package/src/runtime/middleware.ts +186 -0
- package/src/runtime/nav.ts +13 -0
- package/src/runtime/query-reads.ts +49 -0
- package/src/runtime/query-store.ts +16 -0
- package/src/runtime/request-state.ts +69 -0
- package/src/runtime/robots.ts +29 -0
- package/src/runtime/rss-static.ts +16 -0
- package/src/runtime/rss.ts +29 -0
- package/src/runtime/server.ts +29 -0
- package/src/runtime/sitemap.ts +34 -0
- package/src/runtime/template-paths.ts +34 -0
- package/src/runtime/uploads-route.ts +13 -0
- package/src/seed-cli.ts +253 -0
- package/src/server/auth.ts +31 -0
- package/src/server/fetch-image.ts +219 -0
- package/src/server/handler.ts +2106 -0
- package/src/server/http.ts +162 -0
- package/src/server/locales.ts +73 -0
- package/src/server/node.ts +57 -0
- package/src/server/query-params.ts +249 -0
- package/src/server/rate-limit.ts +72 -0
- package/src/server/video-host.ts +162 -0
- package/src/starter.ts +70 -0
- package/src/version.ts +4 -0
- package/src/virtual.d.ts +65 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { defaultScope } from "../runtime/request-state.ts";
|
|
3
|
+
import type { NodeScope } from "../runtime/context.ts";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
nodeId: string;
|
|
7
|
+
href: string;
|
|
8
|
+
scope?: NodeScope;
|
|
9
|
+
[attribute: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { nodeId, href, scope = defaultScope(), ...attributes } = Astro.props;
|
|
13
|
+
const stored = Astro.locals.brim.read("link", nodeId, scope);
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<a {...attributes} {...Astro.locals.brim.marker("link", nodeId, scope)} href={stored?.href ?? href}>
|
|
17
|
+
{stored?.label ?? <slot />}
|
|
18
|
+
</a>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "./mobile-menu.css";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A menu that opens over the whole page from a button. Brim keeps how it opens and closes; what is inside and how
|
|
6
|
+
* it looks is the site's:
|
|
7
|
+
*
|
|
8
|
+
* <MobileMenu label="Menu" closeLabel="Close" class="mobile-menu">
|
|
9
|
+
* <ul>{items.map((item) => <li><a href={item.href}>{item.label}</a></li>)}</ul>
|
|
10
|
+
* </MobileMenu>
|
|
11
|
+
*
|
|
12
|
+
* It is the browser's own popover, which is drawn above the page and measured from the screen whatever the header
|
|
13
|
+
* around it does: a `backdrop-filter`, `transform`, `overflow` or `z-index` on an ancestor cannot cut it or put it
|
|
14
|
+
* behind the page. Escape, the button and a click outside close it; so does following one of its links, or a screen
|
|
15
|
+
* turned wide enough for the site to hide the button.
|
|
16
|
+
*
|
|
17
|
+
* The site's CSS says from which width it shows. The `toggle` and `close` slots replace the icons. Two on one page
|
|
18
|
+
* need an `id` each.
|
|
19
|
+
*/
|
|
20
|
+
interface Props {
|
|
21
|
+
/** What the button is called for a screen reader, in the page's language. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** The same for the button that closes it. */
|
|
24
|
+
closeLabel: string;
|
|
25
|
+
id?: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
[attribute: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { label, closeLabel, id = "brim-mobile-menu", class: className, ...attributes } = Astro.props;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<div class:list={["brim-mobile-menu", className]} {...attributes}>
|
|
34
|
+
<button type="button" class="brim-mobile-menu__toggle" popovertarget={id} aria-label={label}>
|
|
35
|
+
<slot name="toggle">
|
|
36
|
+
<svg
|
|
37
|
+
viewBox="0 0 24 24"
|
|
38
|
+
width="24"
|
|
39
|
+
height="24"
|
|
40
|
+
fill="none"
|
|
41
|
+
stroke="currentColor"
|
|
42
|
+
stroke-width="2"
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
>
|
|
45
|
+
<path d="M4 7h16M4 12h16M4 17h16"></path>
|
|
46
|
+
</svg>
|
|
47
|
+
</slot>
|
|
48
|
+
</button>
|
|
49
|
+
<nav id={id} popover class="brim-mobile-menu__panel" aria-label={label}>
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
class="brim-mobile-menu__close"
|
|
53
|
+
popovertarget={id}
|
|
54
|
+
popovertargetaction="hide"
|
|
55
|
+
aria-label={closeLabel}
|
|
56
|
+
>
|
|
57
|
+
<slot name="close">
|
|
58
|
+
<svg
|
|
59
|
+
viewBox="0 0 24 24"
|
|
60
|
+
width="24"
|
|
61
|
+
height="24"
|
|
62
|
+
fill="none"
|
|
63
|
+
stroke="currentColor"
|
|
64
|
+
stroke-width="2"
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
>
|
|
67
|
+
<path d="M6 6l12 12M18 6L6 18"></path>
|
|
68
|
+
</svg>
|
|
69
|
+
</slot>
|
|
70
|
+
</button>
|
|
71
|
+
<slot />
|
|
72
|
+
</nav>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<script>
|
|
76
|
+
import "./mobile-menu.client.ts";
|
|
77
|
+
</script>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from "virtual:brim/config";
|
|
3
|
+
import type { ImageValue, NavItem, NavbarValue } from "../content/types.ts";
|
|
4
|
+
import { expandNavbar, navSources } from "../content/menus.ts";
|
|
5
|
+
import { itemLinks } from "../runtime/nav.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Holds the site's brand and navigation, nothing else. The markup is yours:
|
|
9
|
+
*
|
|
10
|
+
* <Navbar nodeId="nav" logoText="Acme" items={[{ label: "About", href: "/about" }]}>
|
|
11
|
+
* {({ logoText, items }) => <nav>…</nav>}
|
|
12
|
+
* </Navbar>
|
|
13
|
+
*
|
|
14
|
+
* An item may have `children` (sub-links, two levels deep at most) and an `image`, for a dropdown or a megamenu:
|
|
15
|
+
* `{ label: "Products", href: "/products", children: [{ label: "Chairs", href: "/chairs", image }] }`. How they
|
|
16
|
+
* are drawn is still up to the markup.
|
|
17
|
+
*
|
|
18
|
+
* `from` builds the sub-links from content: `{ label: "Products", href: "/products", from: "category" }` lists the
|
|
19
|
+
* category items (title, page, first picture), in the owner's order when the type is `ordered`, so a category the
|
|
20
|
+
* owner adds is in the menu at once. The owner can switch a link between written and built sub-links.
|
|
21
|
+
*/
|
|
22
|
+
interface Props {
|
|
23
|
+
nodeId: string;
|
|
24
|
+
logo?: ImageValue;
|
|
25
|
+
logoText?: string;
|
|
26
|
+
items: NavItem[];
|
|
27
|
+
as?: "header" | "nav" | "div";
|
|
28
|
+
[attribute: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { nodeId, logo, logoText, items, as: Tag = "header", ...attributes } = Astro.props;
|
|
32
|
+
const source: NavbarValue = { items, ...(logo && { logo }), ...(logoText !== undefined && { logoText }) };
|
|
33
|
+
const stored = Astro.locals.brim.read("navbar", nodeId, "site") ?? source;
|
|
34
|
+
// The markup gets the sub-links built from content; the editor edits what is saved, `from` and all.
|
|
35
|
+
const navbar = await expandNavbar(stored, itemLinks);
|
|
36
|
+
const content = await Astro.slots.render("default", [navbar]);
|
|
37
|
+
const sources = Astro.locals.brim.editing ? { "data-brim-nav-sources": navSources(config.contentTypes) } : {};
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<Tag {...attributes} {...Astro.locals.brim.marker("navbar", nodeId, "site", stored)} {...sources}>
|
|
41
|
+
<Fragment set:html={content} />
|
|
42
|
+
</Tag>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { defaultScope } from "../runtime/request-state.ts";
|
|
3
|
+
import { type ItemBinding, boundValue } from "../content/item-fields.ts";
|
|
4
|
+
import type { Item } from "../content/items.ts";
|
|
5
|
+
import { renderBlocks } from "../content/rich-text.ts";
|
|
6
|
+
import type { RichTextValue } from "../content/types.ts";
|
|
7
|
+
import type { NodeScope } from "../runtime/context.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Flowing content the owner writes freely: paragraphs, headings and lists.
|
|
11
|
+
* What you put inside is the starting content. With `item` and `field` it shows a rich text field of a content
|
|
12
|
+
* item, what you put inside shows while the field is empty, and writing on the page saves the item.
|
|
13
|
+
*/
|
|
14
|
+
interface Props {
|
|
15
|
+
nodeId: string;
|
|
16
|
+
as?: "div" | "section" | "article";
|
|
17
|
+
scope?: NodeScope;
|
|
18
|
+
item?: Item;
|
|
19
|
+
field?: string;
|
|
20
|
+
[attribute: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { nodeId, as: Tag = "div", scope = defaultScope(), item, field, ...attributes } = Astro.props;
|
|
24
|
+
const binding: ItemBinding | undefined = item && field ? { item, field } : undefined;
|
|
25
|
+
const stored = binding
|
|
26
|
+
? (boundValue(binding) as RichTextValue | undefined)
|
|
27
|
+
: Astro.locals.brim.read("richtext", nodeId, scope);
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
<Tag {...attributes} {...Astro.locals.brim.marker("richtext", nodeId, scope, undefined, binding)}>
|
|
31
|
+
{stored ? <Fragment set:html={renderBlocks(stored.blocks)} /> : <slot />}
|
|
32
|
+
</Tag>
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { sharedImageUrl } from "../runtime/media.ts";
|
|
3
|
+
import config from "virtual:brim/config";
|
|
4
|
+
import routes from "virtual:brim/routes";
|
|
5
|
+
import { faviconType, pageTitleOf, profileAddresses } from "../config.ts";
|
|
6
|
+
import { feedAddresses, feedTitle } from "../content/feed.ts";
|
|
7
|
+
import { normalizePagePath } from "../content/ids.ts";
|
|
8
|
+
import type { ItemAuthor } from "../content/item-head.ts";
|
|
9
|
+
import { connect } from "../runtime/connect.ts";
|
|
10
|
+
import { itemPagePath, pathInLocale, readItemPath, storedLocale } from "../server/locales.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The page's title and the tags search engines and link previews read. Put it in <head>.
|
|
14
|
+
* Props are the starting values; the owner can replace them per page in the editor.
|
|
15
|
+
*/
|
|
16
|
+
interface Props {
|
|
17
|
+
/**
|
|
18
|
+
* The page's own title; the site's `identity.titleTemplate` is applied to it. Without one: the item's title on an
|
|
19
|
+
* item's page, else the site's name.
|
|
20
|
+
*/
|
|
21
|
+
title?: string;
|
|
22
|
+
/** Without one: the item's `description` on an item's page, else the site's. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Image shown when the page is shared. Without one: the item's `image` on an item's page, else the site's. */
|
|
25
|
+
image?: string;
|
|
26
|
+
/** Who wrote the page. On an item's page: the item's author, unless given here. */
|
|
27
|
+
author?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The site's other addresses (social profiles, its maps listing), for search engines: `sameAs={[facebook, instagram]}`
|
|
30
|
+
* from Site Settings. Written on the home page only; empty ones are left out.
|
|
31
|
+
*/
|
|
32
|
+
sameAs?: readonly (string | null | undefined)[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { seo, editing } = Astro.locals.brim;
|
|
36
|
+
// Who the site is, from the integration's `identity`: name, title template, fallbacks, theme color, favicon.
|
|
37
|
+
const identity = config.identity ?? {};
|
|
38
|
+
const favicon = identity.favicon;
|
|
39
|
+
// Each is the owner's choice, then the page's code, then the item's own on an item's page, then the site's.
|
|
40
|
+
const { itemHead } = Astro.locals.brim;
|
|
41
|
+
const own = {
|
|
42
|
+
...Astro.props,
|
|
43
|
+
title: Astro.props.title ?? itemHead?.title,
|
|
44
|
+
description: Astro.props.description ?? itemHead?.description,
|
|
45
|
+
image: Astro.props.image ?? itemHead?.image,
|
|
46
|
+
};
|
|
47
|
+
const title = pageTitleOf(seo.title ?? own.title, identity);
|
|
48
|
+
// The site's own stand in on shared links, but are not about this page: an article's data leaves them out.
|
|
49
|
+
const ownDescription = seo.description ?? own.description;
|
|
50
|
+
const description = ownDescription ?? identity.description;
|
|
51
|
+
const ownImage = seo.image ?? own.image;
|
|
52
|
+
const image = ownImage ?? identity.image;
|
|
53
|
+
const authors = Astro.props.author ? [{ name: Astro.props.author }] : (itemHead?.authors ?? []);
|
|
54
|
+
const author = authors.map(({ name }) => name).join(", ");
|
|
55
|
+
// Shared links can say something else than search results; by default they say the same.
|
|
56
|
+
const shareTitle = seo.shareTitle ?? title;
|
|
57
|
+
const shareDescription = seo.shareDescription ?? description;
|
|
58
|
+
const path = normalizePagePath(Astro.url.pathname);
|
|
59
|
+
// Absolute addresses need `site` in the Astro config; without it these tags are left out.
|
|
60
|
+
const absolute = (address: string): string | undefined =>
|
|
61
|
+
/^https?:\/\//.test(address) ? address : Astro.site ? new URL(address, Astro.site).href : undefined;
|
|
62
|
+
const canonical = absolute(seo.canonical ?? path);
|
|
63
|
+
// A card's worth of the picture where the CDN makes copies, not the photo as it was uploaded.
|
|
64
|
+
const sharedImage = image ? sharedImageUrl(image) : undefined;
|
|
65
|
+
const imageUrl = sharedImage ? (absolute(sharedImage) ?? sharedImage) : undefined;
|
|
66
|
+
// Search engines may show the page's picture large (Google asks to be told).
|
|
67
|
+
const robots = [seo.noindex ? "noindex" : "max-image-preview:large", seo.nofollow && "nofollow"]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.join(", ");
|
|
70
|
+
const alternates = await languageVersions(path);
|
|
71
|
+
// The feeds of the page's language, so browsers and feed readers find them from any page.
|
|
72
|
+
const pageLocale = storedLocale(Astro.currentLocale, config.locales) ?? "";
|
|
73
|
+
const feeds = config.feeds
|
|
74
|
+
? feedAddresses(config.contentTypes, config.locales)
|
|
75
|
+
.filter((feed) => feed.locale === pageLocale)
|
|
76
|
+
.map((feed) => ({
|
|
77
|
+
title: feedTitle(feed.type, identity.name),
|
|
78
|
+
href: absolute(feed.path) ?? feed.path,
|
|
79
|
+
}))
|
|
80
|
+
: [];
|
|
81
|
+
const home = path === "/" || (config.locales?.locales.some((code) => path === `/${code}`) ?? false);
|
|
82
|
+
const sameAs = profileAddresses(Astro.props.sameAs);
|
|
83
|
+
const names = { name: identity.name, ...(identity.alternateName && { alternateName: identity.alternateName }) };
|
|
84
|
+
// What the site is, for search engines' knowledge panels: on the home page only, and only once it has a name.
|
|
85
|
+
const structuredData: Record<string, unknown>[] =
|
|
86
|
+
home && identity.name && Astro.site
|
|
87
|
+
? [
|
|
88
|
+
{
|
|
89
|
+
"@context": "https://schema.org",
|
|
90
|
+
"@type": "WebSite",
|
|
91
|
+
...names,
|
|
92
|
+
url: new URL("/", Astro.site).href,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"@context": "https://schema.org",
|
|
96
|
+
"@type": "Organization",
|
|
97
|
+
...names,
|
|
98
|
+
url: new URL("/", Astro.site).href,
|
|
99
|
+
...(identity.favicon && { logo: absolute(identity.favicon) }),
|
|
100
|
+
...(sameAs.length > 0 && { sameAs }),
|
|
101
|
+
},
|
|
102
|
+
]
|
|
103
|
+
: [];
|
|
104
|
+
|
|
105
|
+
// An article, as search engines read it: only what the item says, so it agrees with what its page shows.
|
|
106
|
+
const article = itemHead?.article;
|
|
107
|
+
if (article && Astro.site) {
|
|
108
|
+
const site = { "@type": "Organization", name: identity.name, url: new URL("/", Astro.site).href };
|
|
109
|
+
const siteNames = [identity.name, ...(identity.alternateName ?? [])];
|
|
110
|
+
structuredData.push({
|
|
111
|
+
"@context": "https://schema.org",
|
|
112
|
+
"@type": "Article",
|
|
113
|
+
headline: itemHead.title,
|
|
114
|
+
...(ownDescription && { description: ownDescription }),
|
|
115
|
+
...(ownImage && imageUrl && { image: [imageUrl] }),
|
|
116
|
+
...(article.published && { datePublished: article.published }),
|
|
117
|
+
...(article.modified && { dateModified: article.modified }),
|
|
118
|
+
...(authors.length > 0 && {
|
|
119
|
+
author: authors.map((writer: ItemAuthor) =>
|
|
120
|
+
siteNames.includes(writer.name)
|
|
121
|
+
? { ...site, name: writer.name }
|
|
122
|
+
: { "@type": "Person", name: writer.name, ...(writer.url && { url: absolute(writer.url) }) },
|
|
123
|
+
),
|
|
124
|
+
}),
|
|
125
|
+
...(identity.name && { publisher: site }),
|
|
126
|
+
...(canonical && { mainEntityOfPage: canonical }),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The page in each of the site's languages, for `hreflang`: the addresses the code has and the published pages
|
|
132
|
+
* added from templates. Left out on a site with one language, or when the page exists in one language only.
|
|
133
|
+
*/
|
|
134
|
+
async function languageVersions(page: string): Promise<{ locale: string; href: string }[]> {
|
|
135
|
+
const locales = config.locales;
|
|
136
|
+
if (!locales || locales.locales.length < 2 || !Astro.site) return [];
|
|
137
|
+
const coded = new Set(routes.pages.map(normalizePagePath));
|
|
138
|
+
const { content, items } = await connect(config.databaseUrl, config.authToken);
|
|
139
|
+
// An item's page: its translations have their own slugs (spring, primavara), so the versions are the published
|
|
140
|
+
// translations of the item, each at its own address.
|
|
141
|
+
const ofItem = readItemPath(config.contentTypes, page, locales);
|
|
142
|
+
if (ofItem) {
|
|
143
|
+
const item = await items.bySlug(ofItem.type.key, ofItem.slug, { publishedOnly: true, locale: ofItem.locale });
|
|
144
|
+
if (item && normalizePagePath(itemPagePath(ofItem.type, item, locales)) === page) {
|
|
145
|
+
const versions = (await items.translations(item))
|
|
146
|
+
.filter((translation) => translation.visibility === "published")
|
|
147
|
+
.map((translation) => ({
|
|
148
|
+
locale: translation.locale || locales.defaultLocale,
|
|
149
|
+
href: new URL(itemPagePath(ofItem.type, translation, locales), Astro.site).href,
|
|
150
|
+
}));
|
|
151
|
+
return versions.length > 1 ? versions : [];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const versions: { locale: string; href: string }[] = [];
|
|
155
|
+
for (const locale of locales.locales) {
|
|
156
|
+
const target = pathInLocale(page, locale, locales);
|
|
157
|
+
const exists =
|
|
158
|
+
coded.has(target) ||
|
|
159
|
+
(await content.page(target).then((record) => record.template !== undefined && record.visibility === "published"));
|
|
160
|
+
if (exists) versions.push({ locale, href: new URL(target, Astro.site).href });
|
|
161
|
+
}
|
|
162
|
+
return versions.length > 1 ? versions : [];
|
|
163
|
+
}
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
<title>{title}</title>
|
|
167
|
+
{favicon && <link rel="icon" href={favicon} type={faviconType(favicon)} />}
|
|
168
|
+
{description && <meta name="description" content={description} />}
|
|
169
|
+
{author && <meta name="author" content={author} />}
|
|
170
|
+
{robots && <meta name="robots" content={robots} />}
|
|
171
|
+
{canonical && <link rel="canonical" href={canonical} />}
|
|
172
|
+
{alternates.map(({ locale, href }) => (
|
|
173
|
+
<link rel="alternate" hreflang={locale} href={href} />
|
|
174
|
+
))}
|
|
175
|
+
{alternates.length > 0 && (
|
|
176
|
+
<link
|
|
177
|
+
rel="alternate"
|
|
178
|
+
hreflang="x-default"
|
|
179
|
+
href={alternates.find(({ locale }) => locale === config.locales?.defaultLocale)?.href ?? alternates[0]?.href}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
182
|
+
{feeds.map(({ title: feedTitle, href }) => (
|
|
183
|
+
<link rel="alternate" type="application/rss+xml" title={feedTitle} href={href} />
|
|
184
|
+
))}
|
|
185
|
+
<meta property="og:title" content={shareTitle} />
|
|
186
|
+
{shareDescription && <meta property="og:description" content={shareDescription} />}
|
|
187
|
+
{canonical && <meta property="og:url" content={canonical} />}
|
|
188
|
+
{imageUrl && <meta property="og:image" content={imageUrl} />}
|
|
189
|
+
<meta property="og:type" content={article ? "article" : "website"} />
|
|
190
|
+
{article?.published && <meta property="article:published_time" content={article.published} />}
|
|
191
|
+
{article?.modified && <meta property="article:modified_time" content={article.modified} />}
|
|
192
|
+
{identity.name && <meta property="og:site_name" content={identity.name} />}
|
|
193
|
+
{identity.themeColor && <meta name="theme-color" content={identity.themeColor} />}
|
|
194
|
+
<meta name="twitter:card" content={imageUrl ? "summary_large_image" : "summary"} />
|
|
195
|
+
<meta name="twitter:title" content={shareTitle} />
|
|
196
|
+
{shareDescription && <meta name="twitter:description" content={shareDescription} />}
|
|
197
|
+
{imageUrl && <meta name="twitter:image" content={imageUrl} />}
|
|
198
|
+
{structuredData.map((data) => (
|
|
199
|
+
<script type="application/ld+json" set:html={JSON.stringify(data).replace(/</g, "\\u003c")} />
|
|
200
|
+
))}
|
|
201
|
+
{/* For the editor only: what the owner set for this page, so its SEO panel can tell it from the page's own values. */}
|
|
202
|
+
{editing && <meta name="brim-seo" content={JSON.stringify({ seo, own })} />}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from "virtual:brim/config";
|
|
3
|
+
import { SITE_SETTINGS_NODE, settingsValues } from "../content/site-settings.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One of the site's own settings, shown on the page: `<Setting name="phone" />`, or the visible text of a link
|
|
7
|
+
* built from it (`<a href={`tel:${phone}`}><Setting name="phone" /></a>`). Clicking it in the editor opens Site
|
|
8
|
+
* Settings at that field, so the owner changes it there, for every page that shows it. Nothing is drawn while the
|
|
9
|
+
* setting is empty, unless the code gives a fallback as its content.
|
|
10
|
+
*/
|
|
11
|
+
interface Props {
|
|
12
|
+
name: string;
|
|
13
|
+
as?: "span" | "p" | "strong" | "em" | "small" | "div";
|
|
14
|
+
[attribute: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { name, as: Tag = "span", ...attributes } = Astro.props;
|
|
18
|
+
const declared = config.siteSettings?.fields.find((field) => field.name === name);
|
|
19
|
+
if (!declared) {
|
|
20
|
+
throw new Error(`<Setting name="${name}">: the site declares no such setting in src/site-settings.ts.`);
|
|
21
|
+
}
|
|
22
|
+
const saved = Astro.locals.brim.read("site-settings" as never, SITE_SETTINGS_NODE, "site");
|
|
23
|
+
const value = settingsValues(config.siteSettings, saved)[name];
|
|
24
|
+
// What a setting reads as: text as it is, a list or key–value rows as one line, a choice by its value.
|
|
25
|
+
const text = Array.isArray(value)
|
|
26
|
+
? value
|
|
27
|
+
.map((entry) => (typeof entry === "object" && entry ? Object.values(entry).join(": ") : String(entry)))
|
|
28
|
+
.join(", ")
|
|
29
|
+
: value === undefined || value === null
|
|
30
|
+
? ""
|
|
31
|
+
: typeof value === "object"
|
|
32
|
+
? ""
|
|
33
|
+
: String(value);
|
|
34
|
+
const editing = Astro.locals.brim.editing;
|
|
35
|
+
const fallback = Astro.slots.has("default") ? await Astro.slots.render("default") : "";
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
{(text || fallback || editing) && (
|
|
39
|
+
<Tag
|
|
40
|
+
{...attributes}
|
|
41
|
+
data-brim-setting={editing ? name : undefined}
|
|
42
|
+
data-brim-setting-label={editing ? declared.label : undefined}
|
|
43
|
+
>
|
|
44
|
+
{text || <Fragment set:html={fallback} />}
|
|
45
|
+
</Tag>
|
|
46
|
+
)}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { withSharedScope } from "../runtime/request-state.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A section whose content is the same on every page that shows it: everything inside (texts, links, images, forms,
|
|
6
|
+
* blocks) is saved once for the whole site, so the owner changes a FAQ, a call to action or the quote form in one
|
|
7
|
+
* place. An element that names its own `scope` keeps it. Use the same node ids on every page: a section that
|
|
8
|
+
* prefixes them with an `id` gets one shared copy per id.
|
|
9
|
+
*
|
|
10
|
+
* <Shared>
|
|
11
|
+
* <FaqSection id="faq" />
|
|
12
|
+
* </Shared>
|
|
13
|
+
*/
|
|
14
|
+
const html = await withSharedScope(() => Astro.slots.render("default"));
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<Fragment set:html={html} />
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { defaultScope } from "../runtime/request-state.ts";
|
|
3
|
+
import "./text.css";
|
|
4
|
+
import config from "virtual:brim/config";
|
|
5
|
+
import { text as textBlock } from "../blocks/schemas/text.ts";
|
|
6
|
+
import { resolveSettings } from "../blocks/settings.ts";
|
|
7
|
+
import { themeColor } from "../blocks/theme.ts";
|
|
8
|
+
import { alignStyle, renderInline } from "../content/rich-text.ts";
|
|
9
|
+
import { type ItemBinding, boundValue } from "../content/item-fields.ts";
|
|
10
|
+
import { textDefaultError } from "../content/text-default.ts";
|
|
11
|
+
import type { Item } from "../content/items.ts";
|
|
12
|
+
import type { TextTag } from "../content/types.ts";
|
|
13
|
+
import type { NodeScope } from "../runtime/context.ts";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* One element of text. The owner can retype it, format it, align it, change the element and style it as a quote.
|
|
17
|
+
* With `item` and `field` it shows a text field of a content item (or its title) and retyping it saves the item.
|
|
18
|
+
*/
|
|
19
|
+
interface Props {
|
|
20
|
+
nodeId: string;
|
|
21
|
+
as?: TextTag;
|
|
22
|
+
scope?: NodeScope;
|
|
23
|
+
item?: Item;
|
|
24
|
+
field?: string;
|
|
25
|
+
[attribute: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { nodeId, as = "p", scope = defaultScope(), style, item, field, ...attributes } = Astro.props;
|
|
29
|
+
const binding: ItemBinding | undefined = item && field ? { item, field } : undefined;
|
|
30
|
+
const saved = Astro.locals.brim.read("text", nodeId, scope);
|
|
31
|
+
// A bound element takes its words from the item; the node keeps only how they are presented.
|
|
32
|
+
const stored = binding && saved ? { ...saved, rich: undefined, text: "" } : saved;
|
|
33
|
+
const boundText = binding ? String(boundValue(binding) ?? "") : undefined;
|
|
34
|
+
const Tag = stored?.as ?? as;
|
|
35
|
+
const options = resolveSettings(textBlock, {}, stored?.options);
|
|
36
|
+
|
|
37
|
+
const quote = options.quotedText ? (options.quoteStyle === "pull" ? "pull" : "classic") : undefined;
|
|
38
|
+
const styles = [
|
|
39
|
+
style,
|
|
40
|
+
alignStyle(stored?.align),
|
|
41
|
+
options.rotation ? `rotate:${Number(options.rotation)}deg` : undefined,
|
|
42
|
+
options.dropCap && options.dropCapColor
|
|
43
|
+
? `--brim-text-drop-cap-color:${themeColor(options.dropCapColor)}`
|
|
44
|
+
: undefined,
|
|
45
|
+
quote ? `--brim-text-quote-color:${themeColor(options.quoteColor)}` : undefined,
|
|
46
|
+
]
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.join(";");
|
|
49
|
+
// The editor needs what the owner chose, to show it and to keep it when the text is retyped.
|
|
50
|
+
const chosen = stored?.as || stored?.options ? { as: stored.as, options: stored.options } : undefined;
|
|
51
|
+
|
|
52
|
+
// While someone can edit, the code's content is checked before the owner's first edit could lose part of it. Content
|
|
53
|
+
// that passes holds only inline formatting and is shown as rendered here; content that fails is drawn by the slot as
|
|
54
|
+
// before, so islands and nested elements in it behave as they always did. The public site never runs the check, so a
|
|
55
|
+
// page that showed before still shows. A bound element is left out: its field holds plain words, whatever the code
|
|
56
|
+
// shows while it is empty.
|
|
57
|
+
const defaultHtml =
|
|
58
|
+
Astro.locals.brim.editing && !binding && !stored && Astro.slots.has("default")
|
|
59
|
+
? await Astro.slots.render("default")
|
|
60
|
+
: undefined;
|
|
61
|
+
const unkept = defaultHtml === undefined ? undefined : textDefaultError(nodeId, defaultHtml);
|
|
62
|
+
// In dev the author is at the code: the error stops the page and says what to change. On the live site a signed-in
|
|
63
|
+
// owner gets the page as the code draws it, and the editor will not let them type into this element.
|
|
64
|
+
if (unkept && config.mode === "dev") throw new Error(unkept);
|
|
65
|
+
if (unkept) console.warn(unkept);
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
<Tag
|
|
69
|
+
{...attributes}
|
|
70
|
+
{...Astro.locals.brim.marker("text", nodeId, scope, chosen, binding)}
|
|
71
|
+
data-brim-text={options.dropCap || quote || options.scaleText ? "" : undefined}
|
|
72
|
+
data-drop-cap={options.dropCap ? "" : undefined}
|
|
73
|
+
data-oversized={options.scaleText ? "" : undefined}
|
|
74
|
+
data-quote={quote}
|
|
75
|
+
data-quote-size={quote === "pull" ? options.pullQuoteSize : undefined}
|
|
76
|
+
data-quote-align={quote === "pull" ? options.pullQuoteAlign : undefined}
|
|
77
|
+
style={styles || undefined}
|
|
78
|
+
data-brim-unkept={unkept ? "" : undefined}
|
|
79
|
+
>
|
|
80
|
+
{binding ? (
|
|
81
|
+
boundText || <slot />
|
|
82
|
+
) : stored?.rich ? (
|
|
83
|
+
<Fragment set:html={renderInline(stored.rich)} />
|
|
84
|
+
) : stored ? (
|
|
85
|
+
stored.text
|
|
86
|
+
) : defaultHtml !== undefined && !unkept ? (
|
|
87
|
+
<Fragment set:html={defaultHtml} />
|
|
88
|
+
) : (
|
|
89
|
+
<slot />
|
|
90
|
+
)}
|
|
91
|
+
</Tag>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The blocks of a `blocks` field: each as wide as the owner chose, on the side chosen when narrower than its place,
|
|
3
|
+
* with the site's rhythm between them. The site says what the widths are (--brim-block-narrow, --brim-block-content,
|
|
4
|
+
* --brim-block-wide) and the rhythm (--brim-block-gap); the owner may tighten or widen the space above a block.
|
|
5
|
+
*/
|
|
6
|
+
/* In the `brim` layer: any CSS of the site wins over it, whatever its selectors. */
|
|
7
|
+
@layer brim {
|
|
8
|
+
.brim-blocks {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--brim-block-gap, 1.5rem);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* The space above a block, in steps of the rhythm: none, half, the rhythm itself, twice it. */
|
|
15
|
+
.brim-block[data-space="none"] {
|
|
16
|
+
margin-top: calc(var(--brim-block-gap, 1.5rem) * -1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.brim-block[data-space="small"] {
|
|
20
|
+
margin-top: calc(var(--brim-block-gap, 1.5rem) * -0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.brim-block[data-space="large"] {
|
|
24
|
+
margin-top: var(--brim-block-gap, 1.5rem);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.brim-block:first-child {
|
|
28
|
+
margin-top: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* The rhythm is the only space between blocks: a text block's first and last paragraphs add none of their own. */
|
|
32
|
+
.brim-block > * > :first-child {
|
|
33
|
+
margin-top: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.brim-block > * > :last-child {
|
|
37
|
+
margin-bottom: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.brim-block {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
width: 100%;
|
|
44
|
+
max-width: var(--brim-block-content, 46rem);
|
|
45
|
+
margin-inline: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.brim-block[data-width="narrow"] {
|
|
49
|
+
max-width: var(--brim-block-narrow, 30rem);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.brim-block[data-width="wide"] {
|
|
53
|
+
max-width: var(--brim-block-wide, 72rem);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.brim-block[data-width="full"] {
|
|
57
|
+
max-width: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.brim-block[data-align="left"] {
|
|
61
|
+
margin-inline: 0 auto;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.brim-block[data-align="right"] {
|
|
65
|
+
margin-inline: auto 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* A picture fills its block; a button sits on the block's side. */
|
|
69
|
+
.brim-block > .brim-image,
|
|
70
|
+
.brim-block > .brim-image .brim-image__frame,
|
|
71
|
+
.brim-block > .brim-image img {
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.brim-block > .brim-btn {
|
|
76
|
+
align-self: center;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.brim-block[data-align="left"] > .brim-btn {
|
|
80
|
+
align-self: flex-start;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.brim-block[data-align="right"] > .brim-btn {
|
|
84
|
+
align-self: flex-end;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { default as Accordion } from "../blocks/accordion/Accordion.astro";
|
|
2
|
+
export { default as Analytics } from "../blocks/analytics/Analytics.astro";
|
|
3
|
+
export { default as Button } from "../blocks/button/Button.astro";
|
|
4
|
+
export { default as Carousel } from "../blocks/carousel/Carousel.astro";
|
|
5
|
+
export { default as Divider } from "../blocks/divider/Divider.astro";
|
|
6
|
+
export { default as Form } from "../blocks/form/Form.astro";
|
|
7
|
+
export { default as Icon } from "../blocks/icon/Icon.astro";
|
|
8
|
+
export { default as Image } from "../blocks/image/Image.astro";
|
|
9
|
+
export { default as ImageGallery } from "../blocks/gallery/ImageGallery.astro";
|
|
10
|
+
export { default as Gallery } from "../blocks/gallery/ImageGallery.astro";
|
|
11
|
+
export { default as Listing } from "../blocks/listing/Listing.astro";
|
|
12
|
+
export { default as Map } from "../blocks/map/Map.astro";
|
|
13
|
+
export { default as Search } from "../blocks/search/Search.astro";
|
|
14
|
+
export { default as Newsletter } from "../blocks/form/Newsletter.astro";
|
|
15
|
+
export { default as SocialMedia } from "../blocks/social/SocialMedia.astro";
|
|
16
|
+
export { default as Video } from "../blocks/video/Video.astro";
|
|
17
|
+
export { default as Blocks } from "./Blocks.astro";
|
|
18
|
+
export { default as Field } from "./Field.astro";
|
|
19
|
+
export { default as Footer } from "./Footer.astro";
|
|
20
|
+
export { default as Link } from "./Link.astro";
|
|
21
|
+
export { default as MobileMenu } from "./MobileMenu.astro";
|
|
22
|
+
export { default as Navbar } from "./Navbar.astro";
|
|
23
|
+
export { default as RichText } from "./RichText.astro";
|
|
24
|
+
export { default as Seo } from "./Seo.astro";
|
|
25
|
+
export { default as Setting } from "./Setting.astro";
|
|
26
|
+
export { default as Shared } from "./Shared.astro";
|
|
27
|
+
export { default as Text } from "./Text.astro";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the browser's popover does not do by itself for a `MobileMenu`: it closes once one of its links is followed
|
|
3
|
+
* (a link to a part of the same page would leave it open over that part), and when the screen grows wide enough
|
|
4
|
+
* for the site to hide its button, which would leave the page unable to scroll with nothing to close.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const OPEN = ".brim-mobile-menu__panel:popover-open";
|
|
8
|
+
|
|
9
|
+
if ("popover" in HTMLElement.prototype) {
|
|
10
|
+
document.addEventListener("click", (event) => {
|
|
11
|
+
if (!(event.target instanceof Element) || !event.target.closest("a[href]")) return;
|
|
12
|
+
event.target.closest<HTMLElement>(OPEN)?.hidePopover();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
window.addEventListener("resize", () => {
|
|
16
|
+
for (const panel of document.querySelectorAll<HTMLElement>(OPEN)) {
|
|
17
|
+
const toggle = panel.parentElement?.querySelector(".brim-mobile-menu__toggle");
|
|
18
|
+
if (toggle?.getClientRects().length === 0) panel.hidePopover();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|