mirror of
https://github.com/tjsga/tj-sga-website-react.git
synced 2025-04-21 12:00:17 -04:00
Better spacing, external links open in new windows
This commit is contained in:
parent
84fd33fffe
commit
22d038e17e
|
@ -18,7 +18,7 @@ export default function ArticleRow({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='d-flex'>
|
<div className='d-flex my-4'>
|
||||||
<div className='article-row-thumbnail'>
|
<div className='article-row-thumbnail'>
|
||||||
{thumbUrl ? <img src={thumbUrl} alt={article.title} /> : null}
|
{thumbUrl ? <img src={thumbUrl} alt={article.title} /> : null}
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,6 +26,7 @@ export default function ArticleRow({
|
||||||
<Link
|
<Link
|
||||||
to={'/news/' + article._id + '/' + slug(article.title)}
|
to={'/news/' + article._id + '/' + slug(article.title)}
|
||||||
className='clickable-link'
|
className='clickable-link'
|
||||||
|
target='_blank'
|
||||||
>
|
>
|
||||||
<h3 style={{ margin: '0px' }}>{article.title}</h3>
|
<h3 style={{ margin: '0px' }}>{article.title}</h3>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
@ -16,10 +16,20 @@ let pages = [
|
||||||
{ url: '/class-council', title: 'Class Council' },
|
{ url: '/class-council', title: 'Class Council' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
url: '#',
|
||||||
|
title: 'News',
|
||||||
|
items: [
|
||||||
{
|
{
|
||||||
url: '/news',
|
url: '/news',
|
||||||
title: 'News',
|
title: 'News',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
url: '#',
|
||||||
|
title: 'Newsletter (In development!)',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
url: '/initiatives',
|
url: '/initiatives',
|
||||||
title: 'Initiatives',
|
title: 'Initiatives',
|
||||||
|
@ -72,14 +82,39 @@ export default function Navbar() {
|
||||||
</Link>
|
</Link>
|
||||||
<div className='submenu-content'>
|
<div className='submenu-content'>
|
||||||
{/* Most of these are external so we use <a> tags instead of <Link> */}
|
{/* Most of these are external so we use <a> tags instead of <Link> */}
|
||||||
{page.items?.map((item) => (
|
{page.items?.map((item) => {
|
||||||
|
let isExternal = /https?:\/\//.test(item.url);
|
||||||
|
if (isExternal) {
|
||||||
|
// Treat external links differently; add 'target=_blank' so they
|
||||||
|
// open in a new window
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
<a key={item.url} className='submenu-link' href={item.url}>
|
<a
|
||||||
|
key={item.url}
|
||||||
|
className='submenu-link'
|
||||||
|
href={item.url}
|
||||||
|
target='_blank'
|
||||||
|
rel='noreferrer'
|
||||||
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
))}
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Link
|
||||||
|
key={item.url}
|
||||||
|
className='submenu-link'
|
||||||
|
to={item.url}
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
</Link>
|
||||||
|
<br />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import imageUrlBuilder from '@sanity/image-url';
|
|
||||||
import sanity from './sanity';
|
|
||||||
|
|
||||||
const builder = imageUrlBuilder(sanity);
|
|
||||||
export default function imageUrl(source) {
|
|
||||||
return builder.image(source);
|
|
||||||
}
|
|
12
src/imageUrl.ts
Normal file
12
src/imageUrl.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { default as ImageUrlBuilder } from '@sanity/image-url';
|
||||||
|
import sanity from './sanity';
|
||||||
|
|
||||||
|
const builder = ImageUrlBuilder(sanity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a URL for an image based on specified attributes
|
||||||
|
* @param {SanityImageSource} source The source image
|
||||||
|
*/
|
||||||
|
export default function imageUrl(source: any): any {
|
||||||
|
return builder.image(source);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user