Skip to content

Commit c9c03ed

Browse files
committed
Add profile support to capture and render tooling
source.profile field in manifest entries maps to `quarto render --profile`. Each profile creates a separate render group in capture.js so projects with multiple profiles get independent render cycles.
1 parent 5ad2814 commit c9c03ed

4 files changed

Lines changed: 20 additions & 28 deletions

File tree

tools/screenshots/capture.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ if (listOnly) {
7171
function groupBySource(shots) {
7272
const groups = new Map();
7373
for (const s of shots) {
74-
const key = s.source.type === 'example' ? s.source.project
74+
const key = s.source.type === 'example'
75+
? s.source.project + (s.source.profile ? `:${s.source.profile}` : '')
7576
: s.source.type === 'url' ? `url:${s.source.url}`
7677
: `local:${s.source.page || 'site'}`;
7778
if (!groups.has(key)) groups.set(key, []);
@@ -111,11 +112,14 @@ function startServer(dir) {
111112
}
112113

113114
// Render a Quarto project
114-
function renderProject(projectDir) {
115+
function renderProject(projectDir, profile) {
115116
const renderScript = join(TOOLS_DIR, 'scripts', 'render.js');
116-
console.log(` Rendering ${projectDir}...`);
117+
const profileLabel = profile ? ` (profile: ${profile})` : '';
118+
console.log(` Rendering ${projectDir}${profileLabel}...`);
117119
if (!dryRun) {
118-
execSync(`node "${renderScript}" "${projectDir}"`, { stdio: 'inherit' });
120+
const args = [renderScript, projectDir];
121+
if (profile) args.push('--profile', profile);
122+
execSync(`node ${args.map(a => `"${a}"`).join(' ')}`, { stdio: 'inherit' });
119123
}
120124
}
121125

@@ -248,7 +252,7 @@ async function main() {
248252
// Prepare source
249253
if (shots[0].source.type === 'example') {
250254
const projectDir = resolve(TOOLS_DIR, shots[0].source.project);
251-
renderProject(projectDir);
255+
renderProject(projectDir, shots[0].source.profile);
252256
const siteDir = join(projectDir, '_site');
253257
if (!dryRun) {
254258
server = await startServer(siteDir);
@@ -278,7 +282,8 @@ async function main() {
278282
if (!dryRun) {
279283
await page.goto(firstUrl, { waitUntil: 'domcontentloaded' });
280284
} else {
281-
console.log(` [dry-run] goto ${firstUrl}`);
285+
const profileLabel = shots[0].source.profile ? ` [profile: ${shots[0].source.profile}]` : '';
286+
console.log(` [dry-run] goto ${firstUrl}${profileLabel}`);
282287
}
283288

284289
for (const shot of shots) {

tools/screenshots/examples/about-pages/index.qmd

Lines changed: 0 additions & 5 deletions
This file was deleted.

tools/screenshots/examples/about-pages/jolla.qmd

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/screenshots/scripts/render.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ if (!existsSync(projectDir) || !statSync(projectDir).isDirectory()) {
1818
process.exit(1);
1919
}
2020

21+
const profileIdx = process.argv.indexOf('--profile');
22+
const profile = profileIdx !== -1 ? process.argv[profileIdx + 1] : null;
23+
2124
const quartoCmd = process.env.QUARTO_CMD || 'quarto';
22-
console.log(`Rendering: ${projectDir}`);
23-
execSync(`${quartoCmd} render "${projectDir}"`, { stdio: 'inherit' });
25+
const args = [quartoCmd, 'render', `"${projectDir}"`];
26+
if (profile) args.push('--profile', profile);
27+
28+
const profileLabel = profile ? ` (profile: ${profile})` : '';
29+
console.log(`Rendering: ${projectDir}${profileLabel}`);
30+
execSync(args.join(' '), { stdio: 'inherit' });
2431
console.log(`Done. Output in: ${projectDir}/_site/`);

0 commit comments

Comments
 (0)