Skip to content

Commit

Permalink
chore: use astro preview instead in build
Browse files Browse the repository at this point in the history
  • Loading branch information
sahithyandev committed Nov 7, 2024
1 parent 5bc63ad commit 57f9b73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
20 changes: 10 additions & 10 deletions plugins/generate-pdfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function waitForServer(url: string, timeout = 10000, interval = 500) {

export default function generatePdfsIntegration(): AstroIntegration {
let browser: Browser;
let devServer: ChildProcessWithoutNullStreams;
let previewServer: ChildProcessWithoutNullStreams;
/**
used to signal if the integration must do its work or not
*/
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function generatePdfsIntegration(): AstroIntegration {
},
"astro:build:done": async ({ dir, pages, logger }) => {
if (!isEnabled) return;
devServer = spawn("astro", ["dev"]);
previewServer = spawn("astro", ["preview"]);
const pagesToExport: string[] = [];
for (const page of pages) {
if (!page.pathname.startsWith("summary")) {
Expand Down Expand Up @@ -235,14 +235,14 @@ export default function generatePdfsIntegration(): AstroIntegration {
}),
);
await browser.close();
devServer.kill();
previewServer.kill();

// const summaryFolder = join(buildDir, "summary");
// rm(summaryFolder, {
// recursive: true,
// }).then(() => {
// logger.info(`deleted: ${summaryFolder}`);
// });
const summaryFolder = join(buildDir, "summary");
rm(summaryFolder, {
recursive: true,
}).then(() => {
logger.info(`deleted: ${summaryFolder}`);
});

await Promise.all(
pagesAdditionalInformations.map(async (pageInfo) => {
Expand All @@ -258,7 +258,7 @@ export default function generatePdfsIntegration(): AstroIntegration {
setMetadata(pdfDoc, pageInfo.meta);
setOutline(pdfDoc, pageInfo.outlines, false);
const updatedPdfDocBuffer = await pdfDoc.save();
return await writeFile(pageInfo.path, updatedPdfDocBuffer);
return writeFile(pageInfo.path, updatedPdfDocBuffer, {});
}),
);
},
Expand Down
7 changes: 2 additions & 5 deletions src/components/LiveUsersCount.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="live-users-count-container" class="gap-x-1 h-fit hidden dark:bg-gray-700 bg-blue-100 outline-blue-500 outline-2 outline cursor-grab rounded-md px-2 items-center" title="Currently active users">
<div id="live-users-count-container" class="gap-x-1 h-fit hidden dark:bg-gray-700 bg-blue-100 outline-blue-500 outline-2 outline rounded-md px-2 items-center" title="Currently active users">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-eye"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" /><path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" /></svg>
<span class="font-medium">
1
Expand All @@ -15,7 +15,6 @@
if (!countDisplay) {
return
}

const hideCountDisplay = () => {
container.classList.remove("flex");
container.classList.add("hidden");
Expand All @@ -24,7 +23,6 @@
container.classList.remove("hidden");
container.classList.add("flex");
}

const eventSource = new EventSource("//rando.sahithyan.dev/live-users-count?d=s1.sahithyan.dev", {
});
eventSource.addEventListener("message", function (event) {
Expand All @@ -43,6 +41,5 @@
eventSource.addEventListener("error",function () {
hideCountDisplay()
})

})()
</script>
</script>

0 comments on commit 57f9b73

Please sign in to comment.