Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
380 changes: 210 additions & 170 deletions app/ai/page.tsx

Large diffs are not rendered by default.

285 changes: 195 additions & 90 deletions app/components/Navbar.tsx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions blogs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: DocumentDB Blog
description: Insights, updates, and deep dives into the world of document databases and open-source innovation.
# Shared external links. The Next.js app keeps the same values in
# app/services/externalLinks.ts; update both when one changes.
# Shared external links. app/services/externalLinks.ts and _data/nav.json hold
# the same invite; tests/blogSections.test.ts fails if they differ.
discord_url: https://discord.gg/vH7bYu524D
# Shared release announcement target. app/services/externalLinks.ts holds
# the same site-root path.
Expand Down
30 changes: 30 additions & 0 deletions blogs/_data/nav.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"links": [
{ "label": "Docs", "href": "/docs" },
{ "label": "Install & Download", "href": "/packages" },
{ "label": "AI", "href": "/ai" },
{ "label": "Kubernetes", "href": "/kubernetes-operator" },
{
"label": "Build",
"items": [
{ "label": "Samples", "href": "/samples" },
{
"label": "VS Code extension",
"href": "https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-documentdb"
},
{ "label": "Agent-Kit", "href": "https://github.com/Azure/documentdb-agent-kit" }
]
},
{
"label": "News",
"items": [
{ "label": "Announcements", "href": "/announcements/", "section": "announcements" },
{ "label": "Blogs", "href": "/blogs/", "section": "blogs" }
]
}
],
"icons": [
{ "label": "GitHub", "href": "https://github.com/documentdb/documentdb", "icon": "github" },
{ "label": "Discord", "href": "https://discord.gg/vH7bYu524D", "icon": "discord" }
]
}
11 changes: 11 additions & 0 deletions blogs/_includes/nav-icon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- comment -%}Same icons as app/components/Navbar.tsx{%- endcomment -%}
{%- case include.name -%}
{%- when 'github' -%}
<svg class="nav-icon" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true"><path fill-rule="evenodd" clip-rule="evenodd" d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z"/></svg>
{%- when 'discord' -%}
<svg class="nav-icon" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419-.0190 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9460 2.4189-2.1568 2.4189Z"/></svg>
{%- when 'chevron' -%}
<svg class="nav-chevron" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.17l3.71-3.94a.75.75 0 1 1 1.08 1.04l-4.25 4.5a.75.75 0 0 1-1.08 0l-4.25-4.5a.75.75 0 0 1 .02-1.06Z"/></svg>
{%- when 'external' -%}
<svg class="nav-external" fill="none" stroke="currentColor" stroke-width="1.8" viewBox="0 0 20 20" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M7 13 13 7M8 7h5v5"/></svg>
{%- endcase -%}
12 changes: 12 additions & 0 deletions blogs/_includes/nav-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{%- comment -%}One nav.json link; current_section comes from the layout{%- endcomment -%}
{%- assign nav_link = include.link -%}
{%- if include.icon -%}
{%- capture nav_label -%}{% include nav-icon.html name=nav_link.icon %}<span{% unless include.labelled %} class="visually-hidden"{% endunless %}>{{ nav_link.label | escape }}</span>{%- endcapture -%}
{%- else -%}
{%- assign nav_label = nav_link.label | escape -%}
{%- endif -%}
{%- if nav_link.href contains '://' -%}
<a href="{{ nav_link.href | escape }}" target="_blank" rel="noopener noreferrer">{{ nav_label }}{% unless include.icon %}{% include nav-icon.html name='external' %}{% endunless %}</a>
{%- else -%}
<a href="{{ nav_link.href | relative_url }}"{% if nav_link.section and nav_link.section == current_section %} aria-current="page"{% endif %}>{{ nav_label }}</a>
{%- endif -%}
90 changes: 55 additions & 35 deletions blogs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,9 @@
</head>
<body>
{% assign home_href = '/' | relative_url %}
{% assign docs_href = '/docs' | relative_url %}
{% assign packages_href = '/packages' | relative_url %}
{% assign operator_href = '/kubernetes-operator' | relative_url %}
{% assign logo_href = '/images/DocumentDB Logo - background removed.png' | relative_url %}
{% assign blogs_href = '/blogs/' | relative_url %}
{% assign announcements_href = '/announcements/' | relative_url %}
{% assign current_section = page.section | default: 'blogs' %}

{% capture nav_links %}
<a href="{{ home_href }}">Home</a>
<a href="https://github.com/documentdb/documentdb" target="_blank" rel="noopener noreferrer">GitHub</a>
<a href="{{ site.discord_url }}" target="_blank" rel="noopener noreferrer">Discord</a>
<a href="{{ docs_href }}">Docs</a>
<a href="{{ packages_href }}">Download</a>
<a href="https://github.com/Azure/documentdb-agent-kit" target="_blank" rel="noopener noreferrer">Agent-Kit</a>
<a href="{{ operator_href }}">K8s Operator</a>
<a href="{{ announcements_href }}"{% if current_section == 'announcements' %} aria-current="page"{% endif %}>Announcements</a>
<a href="{{ blogs_href }}"{% if current_section == 'blogs' %} aria-current="page"{% endif %}>Blogs</a>
{% endcapture %}

{% assign release_page_href = '/v1/' | relative_url %}
<div class="site-shell">
<a class="release-bar" href="{{ release_page_href }}">
Expand All @@ -76,7 +59,24 @@
</a>
{% comment %}One landmark for both layouts; screen readers otherwise lose it while the menu is closed{% endcomment %}
<nav class="site-nav-wrap" aria-label="Primary">
<div class="site-nav">{{ nav_links }}</div>
{% comment %}blogs/_data/nav.json also drives app/components/Navbar.tsx{% endcomment %}
<div class="site-nav">
{%- for item in site.data.nav.links -%}
{%- if item.items -%}
<details class="site-dropdown">
<summary>{{ item.label }}{% include nav-icon.html name='chevron' %}</summary>
<div class="site-dropdown__panel">
{%- for link in item.items %}{% include nav-link.html link=link %}{% endfor -%}
</div>
</details>
{%- else %}
{% include nav-link.html link=item %}
{%- endif -%}
{%- endfor %}
<span class="site-nav__icons">
{%- for link in site.data.nav.icons %}{% include nav-link.html link=link icon=true %}{% endfor -%}
</span>
</div>
<details class="site-menu">
<summary class="site-menu__toggle" aria-label="Navigation menu">
<svg class="site-menu__icon-open" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
Expand All @@ -86,7 +86,19 @@
<path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6 6 18" />
</svg>
</summary>
<div class="site-menu__links">{{ nav_links }}</div>
<div class="site-menu__links">
{%- for item in site.data.nav.links -%}
{%- if item.items %}
<p class="site-menu__group">{{ item.label }}</p>
{%- for link in item.items %}{% include nav-link.html link=link %}{% endfor -%}
{%- else %}
{% include nav-link.html link=item %}
{%- endif -%}
{%- endfor %}
<div class="site-menu__icons">
{%- for link in site.data.nav.icons %}{% include nav-link.html link=link icon=true labelled=true %}{% endfor -%}
</div>
</div>
</details>
</nav>
</div>
Expand All @@ -102,26 +114,34 @@
</div>
</footer>
</div>
{% comment %}The open panel covers the page, so close it whenever focus or the page moves on{% endcomment %}
{% comment %}Open panels cover the page, so close them whenever focus, a tap or the page moves on{% endcomment %}
<script>
(function () {
var menu = document.querySelector(".site-menu");
if (!menu) return;
function close() { menu.open = false; }
menu.addEventListener("keydown", function (event) {
if (event.key === "Escape" && menu.open) {
close();
menu.querySelector("summary").focus();
}
var panels = Array.prototype.slice.call(document.querySelectorAll(".site-header details"));
function closeOutside(target) {
panels.forEach(function (panel) {
if (panel.open && !panel.contains(target)) panel.open = false;
});
}
panels.forEach(function (panel) {
panel.addEventListener("toggle", function () {
if (panel.open) closeOutside(panel);
});
panel.addEventListener("keydown", function (event) {
if (event.key === "Escape" && panel.open) {
panel.open = false;
panel.querySelector("summary").focus();
}
});
panel.addEventListener("click", function (event) {
if (event.target.closest("a")) panel.open = false;
});
});
// Safari blurs to nothing when a link is clicked, so only close once focus lands outside
document.addEventListener("focusin", function (event) {
if (menu.open && !menu.contains(event.target)) close();
});
menu.querySelector(".site-menu__links").addEventListener("click", function (event) {
if (event.target.closest("a")) close();
});
window.addEventListener("pageshow", close);
document.addEventListener("focusin", function (event) { closeOutside(event.target); });
// Safari never focuses a clicked summary either
document.addEventListener("pointerdown", function (event) { closeOutside(event.target); });
window.addEventListener("pageshow", function () { closeOutside(null); });
})();
</script>
</body>
Expand Down
129 changes: 123 additions & 6 deletions blogs/assets/blog.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,111 @@ a {
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 2rem;
gap: 1.5rem;
font-size: 0.95rem;
font-weight: 500;
color: var(--muted);
}

.site-nav a {
.site-nav a,
.site-dropdown > summary {
white-space: nowrap;
transition: color 160ms ease;
}

.site-nav a[aria-current="page"] {
.site-nav a[aria-current="page"],
.site-dropdown:has([aria-current="page"]) > summary {
color: #60a5fa;
}

.site-nav a:focus-visible,
.site-dropdown > summary:focus-visible {
outline: 2px solid #60a5fa;
outline-offset: 4px;
border-radius: 0.25rem;
}

.nav-icon {
display: block;
width: 1.25rem;
height: 1.25rem;
}

.nav-chevron {
width: 1rem;
height: 1rem;
transition: transform 160ms ease;
}

.nav-external {
flex-shrink: 0;
width: 0.875rem;
height: 0.875rem;
color: var(--subtle);
}

.site-dropdown {
position: relative;
}

.site-dropdown > summary {
display: inline-flex;
align-items: center;
gap: 0.25rem;
cursor: pointer;
list-style: none;
}

.site-dropdown > summary::-webkit-details-marker {
display: none;
}

.site-dropdown[open] .nav-chevron {
transform: rotate(180deg);
}

.site-dropdown__panel {
position: absolute;
top: calc(100% + 0.75rem);
left: 50%;
z-index: 50;
display: flex;
flex-direction: column;
width: 14rem;
padding: 0.375rem;
transform: translateX(-50%);
border: 1px solid rgba(64, 64, 64, 0.9);
border-radius: 0.5rem;
background: rgb(23, 23, 27);
box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
}

.site-dropdown__panel a {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
padding: 0.5rem 0.75rem;
border-radius: 0.375rem;
font-size: 0.875rem;
}

.site-dropdown__panel a[aria-current="page"] {
background: rgba(38, 38, 45, 0.9);
}

.site-nav__icons {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding-left: 1rem;
border-left: 1px solid rgba(64, 64, 64, 0.9);
}

.site-nav__icons a {
padding: 0.375rem;
}

.site-menu {
display: none;
}
Expand Down Expand Up @@ -210,24 +300,51 @@ a {
}

.site-menu__links a {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.625rem 0.75rem;
border-radius: 0.375rem;
color: var(--muted);
font-size: 0.875rem;
font-weight: 500;
}

.site-menu__group {
margin: 0.5rem 0 0;
padding: 0.5rem 0.75rem 0.25rem;
color: var(--subtle);
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.18em;
text-transform: uppercase;
}

.site-menu__icons {
display: flex;
gap: 0.25rem;
margin-top: 0.5rem;
padding-top: 0.75rem;
border-top: 1px solid rgba(64, 64, 64, 0.9);
}

.site-menu__links a[aria-current="page"] {
background: rgba(38, 38, 45, 0.9);
color: #60a5fa;
}

/* Touch screens would keep a tapped item highlighted */
@media (hover: hover) {
.site-nav a:hover {
.site-nav a:hover,
.site-dropdown > summary:hover {
color: #60a5fa;
}

.site-dropdown__panel a:hover {
background: rgba(38, 38, 45, 0.9);
color: #fff;
}

.site-menu__toggle:hover {
border-color: #60a5fa;
color: #fff;
Expand All @@ -239,8 +356,8 @@ a {
}
}

/* Same query as the main navbar's Tailwind max-xl; print keeps the plain link list */
@media screen and (width < 80rem) {
/* Same query as the main navbar's Tailwind max-lg; print keeps the plain link list */
@media screen and (width < 64rem) {
.site-nav {
display: none;
}
Expand Down
22 changes: 22 additions & 0 deletions tests/aiPage.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, it } from 'vitest';
import AIPage from '../app/ai/page';
import { samples } from '../app/data/samples';

describe('AI page', () => {
const html = renderToStaticMarkup(createElement(AIPage));

it('shows every vector search sample from the gallery', () => {
const aiSamples = samples.filter((sample) => sample.tags.includes('Vector Search'));
expect(aiSamples.length).toBeGreaterThan(0);
for (const sample of aiSamples) {
expect(html).toContain(`href="${sample.githubUrl}"`);
}
});

// A sample renamed or removed in the gallery registry would otherwise drop its link silently
it('links the RAG, search, and agent memory use cases to their samples', () => {
expect(html.match(/>Sample: /g)).toHaveLength(3);
});
});
Loading
Loading