Skip to content

Commit

Permalink
docs: add cors to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgarciaesgi committed Dec 14, 2024
1 parent dab6bc8 commit 423d046
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 12 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ export default defineConfig({
zod: `<svg xmlns='http://www.w3.org/2000/svg" width="1.27em" height="1em" viewBox="0 0 256 203"><defs><filter id="logosZod0" width="105.2%" height="106.5%" x="-2.2%" y="-2.8%" filterUnits="objectBoundingBox"><feOffset dx="1" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.36 0"/></filter><path id="logosZod1" fill="#000" d="M200.42 0H53.63L0 53.355l121.76 146.624l9.714-10.9L252 53.857zm-5.362 12.562l39.84 41.6l-112.8 126.558L17 54.162l41.815-41.6z"/></defs><g transform="translate(2 1.51)"><path fill="#18253f" d="M58.816 12.522h136.278l39.933 41.691l-112.989 126.553L16.957 54.213z"/><path fill="#274d82" d="M149.427 150.875H96.013l-24.124-29.534l68.364-.002l.002-4.19h39.078z"/><path fill="#274d82" d="M223.56 42.323L76.178 127.414l-19.226-24.052l114.099-65.877l-2.096-3.631l30.391-17.546zm-78.964-29.759L33.93 76.457L16.719 54.972l74.095-42.779z"/><use filter="url(#logosZod0)" href="#logosZod1"/><use fill="#3068b7" href="#logosZod1"/></g></svg>`,
},
}) as any,
{
name: 'add-cors',

configureServer(server) {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
next();
});
},
},
],
},
srcDir: './src',
Expand Down
10 changes: 6 additions & 4 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export default {
} satisfies Theme;

function scrollToActiveSidebarItem() {
const activeLink = document.querySelector('#VPSidebarNav div.is-link.is-active.has-active');
if (activeLink) {
activeLink.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
setTimeout(() => {
const activeLink = document.querySelector('#VPSidebarNav div.is-link.is-active.has-active');
if (activeLink) {
activeLink.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}, 1000);
}

0 comments on commit 423d046

Please sign in to comment.