Bundle docs CDN assets locally for full offline support (#2473)

* docs: bundle CDN assets locally for full offline support

* fix

* fix

* fix

* revert accidental package-lock.json changes

---------

Co-authored-by: Reynaldi Chernando <reynaldichernando@gmail.com>
This commit is contained in:
Jatin Sharma
2026-02-14 00:44:46 +05:30
committed by GitHub
parent 809d375854
commit 9a47bf16da
8 changed files with 33 additions and 10 deletions
+9 -5
View File
@@ -315,11 +315,11 @@ function generateDocsHTML (filePath, rootDir, page, isIndex = false) {
<meta name="theme-color" content="#ffffff">
`;
// CSS
html += '<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">';
html += `<link rel="stylesheet" href="/${baseURL}/assets/js/bundle.css">`;
html += `<link rel="stylesheet" href="/${baseURL}/assets/css/bootstrap.min.css">`;
html += '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">';
html += `<link rel="stylesheet" href="/${baseURL}/assets/css/style.css">`;
// JS
html += `<script src="/${baseURL}/assets/js/bundle.js"></script>`;
html += `
<script type="application/ld+json">
{
@@ -330,8 +330,6 @@ function generateDocsHTML (filePath, rootDir, page, isIndex = false) {
}
</script>
`;
html += '<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>';
html += '<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>';
html += '<script defer data-domain="docs.puter.com" src="https://plausible.io/js/script.js"></script>';
html += `
<script type="text/javascript">
@@ -491,7 +489,6 @@ function generateDocsHTML (filePath, rootDir, page, isIndex = false) {
html += generateSearchUIHTML();
html += `<script src="/${baseURL}/assets/js/bundle.js"></script>`;
html += '</body>';
const relativeDir = path.relative(rootDir, path.dirname(filePath));
const newDir = path.join(rootDir, '..', 'dist', relativeDir, path.basename(filePath, '.md'));
@@ -572,6 +569,13 @@ async function generateDocumentation (rootDir) {
minify: true,
sourcemap: true,
allowOverwrite: true,
loader: {
'.woff': 'dataurl',
'.woff2': 'dataurl',
'.ttf': 'dataurl',
'.eot': 'dataurl',
'.svg': 'dataurl',
},
});
} catch ( error ) {
console.error(error);
+3
View File
@@ -14,8 +14,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"@fontsource/inter": "^5.2.8",
"fs-extra": "^11.2.0",
"highlight.js": "^11.11.1",
"html-entities": "^2.3.3",
"jquery": "^4.0.0",
"js-yaml": "^4.1.0",
"jsdom": "^26.1.0",
"marked": "^11.1.1"
+3 -1
View File
@@ -1,4 +1,6 @@
jQuery(document).ready(function () {
import $ from 'jquery';
$(document).ready(function () {
// Dropdown toggle functionality
$(document).on('click', '.dropdown-button', function (e) {
e.preventDefault();
+3 -1
View File
@@ -1,3 +1,5 @@
import $ from 'jquery';
const icons = {
ai_outline: '<svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles-icon lucide-sparkles"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"/><path d="M20 2v4"/><path d="M22 4h-4"/><circle cx="4" cy="20" r="2"/></svg>',
ai_active: '<svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles-icon lucide-sparkles"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"/><path d="M20 2v4"/><path d="M22 4h-4"/><circle cx="4" cy="20" r="2"/></svg>',
@@ -11,7 +13,7 @@ const icons = {
auth_active: '<svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-lock-icon lucide-user-lock"><circle cx="10" cy="7" r="4"/><path d="M10.3 15H7a4 4 0 0 0-4 4v2"/><path d="M15 15.5V14a2 2 0 0 1 4 0v1.5"/><rect width="8" height="5" x="13" y="16" rx=".899"/></svg>',
};
jQuery(document).ready(function () {
$(document).ready(function () {
// add icons to .icon elements
$('.example-group').each(function () {
$(this).find('.icon').html(icons[$(this).data('icon')]);
+6
View File
@@ -1,5 +1,11 @@
import hljs from 'highlight.js';
import 'highlight.js/styles/default.css';
import '@fontsource/inter';
import './router.js';
import './search.js';
import './context-menu.js';
import './example.js';
import './sidebar.js';
window.hljs = hljs;
+3 -1
View File
@@ -1,4 +1,6 @@
jQuery(document).ready(function () {
import $ from 'jquery';
$(document).ready(function () {
//History API
if ( window.history && window.history.pushState ) {
// Initialize state for the first page
+3 -1
View File
@@ -1,3 +1,5 @@
import $ from 'jquery';
// Global search index
let searchIndex = [];
let searchTimeout = null;
@@ -5,7 +7,7 @@ let selectedSearchResult = -1;
const commandIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-command-icon lucide-command"><path d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"/></svg>';
jQuery(document).ready(function () {
$(document).ready(function () {
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
const shortcut = isMac ? `${commandIcon}&nbsp;<span>K</span>` : 'Ctrl K';
+3 -1
View File
@@ -1,4 +1,6 @@
jQuery(document).ready(function () {
import $ from 'jquery';
$(document).ready(function () {
//when doc is loaded scroll side nav to active section
$('#sidebar').scrollTop($('#sidebar').scrollTop() + $('#sidebar a.active').position()?.top
- $('#sidebar').height() / 2 + $('#sidebar a.active').height() / 2);