Skip to content

Commit

Permalink
Fixes Copilot position on Tutorials page
Browse files Browse the repository at this point in the history
- Also introduce a proxy for testing out copilot locally
  • Loading branch information
foot committed Oct 2, 2024
1 parent c569687 commit 7478610
Show file tree
Hide file tree
Showing 7 changed files with 519 additions and 31 deletions.
6 changes: 1 addition & 5 deletions assets/css/bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -3134,7 +3134,7 @@ div.highlight.line-numbers pre.chroma code span.line::before{
#ai-sidebar-target{
position:fixed;
z-index:10;
top:0;
top:108px;
right:0;
bottom:0
}
Expand All @@ -3143,10 +3143,6 @@ div.highlight.line-numbers pre.chroma code span.line::before{
top:200px
}

.section-docs #ai-sidebar-target{
top:108px
}

div.highlight{
display:flex
}
Expand Down
1 change: 1 addition & 0 deletions config/_default/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ security:
- PULUMI_CONVERT_URL
- PULUMI_AI_WS_URL
- PULUMI_COPILOT_URL
- DEV_PULUMI_COPILOT_BASE_PATH
- GITHUB_TOKEN
- ALGOLIA_APP_ID
- ALGOLIA_APP_SEARCH_KEY
Expand Down
5 changes: 3 additions & 2 deletions layouts/partials/copilot/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ $copilotApiUrl := getenv "PULUMI_COPILOT_URL" }}
{{ if $copilotApiUrl }}
{{ $copilotBasePath := or (getenv "DEV_PULUMI_COPILOT_BASE_PATH") "/_pulumi/cloud-ai/" }}
<aside id="ai-sidebar-target"></aside>
<iframe id="ai-sidebar-host" src="/_pulumi/cloud-ai/sidebar?hostApp=docs&apiHost={{ $copilotApiUrl | urlquery }}"></iframe>
{{ end }}
<iframe id="ai-sidebar-host" src="{{ $copilotBasePath }}/sidebar?hostApp=docs&apiHost={{ $copilotApiUrl | urlquery }}"></iframe>
{{ end }}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"typescript": "^4.9.5"
},
"devDependencies": {
"express": "^4.21.0",
"http-proxy-middleware": "^3.0.2",
"husky": "^9.0.11",
"prettier": "^2.6.2"
}
Expand Down
36 changes: 36 additions & 0 deletions scripts/copilot-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const express = require("express");
const { createProxyMiddleware } = require("http-proxy-middleware");

const app = express();

app.use((req, res, next) => {
console.log(req.url);
next();
});

app.use(
"/cloud-ai",
createProxyMiddleware({
target: "http://localhost:3002/cloud-ai",
logger: console,
changeOrigin: true,
})
);

app.use(
createProxyMiddleware({
target: "http://127.0.0.1:1313",
logger: console,
changeOrigin: true,
})
);

app.use((req, res, next) => {
console.log(req.url);
next();
});

// Use a number for port, not a string
app.listen(1312, () => {
console.log("Listening! http://127.0.0.1:1312");
});
11 changes: 2 additions & 9 deletions theme/src/scss/_copilot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// Popovers on site use z-index: 20
z-index: 10;

// Default use up the full height of the viewport
top: 0;
// Default, make space for the navbar
top: calc(38px + 8px + 8px + 54px);
right: 0;
bottom: 0;
}
Expand All @@ -29,10 +29,3 @@
.section- #ai-sidebar-target {
top: 200px;
}

// Docs pages
// ---

.section-docs #ai-sidebar-target {
top: calc(38px + 8px + 8px + 54px);
}
Loading

0 comments on commit 7478610

Please sign in to comment.