-
Notifications
You must be signed in to change notification settings - Fork 5
GRO-683 - 1 - Add astro, example page, make astro+jekyll live side by side (temporarily) #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4ae0e57
dc4d793
fd2a6f1
46a7768
22fe78d
e079a39
228b6e0
8820fe5
a507711
219720a
2c33bf7
9df31f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,20 @@ | ||
| /node_modules/ | ||
| .DS_Store | ||
| .idea | ||
| .vscode | ||
| *.log | ||
| tmp/ | ||
| /htmlproofer.out | ||
| /.clj-kondo/ | ||
| /.lsp/ | ||
| /_site/ | ||
|
|
||
| # Astro build output | ||
| dist/ | ||
|
|
||
| # generated types | ||
| .astro/ | ||
|
|
||
| # environment variables | ||
| .env | ||
| .env.production |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "plugins": [ | ||
| "@ianvs/prettier-plugin-sort-imports", | ||
| "prettier-plugin-astro" | ||
| ], | ||
| "trailingComma": "all" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ## Development | ||
|
|
||
| When starting the dev server, use background mode: | ||
|
|
||
| ``` | ||
| astro dev --background | ||
| ``` | ||
|
|
||
| Manage the background server with `astro dev stop`, `astro dev status`, and `astro dev logs`. | ||
|
|
||
| ## Documentation | ||
|
|
||
| Full documentation: https://docs.astro.build | ||
|
|
||
| Consult these guides before working on related tasks: | ||
|
|
||
| - [Adding pages, dynamic routes, or middleware](https://docs.astro.build/en/guides/routing/) | ||
| - [Working with Astro components](https://docs.astro.build/en/basics/astro-components/) | ||
| - [Using React, Vue, Svelte, or other framework components](https://docs.astro.build/en/guides/framework-components/) | ||
| - [Adding or managing content](https://docs.astro.build/en/guides/content-collections/) | ||
| - [Adding styles or using Tailwind](https://docs.astro.build/en/guides/styling/) | ||
| - [Supporting multiple languages](https://docs.astro.build/en/guides/internationalization/) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| AGENTS.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,4 +31,4 @@ | |
| ] | ||
| } | ||
| </script> | ||
| {% assign page.schema_markup_added = true %} {% endunless %} | ||
| {% endunless %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Jekyll::Hooks.register :site, :post_write do |site| | ||
| next if site.config['serving'] | ||
|
|
||
| build_astro = "bun run build" | ||
|
|
||
| raise "Astro build failed" unless system(build_astro) | ||
|
|
||
| shuffle_directories = "rsync -a dist/* _site && rm -rf dist" | ||
|
|
||
| raise "Astro sitemap rename / sync failed" unless system("#{shuffle_directories}") | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // @ts-check | ||
| import { defineConfig } from 'astro/config'; | ||
|
|
||
| // https://astro.build/config | ||
| export default defineConfig({}); |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
| import type { LiquidRenderer } from "@/lib/liquid/liquidRenderer"; | ||
|
|
||
| const INCLUDES_ROOT = path.join(process.cwd(), "_includes"); | ||
|
|
||
| // Astro equivalent of Jekyll's `{% include %}` tag. Extra props are passed | ||
| // through as `include.*` inside the partial, just like Jekyll: | ||
| // {% include foo.html param="x" %} -> <LiquidInclude src="foo.html" param="x" /> | ||
| interface Props { | ||
| lq: LiquidRenderer; | ||
| src: string; | ||
| [param: string]: unknown; | ||
| } | ||
|
|
||
| const { lq, src, ...params } = Astro.props; | ||
|
|
||
| const html = await lq.render( | ||
| fs.readFileSync(path.join(INCLUDES_ROOT, src), "utf-8"), | ||
| { include: params }, | ||
| ); | ||
| --- | ||
|
|
||
| <Fragment set:html={html} /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineCollection } from "astro:content"; | ||
| import { glob } from "astro/loaders"; | ||
|
|
||
| const examples = defineCollection({ | ||
| loader: glob({ | ||
| pattern: ["src/example-collection/**/*.md"], | ||
| }), | ||
| }); | ||
|
|
||
| export const collections = { examples }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --- | ||
| version: v0.62 | ||
| has_magic_breadcrumbs: true | ||
| show_category_breadcrumb: true | ||
| show_title_breadcrumb: true | ||
| layout: new-docs | ||
| no_index_no_follow: true | ||
| --- | ||
|
|
||
| # Example markdown astro page | ||
|
|
||
| ## Liquid include examples | ||
|
|
||
| {% include plans-blockquote.html feature="Authenticated embeds" sdk=true is_plural=true%} | ||
|
|
||
| {% include youtube.html id='yTRzCQeTmO8' %} | ||
|
|
||
| {% include beta-blockquote.html %} | ||
|
|
||
| ## Custom include_file examples | ||
|
|
||
| Whole file (remove snippet comments): | ||
|
|
||
| ```js | ||
| {% include_file "{{ dirname }}/sdk/snippets/next-js/app-router-authentication-api-route.ts" %} | ||
| ``` | ||
|
|
||
| Specific snippet: | ||
|
|
||
| ```js | ||
| {% include_file "{{ dirname }}/sdk/snippets/authentication/auth-config-base.tsx" snippet="example" %} | ||
| ``` | ||
|
|
||
| ## Miscellaneous cases | ||
|
|
||
| ### Inline attribute lists | ||
|
|
||
| ``` | ||
| [Metabase Expert](/partners/){:target="_blank"} | ||
| ``` | ||
|
|
||
| gets rendered as [Metabase Expert](/partners/){:target="_blank"}. | ||
|
|
||
| ### Inline code snippet | ||
|
|
||
| Inline backticks like `this` get rendered as inline code with no copy button. | ||
|
|
||
| ### Responsive tables | ||
|
|
||
| The columns should stack on small screens. | ||
|
|
||
| {% include_file "{{ dirname }}/sdk/api/snippets/ParameterChangePayload.md" snippet="properties" %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| --- | ||
| import LiquidInclude from "@/components/LiquidInclude.astro"; | ||
| import { getLiquidRenderer } from "@/lib/liquid/liquidRenderer"; | ||
|
|
||
| type Props = { | ||
| page: Record<string, unknown>; | ||
| dirname: string; | ||
| }; | ||
|
|
||
| const { page, dirname } = Astro.props; | ||
|
|
||
| const lq = getLiquidRenderer({ page, dirname }); | ||
| --- | ||
|
|
||
| <!doctype html> | ||
| <html prefix="og: https://ogp.me/ns#" lang="en-US"> | ||
| <LiquidInclude lq={lq} src="head.html" /> | ||
|
|
||
| <body> | ||
| <LiquidInclude lq={lq} src="shared-chrome/header.html" /> | ||
|
|
||
| <div> | ||
| <slot /> | ||
| </div> | ||
|
|
||
| <LiquidInclude lq={lq} src="shared-chrome/footer.html" /> | ||
| <script is:inline type="text/javascript" src="/js/contentloaded.min.js" | ||
| ></script> | ||
| <script is:inline type="text/javascript" src="/js/lightbox.js"></script> | ||
| <script is:inline type="text/javascript" src="/js/documentation.js" | ||
| ></script> | ||
| <script is:inline type="text/javascript" src="/js/blog.js"></script> | ||
| <script is:inline type="text/javascript" src="/js/syntax-highlight.js" | ||
| ></script> | ||
|
|
||
| { | ||
| Astro.url.pathname.includes("/docs/") && | ||
| Astro.url.pathname.includes("embedding") && ( | ||
| <script | ||
| is:inline | ||
| type="text/javascript" | ||
| src="/js/docs/checkpoints.js" | ||
| /> | ||
| ) | ||
| } | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| import LiquidInclude from "@/components/LiquidInclude.astro"; | ||
| import { getLiquidRenderer } from "@/lib/liquid/liquidRenderer"; | ||
| import DefaultNewLayout from "./DefaultNewLayout.astro"; | ||
|
|
||
| type Props = { | ||
| page: { | ||
| category: string; | ||
| }; | ||
| dirname: string; | ||
| }; | ||
|
|
||
| const { page, dirname } = Astro.props; | ||
|
|
||
| /* Do not show breadcrumb on home page */ | ||
| const parts = Astro.url.pathname.split("/"); | ||
| const showBreadcrumb = | ||
| parts[1] == "docs" && parts.length == 4 && parts[3] === "index.html"; | ||
|
Comment on lines
+17
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I beefed it in this PR. I corrected it in the PR where it actually matters though. https://github.com/metabase/docs.metabase.github.io/pull/1243/changes#diff-43fea136ca01895cbd79ec383fbfa857dae9649fa291efdc0e64223d9df62716R17 |
||
|
|
||
| const lq = getLiquidRenderer({ page, dirname }); | ||
| --- | ||
|
|
||
| <DefaultNewLayout page={page} dirname={dirname}> | ||
| <div class="bootstrap"> | ||
| <div class="learn docs blog-post MB-Page"> | ||
| <LiquidInclude lq={lq} src="docs/left-sidebar.html" domain="docs" /> | ||
|
|
||
| <article class="learn__post learn__article"> | ||
| <LiquidInclude | ||
| lq={lq} | ||
| src="learn/top-bar.html" | ||
| domain="docs" | ||
| show_breadcrumb="show_breadcrumb" | ||
| /> | ||
|
|
||
| <div class="learn__post__content"> | ||
| {!showBreadcrumb && <LiquidInclude lq={lq} src="docs_version.html" />} | ||
|
|
||
| <LiquidInclude lq={lq} src="docs/blockquotes.html" /> | ||
|
|
||
| <slot /> | ||
|
|
||
| <div> | ||
| <div class="widget-separator"></div> | ||
| { | ||
| page.category !== "Cloud" && ( | ||
| <p> | ||
| Read docs for other{" "} | ||
| <a href="/docs/all">versions of Metabase</a>. | ||
| </p> | ||
| ) | ||
| } | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="learn__right-sidebar"> | ||
| <div id="sub-navigation-content"> | ||
| {/* Is populated via js */} | ||
| </div> | ||
| <LiquidInclude | ||
| lq={lq} | ||
| src="shared/was-this-helpful-widget.html" | ||
| should_add_propose_a_change_dialog="true" | ||
| /> | ||
| </div> | ||
| </article> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script | ||
| is:inline | ||
| type="text/javascript" | ||
| src="/js/new-docs-version-selector.js"></script> | ||
| <script is:inline type="text/javascript" src="/js/new-docs-anchor-links.js" | ||
| ></script> | ||
| <script | ||
| is:inline | ||
| type="text/javascript" | ||
| src="/js/new-docs-code-snippet-copy.js"></script> | ||
| <script is:inline type="text/javascript" src="/js/new-docs-table-overflow.js" | ||
| ></script> | ||
| <script is:inline type="text/javascript" src="/js/image-zoom.js"></script> | ||
| <script is:inline type="text/javascript" src="/js/learn/left-sidebar.js" | ||
| ></script> | ||
| <script is:inline type="text/javascript" src="/js/docs/right-sidebar.js" | ||
| ></script> | ||
| <script is:inline type="text/javascript" src="/js/position-feedback-widget.js" | ||
| ></script> | ||
|
|
||
| <script is:inline src="/js/use-custom-header-checkout-link.js"></script> | ||
| </DefaultNewLayout> | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this is a no-op. You can't actually reassign page properties in jekyll.