Skip to content

Commit

Permalink
Merge pull request #416 from adobe/svg
Browse files Browse the repository at this point in the history
feat(scripts): allow svg in default content
  • Loading branch information
trieloff authored Nov 16, 2023
2 parents b67d059 + 89482d0 commit 70077f0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,24 @@ export function setUpSideNav(main, aside) {
return loadBlock(sideNav);
}

function decorateSVGs(main) {
// get all links that end with .svg
const svgLinks = main.querySelectorAll('a[href$=".svg"]');
Array.from(svgLinks).forEach((svg) => {
const svgHref = new URL(svg.href).pathname;

const svgEl = createTag('img', {
src: svgHref,
// use the path name as the alt text
alt: svgHref.split('/').pop().split('.')[0],
width: '100%',
// class: 'logo-wall-item-svg',
});

svg.replaceWith(svgEl);
});
}

// --------------- Main functions here ---------------- //

/**
Expand Down Expand Up @@ -538,6 +556,7 @@ export function decorateMain(main) {
decorateGuideTemplate(main);
decorateBlocks(main);
decorateTitleSection(main);
decorateSVGs(main);
}

function prepareSideNav(main) {
Expand Down

0 comments on commit 70077f0

Please sign in to comment.