Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to pages and posts #342

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion public/css/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/base.css.map

Large diffs are not rendered by default.

163 changes: 163 additions & 0 deletions public/css/print.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/css/print.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/js/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/dist/main.js.map

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions public/js/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,35 @@ export function breakLinksAtSlash(root = document.querySelector('main')) {
}
}

/**
* Function that attempts to add the author metadata to the header
* of the page; it won't work all the time, but it gives it a bit of a
* better shot of getting it right
*/
function addAuthor(){
const content = document.querySelector('.blog-content');
const children = content.children;
const authorRex = /\s*Authored\s*by:\s*/gi;
const titleMeta = document.querySelector('meta[name="citation_title"]');
let bylineEl = [...children].find(el => {
return authorRex.test(el.innerText);
});
if (!bylineEl){
return;
}
let byline = bylineEl.innerText.trim();
let bylineNorm = byline.replace(authorRex,'').replace(' and ',',');
let names = bylineNorm.split(/,+\s*/gi);
names.forEach(name => {
let parts = name.split(/\s+/);
let nameArr = [parts.pop(), parts.join(' ')];
if (nameArr.length > 0){
let authorMeta = `<meta name="citation_author" content="${nameArr.join(', ')}"/>`;
titleMeta.insertAdjacentHTML('beforebegin', authorMeta);
}
});
}

/**
* Driver
*/
Expand All @@ -221,5 +250,6 @@ export function breakLinksAtSlash(root = document.querySelector('main')) {
let blogContent = document.querySelector('.blog-content');
if (blogContent){
blogContent.querySelectorAll('img').forEach(cleanStyles);
addAuthor();
}
})();
15 changes: 15 additions & 0 deletions public/sass/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,19 @@ a.btn-primary {
.open > .dropdown-toggle.btn-default:hover {
color: $color_white;
background-color: #1f1f1f ;
}

.icon-button{
border:none;
appearance:none;
box-shadow:none;
background:none;
height:2.5rem;
width:2.5rem;
a{
all:unset;
display:block;
height:100%;
width:100%;
}
}
20 changes: 16 additions & 4 deletions public/sass/pages/_nines.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,32 @@

// Standard content block
.blog-content{
--padding-right: 5rem;
max-width: $reading-width;
font-family: $serif;
margin:0 auto;
background: $color_white;
border: 1px solid #F2F2F2;
box-shadow: $box-shadow-sm;
padding: 2rem 5rem 4.5rem 5rem;
background: $color_white;
border: 1px solid #F2F2F2;
box-shadow: $box-shadow-sm;
padding: 2rem var(--padding-right) 4.5rem 5rem;
position:relative;
.icon-button{
position:absolute;
left:100%;
transform: translateX(-150%);
& + *{
margin-top:0;
}
}

@media (max-width: $breakpoint_sm){
padding-left: 2rem;
padding-right:2rem;
}
& > * + *{
margin-top:ms(1);
}

}

// Normal paragraphs
Expand Down
Loading