Skip to content

Commit 99ac546

Browse files
authored
Merge pull request #306 from embedpdf/fix/latest-within-major
Latest within major
2 parents af56e96 + f813698 commit 99ac546

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

website/next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const snippetPackageJson = JSON.parse(
2222
readFileSync(resolve(__dirname, '../viewers/snippet/package.json'), 'utf8'),
2323
)
2424
const SNIPPET_VERSION = snippetPackageJson.version
25+
// Extract major version for CDN URL (e.g., "2.0.1" → "2")
26+
const SNIPPET_MAJOR_VERSION = SNIPPET_VERSION.split('.')[0]
2527

2628
/**
2729
* This plugin overrides the import source for the Tabs component to use the custom component
@@ -91,6 +93,7 @@ export default async (phase: string) => {
9193
const nextConfig: NextConfig = {
9294
env: {
9395
NEXT_PUBLIC_SNIPPET_VERSION: SNIPPET_VERSION,
96+
NEXT_PUBLIC_SNIPPET_MAJOR_VERSION: SNIPPET_MAJOR_VERSION,
9497
},
9598
// Mark Vue/Svelte example packages as external for server-side bundling
9699
serverExternalPackages: EXTERNAL_EXAMPLE_PACKAGES,
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Version is injected at build time from the snippet's package.json via next.config.ts
22
const EMBEDPDF_VERSION = process.env.NEXT_PUBLIC_SNIPPET_VERSION ?? '0.0.0'
3+
// Major version for CDN URL (e.g., "2" instead of "2.0.1")
4+
const EMBEDPDF_MAJOR_VERSION =
5+
process.env.NEXT_PUBLIC_SNIPPET_MAJOR_VERSION ?? '0'
36

4-
export const EMBEDPDF_JS_URL = `https://cdn.jsdelivr.net/npm/@embedpdf/snippet@${EMBEDPDF_VERSION}/dist/embedpdf.js`
7+
export const EMBEDPDF_JS_URL = `https://cdn.jsdelivr.net/npm/@embedpdf/snippet@${EMBEDPDF_MAJOR_VERSION}/dist/embedpdf.js`
58
export const DEMO_PDF_URL = 'https://snippet.embedpdf.com/ebook.pdf'

website/src/lib/rehype-cdn-urls.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const snippetPackageJson = JSON.parse(
1717
),
1818
)
1919
const EMBEDPDF_VERSION = snippetPackageJson.version
20+
// Extract major version for CDN URL (e.g., "2.0.1" → "2")
21+
const EMBEDPDF_MAJOR_VERSION = EMBEDPDF_VERSION.split('.')[0]
2022

21-
const EMBEDPDF_JS_URL = `https://cdn.jsdelivr.net/npm/@embedpdf/snippet@${EMBEDPDF_VERSION}/dist/embedpdf.js`
23+
const EMBEDPDF_JS_URL = `https://cdn.jsdelivr.net/npm/@embedpdf/snippet@${EMBEDPDF_MAJOR_VERSION}/dist/embedpdf.js`
2224
const DEMO_PDF_URL = 'https://snippet.embedpdf.com/ebook.pdf'
2325

2426
/**

0 commit comments

Comments
 (0)