@master/internal-site 0.0.0-stage → 0.1.1
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 +21 -0
- package/README.md +68 -2
- package/dist/astro.d.mts +3 -0
- package/dist/astro.mjs +510 -0
- package/dist/config.d.mts +69 -0
- package/dist/config.mjs +10 -0
- package/package.json +384 -4
- package/src/astro/Page.astro +12 -0
- package/src/astro/content-pages.ts +75 -0
- package/src/astro/index.ts +124 -0
- package/src/astro/module-id.ts +4 -0
- package/src/astro/propagated-assets.ts +29 -0
- package/src/astro/route-paths.ts +78 -0
- package/src/astro/routes.template.ts +110 -0
- package/src/astro/server-styles.ts +26 -0
- package/src/astro/site-context.ts +27 -0
- package/src/astro/source-url.ts +22 -0
- package/src/astro/svelte-renderer.ts +45 -0
- package/src/astro/svg-markup.ts +23 -0
- package/src/benchmarks/BenchmarkBarRows.astro +34 -0
- package/src/benchmarks/BenchmarkBars.astro +14 -0
- package/src/benchmarks/BenchmarkChart.astro +53 -0
- package/src/benchmarks/BenchmarkChartGroup.astro +24 -0
- package/src/benchmarks/BenchmarkDataTable.astro +24 -0
- package/src/benchmarks/BenchmarkDelta.astro +23 -0
- package/src/benchmarks/BenchmarkFigure.astro +30 -0
- package/src/benchmarks/BenchmarkMetricTable.astro +38 -0
- package/src/benchmarks/BenchmarkMetrics.astro +23 -0
- package/src/benchmarks/BenchmarkSampleSummary.astro +30 -0
- package/src/benchmarks/BenchmarkScrollRegion.svelte +27 -0
- package/src/benchmarks/BenchmarkSource.astro +20 -0
- package/src/benchmarks/BenchmarkStackedBars.astro +54 -0
- package/src/benchmarks/BenchmarkStatus.astro +16 -0
- package/src/benchmarks/types.ts +98 -0
- package/src/benchmarks/utils.ts +42 -0
- package/src/blog/BlogAuthors.astro +25 -0
- package/src/blog/article/BlogArticleContents.svelte +24 -0
- package/src/blog/article/BlogArticleEnd.astro +55 -0
- package/src/blog/article/BlogArticleMasthead.astro +61 -0
- package/src/blog/article/language.ts +29 -0
- package/src/blog/article/neighbors.ts +27 -0
- package/src/blog/article/title-lines.astro +14 -0
- package/src/blog/article/title-parts.ts +9 -0
- package/src/components.d.ts +5 -0
- package/src/config.ts +68 -0
- package/src/css/ButtonPreview.astro +22 -0
- package/src/css/ConfiguredExample.astro +15 -0
- package/src/css/NamespaceUtilityTable.astro +50 -0
- package/src/css/StylesheetExample.astro +15 -0
- package/src/css/ThemeNumberVariableTable.astro +57 -0
- package/src/css/configured-example.ts +53 -0
- package/src/css/foundation-data/elevation/shadow-data.ts +52 -0
- package/src/css/foundation-data/sizing/scale-data.ts +37 -0
- package/src/css/foundation-data/specimen-content.ts +10 -0
- package/src/css/foundation-data/specimens.ts +96 -0
- package/src/css/foundation-data/tokens.ts +32 -0
- package/src/css/generate-preset-css.ts +12 -0
- package/src/css/highlight.ts +34 -0
- package/src/css/manifest-utilities.ts +29 -0
- package/src/css/markdown.ts +279 -0
- package/src/css/preset-css.ts +15 -0
- package/src/css/preset-manifest.ts +3 -0
- package/src/css/stylesheet-example.ts +26 -0
- package/src/css/theme-variables.ts +74 -0
- package/src/css/variable-namespace-sources.ts +20 -0
- package/src/demo/Demo.svelte +55 -0
- package/src/demo/DemoAsset.astro +38 -0
- package/src/demo/DemoAxes.svelte +22 -0
- package/src/demo/DemoBadge.svelte +18 -0
- package/src/demo/DemoCatalog.astro +36 -0
- package/src/demo/DemoComparison.svelte +36 -0
- package/src/demo/DemoConfiguredExample.astro +48 -0
- package/src/demo/DemoContainer.svelte +48 -0
- package/src/demo/DemoControls.svelte +16 -0
- package/src/demo/DemoCopyButton.svelte +50 -0
- package/src/demo/DemoCopyGroup.svelte +15 -0
- package/src/demo/DemoExample.astro +27 -0
- package/src/demo/DemoFeatureSupport.svelte +18 -0
- package/src/demo/DemoGeneratedCSS.svelte +8 -0
- package/src/demo/DemoIndex.astro +23 -0
- package/src/demo/DemoInstallation.astro +17 -0
- package/src/demo/DemoItem.svelte +17 -0
- package/src/demo/DemoLabel.svelte +15 -0
- package/src/demo/DemoLegend.svelte +15 -0
- package/src/demo/DemoMeasure.svelte +28 -0
- package/src/demo/DemoMedia.svelte +43 -0
- package/src/demo/DemoMotion.svelte +41 -0
- package/src/demo/DemoPageViewport.astro +17 -0
- package/src/demo/DemoPalette.astro +29 -0
- package/src/demo/DemoPaletteGroups.svelte +15 -0
- package/src/demo/DemoScrollArea.svelte +15 -0
- package/src/demo/DemoStyleComparison.astro +25 -0
- package/src/demo/DemoSurface.svelte +15 -0
- package/src/demo/DemoSwatch.svelte +19 -0
- package/src/demo/DemoThemeComparison.astro +30 -0
- package/src/demo/DemoTokenTable.astro +34 -0
- package/src/demo/DemoViewTransition.astro +18 -0
- package/src/demo/DemoViewport.svelte +324 -0
- package/src/demo/DemoWaterfall.astro +30 -0
- package/src/demo/FoundationBreakpoint.astro +12 -0
- package/src/demo/ProjectStyleExample.astro +13 -0
- package/src/demo/copy-feedback.ts +10 -0
- package/src/demo/demo-waterfall.ts +17 -0
- package/src/demo/drag-readings.ts +20 -0
- package/src/demo/foundations/FoundationAxes.astro +12 -0
- package/src/demo/foundations/FoundationColorRoles.astro +5 -0
- package/src/demo/foundations/FoundationContainerGrid.astro +24 -0
- package/src/demo/foundations/FoundationDialog.astro +14 -0
- package/src/demo/foundations/FoundationElevation.astro +5 -0
- package/src/demo/foundations/FoundationElevationState.astro +5 -0
- package/src/demo/foundations/FoundationHue.astro +5 -0
- package/src/demo/foundations/FoundationLines.astro +5 -0
- package/src/demo/foundations/FoundationMedia.astro +28 -0
- package/src/demo/foundations/FoundationMotion.astro +5 -0
- package/src/demo/foundations/FoundationPalette.astro +8 -0
- package/src/demo/foundations/FoundationRadius.astro +13 -0
- package/src/demo/foundations/FoundationShapes.astro +12 -0
- package/src/demo/foundations/FoundationShrink.astro +14 -0
- package/src/demo/foundations/FoundationSizing.astro +19 -0
- package/src/demo/foundations/FoundationSpecimen.astro +20 -0
- package/src/demo/foundations/FoundationSurfaces.astro +5 -0
- package/src/demo/foundations/FoundationTextHue.astro +5 -0
- package/src/demo/foundations/FoundationTextRoles.astro +5 -0
- package/src/demo/foundations/FoundationTokens.astro +22 -0
- package/src/demo/foundations/FoundationTokensView.astro +65 -0
- package/src/demo/foundations/FoundationTransition.astro +5 -0
- package/src/demo/foundations/FoundationTypeComparison.astro +12 -0
- package/src/demo/foundations/FoundationTypography.astro +5 -0
- package/src/demo/foundations/Palette.svelte +37 -0
- package/src/demo/foundations/ShadowScaleDemo.astro +22 -0
- package/src/demo/illustration-materials.ts +180 -0
- package/src/demo/maintenance-example.ts +62 -0
- package/src/demo/playback.ts +75 -0
- package/src/demo/project-style-examples.ts +128 -0
- package/src/demo/reference/alignment.ts +42 -0
- package/src/demo/reference/animations.ts +30 -0
- package/src/demo/reference/backgrounds.ts +39 -0
- package/src/demo/reference/border-paint.ts +31 -0
- package/src/demo/reference/clipping.ts +26 -0
- package/src/demo/reference/document.ts +55 -0
- package/src/demo/reference/edges.ts +40 -0
- package/src/demo/reference/effects.ts +27 -0
- package/src/demo/reference/flexbox.ts +33 -0
- package/src/demo/reference/frame.css +118 -0
- package/src/demo/reference/grid.ts +42 -0
- package/src/demo/reference/html.ts +40 -0
- package/src/demo/reference/interaction.ts +42 -0
- package/src/demo/reference/layout-html.ts +10 -0
- package/src/demo/reference/layout.ts +102 -0
- package/src/demo/reference/media.ts +29 -0
- package/src/demo/reference/positioning.ts +90 -0
- package/src/demo/reference/scenes.ts +197 -0
- package/src/demo/reference/scrolling.ts +66 -0
- package/src/demo/reference/shapes.ts +22 -0
- package/src/demo/reference/sizing.ts +43 -0
- package/src/demo/reference/source.ts +8 -0
- package/src/demo/reference/text-effects.ts +37 -0
- package/src/demo/reference/text-flow.ts +41 -0
- package/src/demo/reference/transforms.ts +26 -0
- package/src/demo/reference/transitions.ts +24 -0
- package/src/demo/reference/type-specimens.ts +56 -0
- package/src/demo/reference/types.ts +30 -0
- package/src/demo/reference/typography.ts +32 -0
- package/src/demo/specimens/accent-color.json +50 -0
- package/src/demo/specimens/align-items.json +56 -0
- package/src/demo/specimens/animation-delay.json +55 -0
- package/src/demo/specimens/animation-direction.json +49 -0
- package/src/demo/specimens/animation-fill-mode.json +55 -0
- package/src/demo/specimens/animation-iteration-count.json +55 -0
- package/src/demo/specimens/animation-play-state.json +83 -0
- package/src/demo/specimens/animation-timing-function.json +48 -0
- package/src/demo/specimens/appearance.json +44 -0
- package/src/demo/specimens/aspect-ratio.json +28 -0
- package/src/demo/specimens/backdrop-filter.json +44 -0
- package/src/demo/specimens/background-attachment.json +49 -0
- package/src/demo/specimens/background-image.json +25 -0
- package/src/demo/specimens/background-origin.json +36 -0
- package/src/demo/specimens/background-size.json +29 -0
- package/src/demo/specimens/border-collapse.json +45 -0
- package/src/demo/specimens/border-color.json +35 -0
- package/src/demo/specimens/border-image-repeat.json +50 -0
- package/src/demo/specimens/border-image-slice.json +45 -0
- package/src/demo/specimens/border-radius.json +30 -0
- package/src/demo/specimens/box-decoration-break.json +35 -0
- package/src/demo/specimens/box-shadow.json +33 -0
- package/src/demo/specimens/clear.json +77 -0
- package/src/demo/specimens/clip-path.json +38 -0
- package/src/demo/specimens/content.json +27 -0
- package/src/demo/specimens/counter-set.json +31 -0
- package/src/demo/specimens/fill.json +23 -0
- package/src/demo/specimens/filter.json +23 -0
- package/src/demo/specimens/flex-direction.json +27 -0
- package/src/demo/specimens/flex-grow.json +27 -0
- package/src/demo/specimens/font-style.json +23 -0
- package/src/demo/specimens/font-variant-numeric.json +28 -0
- package/src/demo/specimens/grid-auto-columns.json +29 -0
- package/src/demo/specimens/grid-auto-flow.json +37 -0
- package/src/demo/specimens/grid-template-areas.json +34 -0
- package/src/demo/specimens/grid-template-columns.json +36 -0
- package/src/demo/specimens/isolation.json +25 -0
- package/src/demo/specimens/justify-content.json +36 -0
- package/src/demo/specimens/line-height.json +28 -0
- package/src/demo/specimens/list-style-position.json +36 -0
- package/src/demo/specimens/mask-image.json +54 -0
- package/src/demo/specimens/min-width.json +39 -0
- package/src/demo/specimens/mix-blend-mode.json +43 -0
- package/src/demo/specimens/object-fit.json +27 -0
- package/src/demo/specimens/object-position.json +27 -0
- package/src/demo/specimens/opacity.json +37 -0
- package/src/demo/specimens/order.json +28 -0
- package/src/demo/specimens/overflow-wrap.json +26 -0
- package/src/demo/specimens/overflow.json +53 -0
- package/src/demo/specimens/overscroll-behavior.json +29 -0
- package/src/demo/specimens/padding.json +84 -0
- package/src/demo/specimens/place-content.json +31 -0
- package/src/demo/specimens/pointer-events.json +46 -0
- package/src/demo/specimens/position.json +29 -0
- package/src/demo/specimens/resize.json +32 -0
- package/src/demo/specimens/screen-readers.json +37 -0
- package/src/demo/specimens/scroll-padding.json +29 -0
- package/src/demo/specimens/scroll-snap-stop.json +33 -0
- package/src/demo/specimens/shape-image-threshold.json +37 -0
- package/src/demo/specimens/shape-margin.json +40 -0
- package/src/demo/specimens/shape-outside.json +37 -0
- package/src/demo/specimens/stroke-width.json +27 -0
- package/src/demo/specimens/text-fill-color.json +23 -0
- package/src/demo/specimens/text-stroke-width.json +32 -0
- package/src/demo/specimens/touch-action.json +45 -0
- package/src/demo/specimens/transform-box.json +37 -0
- package/src/demo/specimens/transform-origin.json +56 -0
- package/src/demo/specimens/transform-style.json +55 -0
- package/src/demo/specimens/transform.json +47 -0
- package/src/demo/specimens/transition-delay.json +57 -0
- package/src/demo/specimens/transition-duration.json +60 -0
- package/src/demo/specimens/transition-property.json +60 -0
- package/src/demo/specimens/transition-timing-function.json +65 -0
- package/src/demo/specimens/user-drag.json +28 -0
- package/src/demo/specimens/user-select.json +25 -0
- package/src/demo/specimens/vertical-align.json +28 -0
- package/src/demo/specimens/width.json +56 -0
- package/src/demo/specimens/will-change.json +50 -0
- package/src/demo/specimens/writing-mode.json +26 -0
- package/src/demo/specimens/z-index.json +35 -0
- package/src/demo/style.ts +15 -0
- package/src/demo/tone.ts +4 -0
- package/src/demo/useDemoViewTransition.svelte.ts +71 -0
- package/src/docs-shell/common/i18n.config.d.ts +2 -0
- package/src/docs-shell/common/i18n.config.js +13 -0
- package/src/docs-shell/common/svgo.config.d.ts +2 -0
- package/src/docs-shell/common/svgo.config.js +11 -0
- package/src/docs-shell/components/ArticleHeader.astro +65 -0
- package/src/docs-shell/components/ArticleTOC.astro +18 -0
- package/src/docs-shell/components/Callout.astro +26 -0
- package/src/docs-shell/components/Code.astro +25 -0
- package/src/docs-shell/components/CodeCopyButton.astro +25 -0
- package/src/docs-shell/components/CodeTabBar.astro +40 -0
- package/src/docs-shell/components/CodeTabs.astro +53 -0
- package/src/docs-shell/components/CodeView.astro +23 -0
- package/src/docs-shell/components/Do.astro +5 -0
- package/src/docs-shell/components/DoNot.astro +5 -0
- package/src/docs-shell/components/DocArticle.astro +14 -0
- package/src/docs-shell/components/DocHeader.svelte +93 -0
- package/src/docs-shell/components/DocHeading.astro +28 -0
- package/src/docs-shell/components/DocMain.astro +19 -0
- package/src/docs-shell/components/DocMenuButton.svelte +96 -0
- package/src/docs-shell/components/DocSidebar.svelte +62 -0
- package/src/docs-shell/components/DocVersionSelect.svelte +22 -0
- package/src/docs-shell/components/DocWrapper.astro +11 -0
- package/src/docs-shell/components/DocumentAPIIndex.astro +24 -0
- package/src/docs-shell/components/DocumentChoices.astro +24 -0
- package/src/docs-shell/components/DocumentCodeExample.astro +20 -0
- package/src/docs-shell/components/DocumentCodeExampleView.astro +35 -0
- package/src/docs-shell/components/DocumentCodeTable.astro +19 -0
- package/src/docs-shell/components/DocumentComparison.astro +7 -0
- package/src/docs-shell/components/DocumentCopyButton.svelte +41 -0
- package/src/docs-shell/components/DocumentDeclaration.astro +17 -0
- package/src/docs-shell/components/DocumentDeclarationView.astro +12 -0
- package/src/docs-shell/components/DocumentDisclosure.astro +14 -0
- package/src/docs-shell/components/DocumentFileTree.astro +34 -0
- package/src/docs-shell/components/DocumentFlow.astro +27 -0
- package/src/docs-shell/components/DocumentIdentifier.astro +14 -0
- package/src/docs-shell/components/DocumentIllustration.astro +46 -0
- package/src/docs-shell/components/DocumentKeyList.astro +22 -0
- package/src/docs-shell/components/DocumentNamespaceTable.astro +20 -0
- package/src/docs-shell/components/DocumentOptionEntry.astro +15 -0
- package/src/docs-shell/components/DocumentOptionList.astro +11 -0
- package/src/docs-shell/components/DocumentOptions.astro +23 -0
- package/src/docs-shell/components/DocumentParameters.astro +30 -0
- package/src/docs-shell/components/DocumentPrompt.astro +16 -0
- package/src/docs-shell/components/DocumentValueList.astro +25 -0
- package/src/docs-shell/components/DocumentationIndex.svelte +144 -0
- package/src/docs-shell/components/Dropped.astro +21 -0
- package/src/docs-shell/components/ExpandContent.svelte +21 -0
- package/src/docs-shell/components/ExplorerView.astro +37 -0
- package/src/docs-shell/components/FileIcon.astro +123 -0
- package/src/docs-shell/components/Footer.svelte +80 -0
- package/src/docs-shell/components/GeneratedCSS.astro +8 -0
- package/src/docs-shell/components/Header.svelte +121 -0
- package/src/docs-shell/components/HeaderIcon.astro +14 -0
- package/src/docs-shell/components/HeaderNav.svelte +20 -0
- package/src/docs-shell/components/Image.svelte +56 -0
- package/src/docs-shell/components/Info.astro +5 -0
- package/src/docs-shell/components/InlineCode.astro +30 -0
- package/src/docs-shell/components/InteractingIndicator.astro +19 -0
- package/src/docs-shell/components/LanguageButton.svelte +18 -0
- package/src/docs-shell/components/LanguageSelect.svelte +44 -0
- package/src/docs-shell/components/Link.svelte +127 -0
- package/src/docs-shell/components/ModeImg.astro +11 -0
- package/src/docs-shell/components/NotFound.astro +21 -0
- package/src/docs-shell/components/OverviewButtons.astro +36 -0
- package/src/docs-shell/components/PMAction.astro +25 -0
- package/src/docs-shell/components/PackageBadges.astro +39 -0
- package/src/docs-shell/components/PageContent.svelte +38 -0
- package/src/docs-shell/components/PageContentBootstrap.astro +13 -0
- package/src/docs-shell/components/PageContentDisclosure.astro +25 -0
- package/src/docs-shell/components/PageContentList.svelte +70 -0
- package/src/docs-shell/components/PageContentProvider.svelte +15 -0
- package/src/docs-shell/components/PageContentTitle.svelte +16 -0
- package/src/docs-shell/components/PageNavs.astro +40 -0
- package/src/docs-shell/components/PreparedCodeView.astro +12 -0
- package/src/docs-shell/components/RenderNode.astro +16 -0
- package/src/docs-shell/components/RouteLayers.astro +17 -0
- package/src/docs-shell/components/SearchButton.svelte +31 -0
- package/src/docs-shell/components/SearchDialog.svelte +174 -0
- package/src/docs-shell/components/Segments.svelte +62 -0
- package/src/docs-shell/components/Step.astro +13 -0
- package/src/docs-shell/components/StepL.astro +10 -0
- package/src/docs-shell/components/StepR.astro +10 -0
- package/src/docs-shell/components/StepSection.astro +12 -0
- package/src/docs-shell/components/Tab.astro +8 -0
- package/src/docs-shell/components/Tabs.astro +10 -0
- package/src/docs-shell/components/ThemeIcon.astro +19 -0
- package/src/docs-shell/components/ThemeSelect.svelte +20 -0
- package/src/docs-shell/components/TimeAgo.svelte +32 -0
- package/src/docs-shell/components/Translate.astro +14 -0
- package/src/docs-shell/components/Warn.astro +5 -0
- package/src/docs-shell/components/code-props.ts +28 -0
- package/src/docs-shell/components/document-types.ts +119 -0
- package/src/docs-shell/components/markdown/Anchor.astro +5 -0
- package/src/docs-shell/components/markdown/Heading2.astro +5 -0
- package/src/docs-shell/components/markdown/Heading3.astro +5 -0
- package/src/docs-shell/components/markdown/Table.astro +6 -0
- package/src/docs-shell/components/markdown-components.ts +36 -0
- package/src/docs-shell/components/page-content-bootstrap.ts +115 -0
- package/src/docs-shell/components/page-content.svelte.ts +125 -0
- package/src/docs-shell/contexts/search.ts +18 -0
- package/src/docs-shell/contexts/theme-mode.svelte.ts +61 -0
- package/src/docs-shell/data/authors.ts +17 -0
- package/src/docs-shell/data/base-colors.ts +29 -0
- package/src/docs-shell/data/brands.ts +79 -0
- package/src/docs-shell/data/color-names.ts +1 -0
- package/src/docs-shell/data/color-palette.ts +50 -0
- package/src/docs-shell/data/colors.ts +1 -0
- package/src/docs-shell/factories/Page.astro +35 -0
- package/src/docs-shell/factories/create-page.ts +31 -0
- package/src/docs-shell/layouts/BlogArticle.astro +53 -0
- package/src/docs-shell/layouts/Doc.astro +41 -0
- package/src/docs-shell/remark/markdown-components.d.ts +2 -0
- package/src/docs-shell/remark/markdown-components.js +101 -0
- package/src/docs-shell/remark/slug-and-toc.d.ts +2 -0
- package/src/docs-shell/remark/slug-and-toc.js +53 -0
- package/src/docs-shell/scripts/code-tabs-bootstrap.ts +34 -0
- package/src/docs-shell/scripts/code.ts +124 -0
- package/src/docs-shell/scripts/document-anchor.ts +57 -0
- package/src/docs-shell/scripts/document.ts +47 -0
- package/src/docs-shell/site.ts +67 -0
- package/src/docs-shell/types/IllustrationImages.ts +2 -0
- package/src/docs-shell/types/Metadata.ts +17 -0
- package/src/docs-shell/types/Props.ts +9 -0
- package/src/docs-shell/types/StaticImage.ts +6 -0
- package/src/docs-shell/uses/use-selected-preview-syntax.svelte.ts +16 -0
- package/src/docs-shell/utils/anchor.ts +24 -0
- package/src/docs-shell/utils/beautify-css.ts +14 -0
- package/src/docs-shell/utils/beautify-html.ts +12 -0
- package/src/docs-shell/utils/beautify-js.ts +9 -0
- package/src/docs-shell/utils/create-highlighter.ts +50 -0
- package/src/docs-shell/utils/css-modern-grammar.ts +339 -0
- package/src/docs-shell/utils/documentation-search.ts +68 -0
- package/src/docs-shell/utils/generate-metadata.ts +60 -0
- package/src/docs-shell/utils/group-page-content.ts +10 -0
- package/src/docs-shell/utils/head.ts +72 -0
- package/src/docs-shell/utils/highlight-code-core.ts +146 -0
- package/src/docs-shell/utils/highlight-code.ts +1 -0
- package/src/docs-shell/utils/highlighted-code-text.ts +27 -0
- package/src/docs-shell/utils/i18n-pathname.ts +98 -0
- package/src/docs-shell/utils/i18n.ts +12 -0
- package/src/docs-shell/utils/is-date-within-seven-days.ts +16 -0
- package/src/docs-shell/utils/isBrowser.ts +1 -0
- package/src/docs-shell/utils/isInteractOutside.ts +16 -0
- package/src/docs-shell/utils/markdown-tree.ts +22 -0
- package/src/docs-shell/utils/metadata.ts +25 -0
- package/src/docs-shell/utils/prepared-code.ts +21 -0
- package/src/docs-shell/utils/resolve-heading.d.ts +1 -0
- package/src/docs-shell/utils/resolve-heading.js +19 -0
- package/src/docs-shell/utils/search-pages.ts +271 -0
- package/src/docs-shell/utils/slot-text.ts +15 -0
- package/src/docs-shell/utils/snackbar.ts +39 -0
- package/src/docs-shell/utils/syntax-theme.ts +53 -0
- package/src/docs-shell/utils/transformer-notation-word-mark.ts +146 -0
- package/src/docs-shell/utils/unique-id.ts +11 -0
- package/src/examples/article-transitions/page.astro +7 -0
- package/src/examples/article-transitions/transitions.css +10 -0
- package/src/examples/components/ArticleTransitionScene.svelte +83 -0
- package/src/examples/components/ViewTransitionScene.svelte +31 -0
- package/src/examples/images/article-aurora.jpg +0 -0
- package/src/examples/images/article-coast.jpg +0 -0
- package/src/examples/images/article-grid.jpg +0 -0
- package/src/examples/images/article-studio.jpg +0 -0
- package/src/examples/layout-system/page.astro +59 -0
- package/src/examples/scene.css +3 -0
- package/src/examples/view-transitions/page.astro +7 -0
- package/src/examples/view-transitions/transitions.css +9 -0
- package/src/home/HeroCanvas.svelte +617 -0
- package/src/home/HomeAction.astro +17 -0
- package/src/home/HomeBentoFrame.astro +9 -0
- package/src/home/HomeBentoGrid.astro +9 -0
- package/src/home/HomeCompactIcon.astro +15 -0
- package/src/home/HomeFooter.svelte +63 -0
- package/src/home/HomeIllustration.astro +17 -0
- package/src/home/HomeIllustrationArt.svelte +15 -0
- package/src/home/HomeLamp.svelte +18 -0
- package/src/home/design.css +532 -0
- package/src/home/footer.css +225 -0
- package/src/home/hero-shaders.ts +460 -0
- package/src/home/hero-title-mask.ts +175 -0
- package/src/home/hero.css +547 -0
- package/src/home/home-illustration.ts +5 -0
- package/src/home/home-lamp.ts +225 -0
- package/src/home/home.css +1081 -0
- package/src/home/icons/agent-check-preview-apply.svg +24 -0
- package/src/home/icons/agent-clients.svg +26 -0
- package/src/home/icons/agent-project-tools.svg +23 -0
- package/src/home/icons/artwork/agent-check-preview-apply-dark.webp +0 -0
- package/src/home/icons/artwork/agent-check-preview-apply-light.webp +0 -0
- package/src/home/icons/artwork/agent-clients-dark.webp +0 -0
- package/src/home/icons/artwork/agent-clients-light.webp +0 -0
- package/src/home/icons/artwork/agent-edit-file-dark.webp +0 -0
- package/src/home/icons/artwork/agent-edit-file-light.webp +0 -0
- package/src/home/icons/artwork/agent-project-tools-dark.webp +0 -0
- package/src/home/icons/artwork/agent-project-tools-light.webp +0 -0
- package/src/home/icons/artwork/design-cascade-layers-dark.webp +0 -0
- package/src/home/icons/artwork/design-cascade-layers-light.webp +0 -0
- package/src/home/icons/artwork/design-layout-motion-dark.webp +0 -0
- package/src/home/icons/artwork/design-layout-motion-light.webp +0 -0
- package/src/home/icons/artwork/design-p3-gamut-dark.webp +0 -0
- package/src/home/icons/artwork/design-p3-gamut-light.webp +0 -0
- package/src/home/icons/artwork/design-theme-modes-dark.webp +0 -0
- package/src/home/icons/artwork/design-theme-modes-light.webp +0 -0
- package/src/home/icons/artwork/design-theme-tokens-dark.webp +0 -0
- package/src/home/icons/artwork/design-theme-tokens-light.webp +0 -0
- package/src/home/icons/artwork/editor-color-tools-dark.webp +0 -0
- package/src/home/icons/artwork/editor-color-tools-light.webp +0 -0
- package/src/home/icons/artwork/editor-focused-highlighting-dark.webp +0 -0
- package/src/home/icons/artwork/editor-focused-highlighting-light.webp +0 -0
- package/src/home/icons/artwork/editor-hover-inspection-dark.webp +0 -0
- package/src/home/icons/artwork/editor-hover-inspection-light.webp +0 -0
- package/src/home/icons/artwork/editor-manifest-completions-dark.webp +0 -0
- package/src/home/icons/artwork/editor-manifest-completions-light.webp +0 -0
- package/src/home/icons/artwork/lint-class-order-dark.webp +0 -0
- package/src/home/icons/artwork/lint-class-order-light.webp +0 -0
- package/src/home/icons/artwork/lint-conflicting-classes-dark.webp +0 -0
- package/src/home/icons/artwork/lint-conflicting-classes-light.webp +0 -0
- package/src/home/icons/artwork/lint-fix-previews-dark.webp +0 -0
- package/src/home/icons/artwork/lint-fix-previews-light.webp +0 -0
- package/src/home/icons/artwork/lint-invalid-classes-dark.webp +0 -0
- package/src/home/icons/artwork/lint-invalid-classes-light.webp +0 -0
- package/src/home/icons/artwork/lint-strict-vocabulary-dark.webp +0 -0
- package/src/home/icons/artwork/lint-strict-vocabulary-light.webp +0 -0
- package/src/home/icons/artwork/lint-theme-tokens-dark.webp +0 -0
- package/src/home/icons/artwork/lint-theme-tokens-light.webp +0 -0
- package/src/home/icons/artwork/mcp-apply-preview-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-apply-preview-light.webp +0 -0
- package/src/home/icons/artwork/mcp-css-compare-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-css-compare-light.webp +0 -0
- package/src/home/icons/artwork/mcp-inspect-class-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-inspect-class-light.webp +0 -0
- package/src/home/icons/artwork/mcp-lint-project-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-lint-project-light.webp +0 -0
- package/src/home/icons/artwork/mcp-manifest-query-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-manifest-query-light.webp +0 -0
- package/src/home/icons/artwork/mcp-preview-fixes-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-preview-fixes-light.webp +0 -0
- package/src/home/icons/artwork/mcp-render-css-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-render-css-light.webp +0 -0
- package/src/home/icons/artwork/mcp-scan-project-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-scan-project-light.webp +0 -0
- package/src/home/icons/artwork/mcp-trace-class-dark.webp +0 -0
- package/src/home/icons/artwork/mcp-trace-class-light.webp +0 -0
- package/src/home/icons/artwork/render-progressive-dark.webp +0 -0
- package/src/home/icons/artwork/render-progressive-light.webp +0 -0
- package/src/home/icons/artwork/render-runtime-dark.webp +0 -0
- package/src/home/icons/artwork/render-runtime-light.webp +0 -0
- package/src/home/icons/artwork/render-static-dark.webp +0 -0
- package/src/home/icons/artwork/render-static-light.webp +0 -0
- package/src/home/icons/artwork/section-ai-agents-dark.webp +0 -0
- package/src/home/icons/artwork/section-ai-agents-light.webp +0 -0
- package/src/home/icons/artwork/section-css-size-dark.webp +0 -0
- package/src/home/icons/artwork/section-css-size-light.webp +0 -0
- package/src/home/icons/artwork/section-design-system-dark.webp +0 -0
- package/src/home/icons/artwork/section-design-system-light.webp +0 -0
- package/src/home/icons/artwork/section-editor-dark.webp +0 -0
- package/src/home/icons/artwork/section-editor-light.webp +0 -0
- package/src/home/icons/artwork/section-lint-dark.webp +0 -0
- package/src/home/icons/artwork/section-lint-light.webp +0 -0
- package/src/home/icons/artwork/section-rendering-dark.webp +0 -0
- package/src/home/icons/artwork/section-rendering-light.webp +0 -0
- package/src/home/icons/artwork/section-workflow-dark.webp +0 -0
- package/src/home/icons/artwork/section-workflow-light.webp +0 -0
- package/src/home/icons/artwork/source.json +303 -0
- package/src/home/icons/artwork/workflow-integrations-dark.webp +0 -0
- package/src/home/icons/artwork/workflow-integrations-light.webp +0 -0
- package/src/home/icons/artwork/workflow-monorepo-dark.webp +0 -0
- package/src/home/icons/artwork/workflow-monorepo-light.webp +0 -0
- package/src/home/icons/artwork/workflow-route-styles-dark.webp +0 -0
- package/src/home/icons/artwork/workflow-route-styles-light.webp +0 -0
- package/src/home/icons/artwork/workflow-trace-change-dark.webp +0 -0
- package/src/home/icons/artwork/workflow-trace-change-light.webp +0 -0
- package/src/home/icons/artwork.css +4 -0
- package/src/home/icons/artwork.ts +131 -0
- package/src/home/icons/catalog.ts +381 -0
- package/src/home/icons/design-cascade-layers.svg +32 -0
- package/src/home/icons/design-layout-motion.svg +16 -0
- package/src/home/icons/design-p3-gamut.svg +12 -0
- package/src/home/icons/design-theme-modes.svg +12 -0
- package/src/home/icons/design-theme-tokens.svg +20 -0
- package/src/home/icons/editor-color-tools.svg +18 -0
- package/src/home/icons/editor-focused-highlighting.svg +15 -0
- package/src/home/icons/editor-hover-inspection.svg +19 -0
- package/src/home/icons/editor-manifest-completions.svg +24 -0
- package/src/home/icons/lint-class-order-compact.svg +15 -0
- package/src/home/icons/lint-class-order.svg +28 -0
- package/src/home/icons/lint-conflicting-classes-compact.svg +11 -0
- package/src/home/icons/lint-conflicting-classes.svg +24 -0
- package/src/home/icons/lint-fix-previews-compact.svg +9 -0
- package/src/home/icons/lint-fix-previews.svg +19 -0
- package/src/home/icons/lint-invalid-classes-compact.svg +7 -0
- package/src/home/icons/lint-invalid-classes.svg +17 -0
- package/src/home/icons/lint-strict-vocabulary-compact.svg +8 -0
- package/src/home/icons/lint-strict-vocabulary.svg +16 -0
- package/src/home/icons/lint-theme-tokens-compact.svg +7 -0
- package/src/home/icons/lint-theme-tokens.svg +14 -0
- package/src/home/icons/mcp-apply-preview-compact.svg +9 -0
- package/src/home/icons/mcp-apply-preview.svg +18 -0
- package/src/home/icons/mcp-css-compare-compact.svg +9 -0
- package/src/home/icons/mcp-css-compare.svg +20 -0
- package/src/home/icons/mcp-inspect-class-compact.svg +9 -0
- package/src/home/icons/mcp-inspect-class.svg +18 -0
- package/src/home/icons/mcp-lint-project-compact.svg +14 -0
- package/src/home/icons/mcp-lint-project.svg +30 -0
- package/src/home/icons/mcp-manifest-query-compact.svg +14 -0
- package/src/home/icons/mcp-manifest-query.svg +27 -0
- package/src/home/icons/mcp-preview-fixes-compact.svg +9 -0
- package/src/home/icons/mcp-preview-fixes.svg +15 -0
- package/src/home/icons/mcp-render-css-compact.svg +13 -0
- package/src/home/icons/mcp-render-css.svg +30 -0
- package/src/home/icons/mcp-scan-project-compact.svg +7 -0
- package/src/home/icons/mcp-scan-project.svg +13 -0
- package/src/home/icons/mcp-trace-class-compact.svg +11 -0
- package/src/home/icons/mcp-trace-class.svg +24 -0
- package/src/home/icons/render-progressive.svg +17 -0
- package/src/home/icons/render-runtime.svg +23 -0
- package/src/home/icons/render-static.svg +29 -0
- package/src/home/icons/section-ai-agents.svg +24 -0
- package/src/home/icons/section-css-size.svg +13 -0
- package/src/home/icons/section-design-system.svg +24 -0
- package/src/home/icons/section-editor.svg +14 -0
- package/src/home/icons/section-lint.svg +14 -0
- package/src/home/icons/section-rendering.svg +30 -0
- package/src/home/icons/section-workflow.svg +22 -0
- package/src/home/icons/workflow-integrations.svg +15 -0
- package/src/home/icons/workflow-monorepo.svg +27 -0
- package/src/home/icons/workflow-route-styles.svg +24 -0
- package/src/home/icons/workflow-trace-change.svg +21 -0
- package/src/layouts/Document.astro +71 -0
- package/src/public/brand/v2/logo/mark/master-mark-small-on-dark.svg +1 -0
- package/src/public/brand/v2/logo/master-css/master-css-horizontal-on-dark.svg +1 -0
- package/src/public/brand/v2/logo/master-css/master-css-horizontal-on-light.svg +1 -0
- package/src/public/demo/border-grid.svg +7 -0
- package/src/public/demo/landscape.svg +1 -0
- package/src/public/demo/marker.svg +1 -0
- package/src/public/demo/mask.svg +1 -0
- package/src/public/fonts/Geist-Medium.ttf +0 -0
- package/src/public/fonts/Geist-Regular.ttf +0 -0
- package/src/public/fonts/GeistVariable.woff2 +0 -0
- package/src/public/fonts/IBMPlexMono-Bold.woff2 +0 -0
- package/src/public/fonts/IBMPlexMono-Medium.woff2 +0 -0
- package/src/public/fonts/IBMPlexMono-Regular.woff2 +0 -0
- package/src/public/fonts/IBMPlexMono-SemiBold.woff2 +0 -0
- package/src/public/fonts/index.css +40 -0
- package/src/public/icons/csharp.svg +1 -0
- package/src/public/icons/css.svg +1 -0
- package/src/public/icons/eslint.svg +1 -0
- package/src/public/icons/folder.svg +12 -0
- package/src/public/icons/html.svg +1 -0
- package/src/public/icons/php.svg +1 -0
- package/src/public/icons/sass.svg +1 -0
- package/src/public/icons/storybook.svg +1 -0
- package/src/public/icons/visualstudiocode.svg +41 -0
- package/src/public/images/authors/aron.jpg +0 -0
- package/src/public/images/authors/benseage.jpg +0 -0
- package/src/public/images/authors/joy.jpg +0 -0
- package/src/public/images/authors/lola.jpg +0 -0
- package/src/public/images/authors/miles.jpg +0 -0
- package/src/public/images/bootstrap.svg +23 -0
- package/src/public/images/build-tools/rsbuild.svg +1 -0
- package/src/public/images/build-tools/rspack.svg +1 -0
- package/src/public/images/build-tools/vite.svg +15 -0
- package/src/public/images/build-tools/webpack.svg +10 -0
- package/src/public/images/cdns/esm-sh.svg +1 -0
- package/src/public/images/chevron-left.svg +4 -0
- package/src/public/images/cover-bg.jpg +0 -0
- package/src/public/images/emotion.svg +1 -0
- package/src/public/images/frameworks/angular.svg +29 -0
- package/src/public/images/frameworks/astro.svg +4 -0
- package/src/public/images/frameworks/blazor.svg +22 -0
- package/src/public/images/frameworks/express.svg +1 -0
- package/src/public/images/frameworks/laravel.svg +8 -0
- package/src/public/images/frameworks/line-liff.svg +1 -0
- package/src/public/images/frameworks/lit.svg +1 -0
- package/src/public/images/frameworks/nextjs.svg +16 -0
- package/src/public/images/frameworks/nuxtjs.svg +3 -0
- package/src/public/images/frameworks/rails.svg +1 -0
- package/src/public/images/frameworks/react.svg +8 -0
- package/src/public/images/frameworks/remix.svg +5 -0
- package/src/public/images/frameworks/shopify.svg +1 -0
- package/src/public/images/frameworks/svelte.svg +6 -0
- package/src/public/images/frameworks/tanstack.svg +1 -0
- package/src/public/images/frameworks/vuejs.svg +11 -0
- package/src/public/images/frameworks/wordpress.svg +1 -0
- package/src/public/images/mui.svg +1 -0
- package/src/public/images/styled-components.svg +4 -0
- package/src/public/images/tailwindcss.svg +1 -0
- package/src/scripts/bundler-imports.ts +25 -0
- package/src/scripts/static-social.ts +333 -0
- package/src/scripts/write-if-changed.ts +26 -0
- package/src/sections/blog.astro +11 -0
- package/src/sections/design-system.astro +14 -0
- package/src/sections/document.astro +8 -0
- package/src/sections/examples.astro +6 -0
- package/src/sections/guide.astro +26 -0
- package/src/sections/home.astro +7 -0
- package/src/sections/page.astro +12 -0
- package/src/styles/base.css +57 -0
- package/src/styles/benchmarks.css +20 -0
- package/src/styles/blog-article.css +670 -0
- package/src/styles/blog-materials.css +399 -0
- package/src/styles/blog.css +568 -0
- package/src/styles/demo.css +30 -0
- package/src/styles/design-system.css +15 -0
- package/src/styles/docs-shell/code.css +61 -0
- package/src/styles/docs-shell/docs.css +79 -0
- package/src/styles/docs-shell/documentation-search.css +42 -0
- package/src/styles/docs-shell/footer.css +38 -0
- package/src/styles/docs-shell/header.css +73 -0
- package/src/styles/docs-shell/materials.css +25 -0
- package/src/styles/docs-shell/menu.css +19 -0
- package/src/styles/docs-shell/not-found.css +10 -0
- package/src/styles/docs-shell/page-content.css +37 -0
- package/src/styles/docs-shell/prose.css +89 -0
- package/src/styles/docs-shell/segments.css +13 -0
- package/src/styles/docs-shell/steps.css +39 -0
- package/src/styles/docs-shell/syntax-theme.css +18 -0
- package/src/styles/docs-shell/theme.css +68 -0
- package/src/styles/docs-shell/wrapper.css +10 -0
- package/src/styles/document-comparison.css +7 -0
- package/src/styles/documentation-illustration.css +34 -0
- package/src/styles/documentation-index.css +100 -0
- package/src/styles/documents.css +4 -0
- package/src/styles/documents.ts +2 -0
- package/src/styles/foundation.css +4 -0
- package/src/styles/globals.css +2 -0
- package/src/styles/interface.css +3 -0
- package/src/styles/interface.ts +2 -0
- package/src/styles/site.ts +2 -0
- package/src/styles/system/DESIGN.md +108 -0
- package/src/styles/system/buttons.css +51 -0
- package/src/styles/system/code.css +85 -0
- package/src/styles/system/controls.css +110 -0
- package/src/styles/system/data.css +134 -0
- package/src/styles/system/mixins.css +7 -0
- package/src/styles/system/prose.css +75 -0
- package/src/styles/system/shell.css +102 -0
- package/src/styles/system/specimens.css +98 -0
- package/src/styles/system/surfaces.css +104 -0
- package/src/styles/system/tokens.css +136 -0
- package/src/utils/cloudflare-image-loader.js +85 -0
- package/src/virtual.d.ts +36 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import type { LanguageRegistration } from 'shiki/core'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Presentation-only additions to Shiki's CSS grammar for syntax the docs use but the bundled grammar predates:
|
|
5
|
+
* nested rules and conditional groups inside declaration blocks, descriptor at-rules, container and scope
|
|
6
|
+
* preludes, functions, properties or query features newer than its keyword lists, and CSS-in-JS templates.
|
|
7
|
+
* Master CSS directives keep their own grammar.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type Pattern = Record<string, unknown>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Root grammars whose documents contain CSS. Shiki injects by root scope prefix, so a stylesheet embedded in
|
|
14
|
+
* HTML, Vue, Svelte, Astro, MDX, a Markdown fence or a CSS-in-JS template needs its host listed; selectors still
|
|
15
|
+
* require CSS scopes.
|
|
16
|
+
*/
|
|
17
|
+
export const cssInjectionHosts = ['source.css', 'text.html', 'source.svelte', 'source.astro', 'source.mdx', 'source.js', 'source.ts', 'source.tsx']
|
|
18
|
+
|
|
19
|
+
const scopePrelude: Pattern[] = [
|
|
20
|
+
{ match: '(?i)(?<=\\))\\s*(to)(?=\\s*\\()', captures: { 1: { name: 'keyword.operator.logical.to.css' } } },
|
|
21
|
+
{
|
|
22
|
+
begin: '\\(',
|
|
23
|
+
beginCaptures: { 0: { name: 'punctuation.definition.parameters.begin.bracket.round.css' } },
|
|
24
|
+
end: '\\)',
|
|
25
|
+
endCaptures: { 0: { name: 'punctuation.definition.parameters.end.bracket.round.css' } },
|
|
26
|
+
name: 'meta.selector.css',
|
|
27
|
+
patterns: [{ include: 'source.css#selector-innards' }]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
const preludes: Record<string, Pattern[]> = {
|
|
32
|
+
media: [{ include: 'source.css#media-query-list' }],
|
|
33
|
+
container: [{ include: 'source.css#media-query-list' }],
|
|
34
|
+
supports: [{ include: 'source.css#feature-query-operators' }, { include: 'source.css#feature-query' }],
|
|
35
|
+
scope: scopePrelude,
|
|
36
|
+
layer: [{ include: 'source.css#comment-block' }, { include: 'source.css#commas' }],
|
|
37
|
+
'starting-style': [{ include: 'source.css#comment-block' }]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** `@name prelude { body }` or `@name prelude;`, with the prelude in `meta.at-rule.<name>.header.css`. */
|
|
41
|
+
function atRule(name: string, prelude: Pattern[], body: Pattern): Pattern {
|
|
42
|
+
return {
|
|
43
|
+
begin: `(?i)((@)${name})(?![\\w-])`,
|
|
44
|
+
beginCaptures: {
|
|
45
|
+
1: { name: `keyword.control.at-rule.${name}.css` },
|
|
46
|
+
2: { name: 'punctuation.definition.keyword.css' }
|
|
47
|
+
},
|
|
48
|
+
end: '(?<=[};])(?!\\G)',
|
|
49
|
+
patterns: [
|
|
50
|
+
{ begin: '\\G(?!\\s*[;{])', end: '(?=\\s*[;{])', name: `meta.at-rule.${name}.header.css`, patterns: prelude },
|
|
51
|
+
{ match: ';', name: 'punctuation.terminator.rule.css' },
|
|
52
|
+
body
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function block(patterns: Pattern[]): Pattern {
|
|
58
|
+
return {
|
|
59
|
+
begin: '\\{',
|
|
60
|
+
beginCaptures: { 0: { name: 'punctuation.section.begin.bracket.curly.css' } },
|
|
61
|
+
end: '\\}',
|
|
62
|
+
endCaptures: { 0: { name: 'punctuation.section.end.bracket.curly.css' } },
|
|
63
|
+
name: 'meta.at-rule.body.css',
|
|
64
|
+
patterns
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const selectorInnards: Pattern[] = [
|
|
69
|
+
{ match: '&', name: 'entity.name.tag.nesting.css' },
|
|
70
|
+
{ include: 'source.css#selector-innards' }
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
const headers = [...Object.keys(preludes), 'custom-media'].map((name) => `-meta.at-rule.${name}.header.css`).join(' ')
|
|
74
|
+
|
|
75
|
+
/** Rules and conditional groups nested in a declaration block; their blocks accept declarations again. */
|
|
76
|
+
const cssNestingLanguage = {
|
|
77
|
+
name: 'css-nesting',
|
|
78
|
+
scopeName: 'source.css.nesting.injection',
|
|
79
|
+
injectTo: cssInjectionHosts,
|
|
80
|
+
injectionSelector: `L:meta.property-list.css -meta.property-value.css -meta.property-name.css -meta.selector.css -meta.at-rule.header.css ${headers} -comment -string`,
|
|
81
|
+
patterns: [
|
|
82
|
+
...Object.entries(preludes).map(([name, prelude]) => atRule(name, prelude, { include: 'source.css#rule-list' })),
|
|
83
|
+
// Each begin consumes its selector: the injection stays active inside, so a zero-width begin would recur.
|
|
84
|
+
{
|
|
85
|
+
// At a statement start, including a CSS-in-JS template start, a selector reaches `{` before `;`.
|
|
86
|
+
begin: '(?<=^\\s*|[{};`]\\s*)(?!--)((?:[&>+~*.#:\\[]|[-_a-zA-Z][\\w-]*)[^;{}]*?)(?<!\\$)(?=\\s*\\{)',
|
|
87
|
+
beginCaptures: { 1: { name: 'meta.selector.css', patterns: selectorInnards } },
|
|
88
|
+
end: '(?<=\\})',
|
|
89
|
+
patterns: [{ include: 'source.css#rule-list' }]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
// A selector list continues on the following lines.
|
|
93
|
+
begin: '(?<=^\\s*|[{};`]\\s*)([&>+~.#:\\[][^;{}]*,)\\s*$',
|
|
94
|
+
beginCaptures: { 1: { name: 'meta.selector.css', patterns: selectorInnards } },
|
|
95
|
+
end: '(?<=\\})',
|
|
96
|
+
patterns: [
|
|
97
|
+
{ begin: '^', end: '(?=\\s*\\{)', name: 'meta.selector.css', patterns: selectorInnards },
|
|
98
|
+
{ include: 'source.css#rule-list' }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
} as unknown as LanguageRegistration
|
|
103
|
+
|
|
104
|
+
/** Stylesheet-level at-rules the bundled grammar reads as selectors or plain text. */
|
|
105
|
+
const cssAtRulesLanguage = {
|
|
106
|
+
name: 'css-modern-at-rules',
|
|
107
|
+
scopeName: 'source.css.modern-at-rules.injection',
|
|
108
|
+
injectTo: cssInjectionHosts,
|
|
109
|
+
injectionSelector: `L:source.css -meta.property-list.css -meta.property-value.css -meta.selector.css -meta.at-rule.header.css ${headers} -comment -string`,
|
|
110
|
+
patterns: [
|
|
111
|
+
...['property', 'view-transition', 'font-palette-values', 'position-try'].map((name) => atRule(name, [
|
|
112
|
+
{ include: 'source.css#comment-block' },
|
|
113
|
+
{ match: '--[\\w-]+', name: 'support.type.property-name.custom.css' }
|
|
114
|
+
], { include: 'source.css#rule-list' })),
|
|
115
|
+
atRule('custom-media', [
|
|
116
|
+
{ match: '\\G\\s*(--[\\w-]+)', captures: { 1: { name: 'support.type.property-name.custom.css' } } },
|
|
117
|
+
{ include: 'source.css#media-query-list' }
|
|
118
|
+
], { include: 'source.css#comment-block' }),
|
|
119
|
+
atRule('container', preludes.container, block([{ include: 'source.css' }])),
|
|
120
|
+
atRule('scope', preludes.scope, block([{ include: 'source.css' }])),
|
|
121
|
+
atRule('starting-style', preludes['starting-style'], block([{ include: 'source.css' }]))
|
|
122
|
+
]
|
|
123
|
+
} as unknown as LanguageRegistration
|
|
124
|
+
|
|
125
|
+
/** Query features the bundled lists predate, such as `prefers-color-scheme` or container `inline-size`. */
|
|
126
|
+
const cssQueryFeaturesLanguage = {
|
|
127
|
+
name: 'css-query-features',
|
|
128
|
+
scopeName: 'source.css.query-features.injection',
|
|
129
|
+
injectTo: cssInjectionHosts,
|
|
130
|
+
injectionSelector: ['media', 'container', 'custom-media'].map((name) => `meta.at-rule.${name}.header.css -comment -string`).join(', '),
|
|
131
|
+
patterns: [
|
|
132
|
+
{
|
|
133
|
+
match: '(?i)(?<=\\(\\s*)([a-z][\\w-]*)(?=\\s*[:<>=)])',
|
|
134
|
+
captures: { 1: { name: 'support.type.property-name.media.css' } }
|
|
135
|
+
},
|
|
136
|
+
{ match: '(?i)(?<=:\\s*)[a-z][\\w-]*(?=\\s*\\))', name: 'support.constant.property-value.css' }
|
|
137
|
+
]
|
|
138
|
+
} as unknown as LanguageRegistration
|
|
139
|
+
|
|
140
|
+
/** Docs elide CSS with `...`; as a selector it would swallow the rest, including an HTML `</style>`. */
|
|
141
|
+
const cssPlaceholderLanguage = {
|
|
142
|
+
name: 'css-placeholder',
|
|
143
|
+
scopeName: 'source.css.placeholder.injection',
|
|
144
|
+
injectTo: cssInjectionHosts,
|
|
145
|
+
injectionSelector: 'L:source.css -meta.property-value.css -comment -string',
|
|
146
|
+
patterns: [{ match: '\\.{3}|…', name: 'comment.other.placeholder.css' }]
|
|
147
|
+
} as unknown as LanguageRegistration
|
|
148
|
+
|
|
149
|
+
/** `@import` conditions: `layer(name)` and `supports(declaration)`. */
|
|
150
|
+
const cssImportLanguage = {
|
|
151
|
+
name: 'css-import-conditions',
|
|
152
|
+
scopeName: 'source.css.import-conditions.injection',
|
|
153
|
+
injectTo: cssInjectionHosts,
|
|
154
|
+
injectionSelector: 'L:meta.at-rule.import.css -comment -string',
|
|
155
|
+
patterns: [['layer', [{ include: 'source.css#comment-block' }]], ['supports', [{ include: 'source.css#rule-list-innards' }]]].map(([name, patterns]) => ({
|
|
156
|
+
begin: `(?i)(?<![\\w-])(${name})(\\()`,
|
|
157
|
+
beginCaptures: {
|
|
158
|
+
1: { name: 'support.function.misc.css' },
|
|
159
|
+
2: { name: 'punctuation.section.function.begin.bracket.round.css' }
|
|
160
|
+
},
|
|
161
|
+
end: '\\)',
|
|
162
|
+
endCaptures: { 0: { name: 'punctuation.section.function.end.bracket.round.css' } },
|
|
163
|
+
name: `meta.function.${name}.css`,
|
|
164
|
+
patterns
|
|
165
|
+
}))
|
|
166
|
+
} as unknown as LanguageRegistration
|
|
167
|
+
|
|
168
|
+
/** `@supports selector(...)` tests a selector, not a declaration. */
|
|
169
|
+
const cssSupportsSelectorLanguage = {
|
|
170
|
+
name: 'css-supports-selector',
|
|
171
|
+
scopeName: 'source.css.supports-selector.injection',
|
|
172
|
+
injectTo: cssInjectionHosts,
|
|
173
|
+
injectionSelector: 'L:meta.at-rule.supports.header.css -comment -string',
|
|
174
|
+
patterns: [
|
|
175
|
+
{
|
|
176
|
+
begin: '(?i)(?<![\\w-])(selector)(\\()',
|
|
177
|
+
beginCaptures: {
|
|
178
|
+
1: { name: 'support.function.misc.css' },
|
|
179
|
+
2: { name: 'punctuation.section.function.begin.bracket.round.css' }
|
|
180
|
+
},
|
|
181
|
+
end: '\\)',
|
|
182
|
+
endCaptures: { 0: { name: 'punctuation.section.function.end.bracket.round.css' } },
|
|
183
|
+
name: 'meta.function.selector.css',
|
|
184
|
+
patterns: [
|
|
185
|
+
{
|
|
186
|
+
begin: '(?=\\S)',
|
|
187
|
+
end: '(?=\\))',
|
|
188
|
+
name: 'meta.selector.css',
|
|
189
|
+
patterns: selectorInnards
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
} as unknown as LanguageRegistration
|
|
195
|
+
|
|
196
|
+
/** Functions newer than the bundled list, such as `light-dark()` and `env()`, read as functions; `/` separates values. */
|
|
197
|
+
const cssFunctionsLanguage = {
|
|
198
|
+
name: 'css-modern-functions',
|
|
199
|
+
scopeName: 'source.css.modern-functions.injection',
|
|
200
|
+
injectTo: cssInjectionHosts,
|
|
201
|
+
injectionSelector: 'meta.property-value.css -comment -string',
|
|
202
|
+
patterns: [
|
|
203
|
+
{
|
|
204
|
+
begin: '(?i)(?<![\\w-])((?:-(?:webkit|moz|o|ms)-)?[a-z][\\w-]*)(\\()',
|
|
205
|
+
beginCaptures: {
|
|
206
|
+
1: { name: 'support.function.misc.css' },
|
|
207
|
+
2: { name: 'punctuation.section.function.begin.bracket.round.css' }
|
|
208
|
+
},
|
|
209
|
+
end: '\\)',
|
|
210
|
+
endCaptures: { 0: { name: 'punctuation.section.function.end.bracket.round.css' } },
|
|
211
|
+
name: 'meta.function.misc.css',
|
|
212
|
+
patterns: [{ include: 'source.css#property-values' }]
|
|
213
|
+
},
|
|
214
|
+
{ match: '/', name: 'punctuation.separator.slash.css' }
|
|
215
|
+
]
|
|
216
|
+
} as unknown as LanguageRegistration
|
|
217
|
+
|
|
218
|
+
function functionalPseudo(colons: string, kind: string, names = '[a-z][\\w-]*'): Pattern {
|
|
219
|
+
return {
|
|
220
|
+
begin: `(?i)(${colons})(${names})(\\()`,
|
|
221
|
+
beginCaptures: {
|
|
222
|
+
1: { name: 'punctuation.definition.entity.css' },
|
|
223
|
+
2: { name: `entity.other.attribute-name.pseudo-${kind}.css` },
|
|
224
|
+
3: { name: 'punctuation.section.function.begin.bracket.round.css' }
|
|
225
|
+
},
|
|
226
|
+
end: '\\)',
|
|
227
|
+
endCaptures: { 0: { name: 'punctuation.section.function.end.bracket.round.css' } },
|
|
228
|
+
name: `meta.function.pseudo-${kind}.css`,
|
|
229
|
+
patterns: [{ include: 'source.css#selector-innards' }]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Pseudo-classes and pseudo-elements newer than the bundled lists, with or without arguments. */
|
|
234
|
+
const cssPseudoLanguage = {
|
|
235
|
+
name: 'css-modern-pseudo',
|
|
236
|
+
scopeName: 'source.css.modern-pseudo.injection',
|
|
237
|
+
injectTo: cssInjectionHosts,
|
|
238
|
+
injectionSelector: 'meta.selector.css -comment -string',
|
|
239
|
+
patterns: [
|
|
240
|
+
functionalPseudo('::', 'element'),
|
|
241
|
+
functionalPseudo(':', 'class'),
|
|
242
|
+
{
|
|
243
|
+
match: '(?i)(::)[a-z][\\w-]*',
|
|
244
|
+
captures: {
|
|
245
|
+
0: { name: 'entity.other.attribute-name.pseudo-element.css' },
|
|
246
|
+
1: { name: 'punctuation.definition.entity.css' }
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
match: '(?i)(:)[a-z][\\w-]*',
|
|
251
|
+
captures: {
|
|
252
|
+
0: { name: 'entity.other.attribute-name.pseudo-class.css' },
|
|
253
|
+
1: { name: 'punctuation.definition.entity.css' }
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
} as unknown as LanguageRegistration
|
|
258
|
+
|
|
259
|
+
/** The bundled grammar knows `:host` only without its selector argument. */
|
|
260
|
+
const cssHostLanguage = {
|
|
261
|
+
name: 'css-host',
|
|
262
|
+
scopeName: 'source.css.host.injection',
|
|
263
|
+
injectTo: cssInjectionHosts,
|
|
264
|
+
injectionSelector: 'L:meta.selector.css -comment -string',
|
|
265
|
+
patterns: [functionalPseudo(':', 'class', 'host|host-context')]
|
|
266
|
+
} as unknown as LanguageRegistration
|
|
267
|
+
|
|
268
|
+
const scriptHosts = ['source.js', 'source.ts', 'source.tsx']
|
|
269
|
+
|
|
270
|
+
/** CSS-in-JS tagged templates hold declarations and nested rules: `styled.button`, `styled(Card)`, `css`, `keyframes`. */
|
|
271
|
+
const cssInJSLanguage = {
|
|
272
|
+
name: 'css-in-js',
|
|
273
|
+
scopeName: 'source.css.in-js.injection',
|
|
274
|
+
injectTo: scriptHosts,
|
|
275
|
+
injectionSelector: 'L:source -comment -string',
|
|
276
|
+
patterns: [
|
|
277
|
+
{
|
|
278
|
+
// The tag is part of the match: the script grammar would otherwise hold its tagged-template call open past the template.
|
|
279
|
+
begin: '(?<![\\w$.])(?:(styled)(?:(\\.)([\\w$]+)|(\\()([\\w$.]*)(\\)))|(css|keyframes|createGlobalStyle|injectGlobal))(`)',
|
|
280
|
+
beginCaptures: {
|
|
281
|
+
1: { name: 'variable.other.object.js' },
|
|
282
|
+
2: { name: 'punctuation.accessor.js' },
|
|
283
|
+
3: { name: 'entity.name.function.tagged-template.js' },
|
|
284
|
+
4: { name: 'meta.brace.round.js' },
|
|
285
|
+
5: { name: 'variable.other.readwrite.js' },
|
|
286
|
+
6: { name: 'meta.brace.round.js' },
|
|
287
|
+
7: { name: 'entity.name.function.tagged-template.js' },
|
|
288
|
+
8: { name: 'string.template.js punctuation.definition.string.template.begin.js' }
|
|
289
|
+
},
|
|
290
|
+
end: '`',
|
|
291
|
+
endCaptures: { 0: { name: 'string.template.js punctuation.definition.string.template.end.js' } },
|
|
292
|
+
contentName: 'meta.embedded.css-in-js source.css meta.property-list.css',
|
|
293
|
+
patterns: [{ include: 'source.css#rule-list-innards' }]
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
} as unknown as LanguageRegistration
|
|
297
|
+
|
|
298
|
+
/** `${...}` stays a script expression anywhere in a CSS-in-JS template, including inside a declaration value. */
|
|
299
|
+
const cssInJSSubstitutionLanguage = {
|
|
300
|
+
name: 'css-in-js-substitution',
|
|
301
|
+
scopeName: 'source.css.in-js-substitution.injection',
|
|
302
|
+
injectTo: scriptHosts,
|
|
303
|
+
injectionSelector: 'L:meta.embedded.css-in-js -comment',
|
|
304
|
+
patterns: [{ include: 'source.ts#template-substitution-element' }]
|
|
305
|
+
} as unknown as LanguageRegistration
|
|
306
|
+
|
|
307
|
+
/** A custom property declaration names a property, as in `@theme`; `var(--name)` references stay variables. */
|
|
308
|
+
const cssCustomPropertyLanguage = {
|
|
309
|
+
name: 'css-custom-property',
|
|
310
|
+
scopeName: 'source.css.custom-property.injection',
|
|
311
|
+
injectTo: cssInjectionHosts,
|
|
312
|
+
injectionSelector: 'L:meta.property-list.css -meta.property-value.css -meta.selector.css -comment -string',
|
|
313
|
+
patterns: [{ match: '(?<![\\w-])--[\\w-]+(?=\\s*:)', name: 'support.type.property-name.custom.css' }]
|
|
314
|
+
} as unknown as LanguageRegistration
|
|
315
|
+
|
|
316
|
+
/** Property names newer than the bundled list keep the property role. */
|
|
317
|
+
const cssPropertyNamesLanguage = {
|
|
318
|
+
name: 'css-modern-property-names',
|
|
319
|
+
scopeName: 'source.css.modern-property-names.injection',
|
|
320
|
+
injectTo: cssInjectionHosts,
|
|
321
|
+
injectionSelector: 'meta.property-name.css -comment -string',
|
|
322
|
+
patterns: [{ match: '(?<![\\w-])-?[a-zA-Z][\\w-]*', name: 'support.type.property-name.css' }]
|
|
323
|
+
} as unknown as LanguageRegistration
|
|
324
|
+
|
|
325
|
+
export default [
|
|
326
|
+
cssNestingLanguage,
|
|
327
|
+
cssAtRulesLanguage,
|
|
328
|
+
cssQueryFeaturesLanguage,
|
|
329
|
+
cssPlaceholderLanguage,
|
|
330
|
+
cssImportLanguage,
|
|
331
|
+
cssSupportsSelectorLanguage,
|
|
332
|
+
cssFunctionsLanguage,
|
|
333
|
+
cssPseudoLanguage,
|
|
334
|
+
cssHostLanguage,
|
|
335
|
+
cssCustomPropertyLanguage,
|
|
336
|
+
cssPropertyNamesLanguage,
|
|
337
|
+
cssInJSLanguage,
|
|
338
|
+
cssInJSSubstitutionLanguage
|
|
339
|
+
]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Fuse from 'fuse.js'
|
|
2
|
+
import type { SearchPage } from './search-pages'
|
|
3
|
+
|
|
4
|
+
export interface DocumentationSearchPage extends SearchPage {
|
|
5
|
+
kind?: string
|
|
6
|
+
identifiers?: { text: string; id?: string; detail?: string }[]
|
|
7
|
+
terms?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DocumentationSearchResult {
|
|
11
|
+
page: DocumentationSearchPage
|
|
12
|
+
href: string
|
|
13
|
+
reason: 'Identifier' | 'Title' | 'Syntax' | 'Topic' | 'Content'
|
|
14
|
+
excerpt: string
|
|
15
|
+
score: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const normalize = (text: string) => text.normalize('NFKC').toLocaleLowerCase().trim()
|
|
19
|
+
|
|
20
|
+
/** One index per loaded locale. Exact public identifiers outrank approximate prose. */
|
|
21
|
+
export function createDocumentationSearch(pages: DocumentationSearchPage[]) {
|
|
22
|
+
const enabled = pages.filter(page => !page.disabled)
|
|
23
|
+
const exact = new Map<string, DocumentationSearchResult[]>()
|
|
24
|
+
for (const page of enabled) {
|
|
25
|
+
for (const identifier of page.identifiers ?? []) {
|
|
26
|
+
const key = normalize(identifier.text)
|
|
27
|
+
const items = exact.get(key) ?? []
|
|
28
|
+
if (!items.some(item => item.page.url === page.url)) items.push({ page, href: page.url + (identifier.id ? `#${identifier.id}` : ''), reason: 'Identifier', excerpt: identifier.detail || identifier.text, score: 1000 })
|
|
29
|
+
exact.set(key, items)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const fuse = new Fuse(enabled, {
|
|
33
|
+
includeScore: true, includeMatches: true, threshold: .35, ignoreLocation: true,
|
|
34
|
+
keys: [{ name: 'title', weight: 4 }, { name: 'identifiers.text', weight: 4 }, { name: 'terms', weight: 3 }, { name: 'description', weight: 2 }, { name: 'nodes.text', weight: 1 }]
|
|
35
|
+
})
|
|
36
|
+
return (query: string, limit = 40): DocumentationSearchResult[] => {
|
|
37
|
+
const needle = normalize(query)
|
|
38
|
+
if (!needle) return []
|
|
39
|
+
if (exact.has(needle)) return exact.get(needle)!.slice(0, limit)
|
|
40
|
+
const results = new Map<string, DocumentationSearchResult>()
|
|
41
|
+
for (const page of enabled) {
|
|
42
|
+
const identifier = page.identifiers?.find(item => normalize(item.text) === needle)
|
|
43
|
+
const syntax = page.nodes.find(node => node.tag === 'code' && normalize(node.text).includes(needle))
|
|
44
|
+
const title = normalize(page.title) === needle
|
|
45
|
+
const topic = page.terms?.some(term => normalize(term) === needle)
|
|
46
|
+
if (!identifier && !syntax && !title && !topic) continue
|
|
47
|
+
const node = identifier ?? syntax
|
|
48
|
+
const id = node?.id
|
|
49
|
+
results.set(page.url, {
|
|
50
|
+
page, href: page.url + (id ? `#${id}` : ''),
|
|
51
|
+
reason: identifier ? 'Identifier' : title ? 'Title' : topic ? 'Topic' : 'Syntax',
|
|
52
|
+
excerpt: identifier?.detail || identifier?.text || (title || topic ? page.description : syntax?.text) || page.description,
|
|
53
|
+
score: identifier ? 1000 : title ? 950 : topic ? 850 : 750
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
const approximate = [...results.values()].some(result => result.reason === 'Identifier') ? [] : fuse.search(query, { limit: limit * 2 })
|
|
57
|
+
for (const match of approximate) {
|
|
58
|
+
const page = match.item
|
|
59
|
+
if (results.has(page.url)) continue
|
|
60
|
+
const nodeMatch = match.matches?.find(match => match.key === 'nodes.text')
|
|
61
|
+
const index = nodeMatch?.refIndex ?? -1
|
|
62
|
+
const node = page.nodes[index]
|
|
63
|
+
const anchor = node?.id ?? page.nodes.slice(0, index).reverse().find(node => node.id)?.id
|
|
64
|
+
results.set(page.url, { page, href: page.url + (anchor ? `#${anchor}` : ''), reason: 'Content', excerpt: node?.text || page.description, score: 500 - (match.score ?? 1) * 100 })
|
|
65
|
+
}
|
|
66
|
+
return [...results.values()].sort((a, b) => b.score - a.score || a.page.title.localeCompare(b.page.title)).slice(0, limit)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defu } from 'defu'
|
|
2
|
+
import type { Metadata } from '../types/Metadata'
|
|
3
|
+
import type { Props } from '../types/Props'
|
|
4
|
+
import { createTranslation } from './i18n'
|
|
5
|
+
|
|
6
|
+
export default async function generate(
|
|
7
|
+
metadata: Metadata | Record<string, any>,
|
|
8
|
+
{ params }: Pick<Props, 'params'>,
|
|
9
|
+
dictionaries: Record<string, () => Promise<any>>
|
|
10
|
+
): Promise<Metadata> {
|
|
11
|
+
const { locale } = params
|
|
12
|
+
const $ = await createTranslation(locale, dictionaries)
|
|
13
|
+
const description = $(metadata.description)
|
|
14
|
+
const category = $(metadata.category)
|
|
15
|
+
const ogTitle = $(metadata.openGraph?.title || metadata.title?.absolute || metadata.title)
|
|
16
|
+
const ogDescription = $(metadata.openGraph?.description || metadata.description)
|
|
17
|
+
const requestedSearchParams = {
|
|
18
|
+
...metadata as any,
|
|
19
|
+
title: ogTitle,
|
|
20
|
+
description: ogDescription,
|
|
21
|
+
locale
|
|
22
|
+
}
|
|
23
|
+
delete requestedSearchParams.openGraph
|
|
24
|
+
if (requestedSearchParams.authors) {
|
|
25
|
+
requestedSearchParams.authors = JSON.stringify(requestedSearchParams.authors.map((author: any) => author.name))
|
|
26
|
+
}
|
|
27
|
+
const baseMetadata: any = {
|
|
28
|
+
openGraph: {
|
|
29
|
+
title: ogTitle,
|
|
30
|
+
description: ogDescription,
|
|
31
|
+
siteName: import.meta.env.PUBLIC_PROJECT
|
|
32
|
+
},
|
|
33
|
+
twitter: {
|
|
34
|
+
title: ogTitle,
|
|
35
|
+
description: ogDescription,
|
|
36
|
+
site: '@mastercorg',
|
|
37
|
+
creator: '@aron1tw',
|
|
38
|
+
card: 'summary_large_image'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (metadata.openGraph?.images) {
|
|
42
|
+
baseMetadata.twitter.images = metadata.openGraph.images
|
|
43
|
+
} else {
|
|
44
|
+
// postbuild-static renders each placeholder into a static /og image.
|
|
45
|
+
baseMetadata.openGraph.images = baseMetadata.twitter.images = `/api/og-image?${new URLSearchParams(requestedSearchParams)}`
|
|
46
|
+
}
|
|
47
|
+
return defu(
|
|
48
|
+
{
|
|
49
|
+
title: typeof metadata.title === 'string'
|
|
50
|
+
? $(metadata.title)
|
|
51
|
+
: {
|
|
52
|
+
absolute: $(metadata.title.absolute)
|
|
53
|
+
},
|
|
54
|
+
description,
|
|
55
|
+
category
|
|
56
|
+
},
|
|
57
|
+
metadata,
|
|
58
|
+
baseMetadata
|
|
59
|
+
) as Metadata
|
|
60
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Sections with the subsections that follow them, as nested contents lists; a subsection before any section stands on its own. */
|
|
2
|
+
export default function groupPageContent<T extends { level: number }>(items: T[]) {
|
|
3
|
+
const groups: { item: T, children: T[] }[] = []
|
|
4
|
+
for (const item of items) {
|
|
5
|
+
const parent = groups[groups.length - 1]
|
|
6
|
+
if (item.level === 3 && parent?.item.level === 2) parent.children.push(item)
|
|
7
|
+
else groups.push({ item, children: [] })
|
|
8
|
+
}
|
|
9
|
+
return groups
|
|
10
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Metadata } from '../types/Metadata'
|
|
2
|
+
|
|
3
|
+
export interface HeadTag {
|
|
4
|
+
tag: 'meta' | 'link'
|
|
5
|
+
attributes: Record<string, string>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ResolvedHead {
|
|
9
|
+
title: string
|
|
10
|
+
tags: HeadTag[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function list(value: string | string[] | undefined) {
|
|
14
|
+
return value === undefined ? [] : Array.isArray(value) ? value : [value]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function resolveTitle(title: Metadata['title'], project: string) {
|
|
18
|
+
if (!title) return project
|
|
19
|
+
if (typeof title === 'string') return `${title} - ${project}`
|
|
20
|
+
if ('absolute' in title) return title.absolute
|
|
21
|
+
return title.default
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function resolveRobots(robots: Metadata['robots']) {
|
|
25
|
+
if (!robots || typeof robots === 'string') return robots
|
|
26
|
+
return [robots.index === false ? 'noindex' : 'index', robots.follow === false ? 'nofollow' : 'follow']
|
|
27
|
+
.filter((value, index) => index === 0 || robots.follow !== undefined)
|
|
28
|
+
.join(', ')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface HeadOptions {
|
|
32
|
+
project: string
|
|
33
|
+
siteURL: string
|
|
34
|
+
/** The page's published pathname; indexable pages declare it as canonical. */
|
|
35
|
+
pathname?: string
|
|
36
|
+
/** Published pathnames of the page by `hreflang`, including `x-default`. */
|
|
37
|
+
languages?: Record<string, string>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Resolve page metadata into document head tags. Relative URLs resolve against `siteURL`. */
|
|
41
|
+
export function resolveHead(metadata: Partial<Metadata>, { project, siteURL, pathname, languages = {} }: HeadOptions): ResolvedHead {
|
|
42
|
+
const tags: HeadTag[] = []
|
|
43
|
+
const absolute = (url: string) => new URL(url, siteURL).href
|
|
44
|
+
const meta = (key: 'name' | 'property', name: string, content: string | undefined) => {
|
|
45
|
+
if (content) tags.push({ tag: 'meta', attributes: { [key]: name, content } })
|
|
46
|
+
}
|
|
47
|
+
const robots = resolveRobots(metadata.robots)
|
|
48
|
+
const indexable = !robots?.includes('noindex')
|
|
49
|
+
meta('name', 'description', metadata.description)
|
|
50
|
+
meta('name', 'category', metadata.category)
|
|
51
|
+
meta('name', 'robots', robots)
|
|
52
|
+
const canonical = metadata.alternates?.canonical ?? (indexable ? pathname : undefined)
|
|
53
|
+
if (canonical) tags.push({ tag: 'link', attributes: { rel: 'canonical', href: absolute(canonical) } })
|
|
54
|
+
if (indexable) {
|
|
55
|
+
for (const [hreflang, href] of Object.entries(languages)) {
|
|
56
|
+
tags.push({ tag: 'link', attributes: { rel: 'alternate', hreflang, href: absolute(href) } })
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const { openGraph, twitter } = metadata
|
|
60
|
+
meta('property', 'og:title', openGraph?.title)
|
|
61
|
+
meta('property', 'og:description', openGraph?.description)
|
|
62
|
+
meta('property', 'og:site_name', openGraph?.siteName)
|
|
63
|
+
// Open Graph and Twitter cards require absolute image URLs.
|
|
64
|
+
for (const image of list(openGraph?.images)) meta('property', 'og:image', absolute(image))
|
|
65
|
+
meta('name', 'twitter:card', twitter?.card)
|
|
66
|
+
meta('name', 'twitter:site', twitter?.site)
|
|
67
|
+
meta('name', 'twitter:creator', twitter?.creator)
|
|
68
|
+
meta('name', 'twitter:title', twitter?.title)
|
|
69
|
+
meta('name', 'twitter:description', twitter?.description)
|
|
70
|
+
for (const image of list(twitter?.images)) meta('name', 'twitter:image', absolute(image))
|
|
71
|
+
return { title: resolveTitle(metadata.title, project), tags }
|
|
72
|
+
}
|