Skip to content

Commit

Permalink
Merge pull request #63 from torontojs/chore/reformat
Browse files Browse the repository at this point in the history
Chore: reformat project
  • Loading branch information
madcampos authored Sep 28, 2024
2 parents c6d2ac3 + 4e7b6e7 commit 782c1fb
Show file tree
Hide file tree
Showing 82 changed files with 1,042 additions and 1,143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/astro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:

env:
BUILD_PATH: "." # default value when not using subfolders
# BUILD_PATH: subfolder
# BUILD_PATH: subfolder

jobs:
build:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Check detailed documentation on the project setup and how to get it running in [

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :--- | :--- |
| `npm install` | Installs all dependencies |
| `npm start` | Starts local dev server at [`https://localhost:3000/`](https://localhost:3000/) |
| `npm run build` | Build your production site to `./dist/` |
| `npm run lint` | Checks the project for errors and fix most of them |
| Command | Action |
| :-------------- | :------------------------------------------------------------------------------ |
| `npm install` | Installs all dependencies |
| `npm start` | Starts local dev server at [`https://localhost:3000/`](https://localhost:3000/) |
| `npm run build` | Build your production site to `./dist/` |
| `npm run lint` | Checks the project for errors and fix most of them |

Check detailed documentation on the commands available in [`src/content/docs/commands.md`](./src/content/docs/commands.md).

Expand Down
24 changes: 12 additions & 12 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { readFileSync } from 'node:fs';
import { assetsCache, externalResourcesCache, pagesCache, scriptsCache } from './src/sw-caching.ts';

const manifest: PwaOptions['manifest'] = JSON.parse(readFileSync('./src/manifest.json', {
encoding: 'utf8'
encoding: 'utf8'
}));

const mode = process.env['NODE_ENV'] === 'production' ? 'production' : 'development';
Expand All @@ -29,23 +29,23 @@ export default defineConfig({
},
...(mode !== 'production' && {
vite: {
server: {
https: {
cert: './certs/server.crt',
key: './certs/server.key'
server: {
https: {
cert: './certs/server.crt',
key: './certs/server.key'
}
}
}
}
}),
markdown: {
syntaxHighlight: 'shiki',
shikiConfig: {
theme: 'css-variables',
themes: {
light: 'light-plus',
dark: 'dark-plus'
},
wrap: true
theme: 'css-variables',
themes: {
light: 'light-plus',
dark: 'dark-plus'
},
wrap: true
}
},
integrations: [
Expand Down
4 changes: 2 additions & 2 deletions src/components/AuthorCard/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Avatar from '../Avatar/index.astro';
import './styles.css';
interface Props {
author: string
author: string;
}
const { author } = Astro.props;
Expand All @@ -24,7 +24,7 @@ const { Content } = await render();
<a class="p-author h-card" rel="author" itemprop="url" href={`${BLOG_URL}authors/${author}`}>
<h2 itemprop="name">{name}</h2>
</a>
{pronouns && (<small>{pronouns}</small>)}
{pronouns && <small>{pronouns}</small>}
</div>

<div class="author-bio">
Expand Down
37 changes: 17 additions & 20 deletions src/components/AuthorCard/styles.css
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
.author-card {
display: grid;
padding-inline: var(--size-3);
grid-template-columns: auto 1fr;
grid-template-rows: auto 1fr;
gap: var(--size-3);
place-items: center;
grid-template-areas:
"avatar name"
"avatar bio";
'avatar name'
'avatar bio';
grid-template-columns: auto 1fr;
grid-template-rows: auto 1fr;
margin: var(--size-3) 0;
padding-inline: var(--size-3);
place-items: center;
}

.author-card .author-name {
margin: 0;
color: var(--title-color);
text-shadow: var(--size-1) var(--size-1) var(--size-1) var(--gray-12);
text-decoration-color: var(--tjs-red-7);
text-underline-offset: var(--size-1);

grid-area: name;
justify-self: start;
margin: 0;
text-decoration-color: var(--tjs-red-7);
text-shadow: var(--size-1) var(--size-1) var(--size-1) var(--gray-12);
text-underline-offset: var(--size-1);
}

.author-card .author-picture {
grid-area: avatar;
align-self: start;
grid-area: avatar;
}

.author-card .author-bio {
grid-area: bio;
width: 100%;
place-self: start start;
width: 100%;
}

@media (max-width: 768px) {
.author-card {
grid-template-areas:
'avatar'
'name'
'bio';
grid-template-columns: 1fr;
grid-template-rows: 1fr auto auto;
grid-template-areas:
"avatar"
"name"
"bio";
}

.author-card .author-picture {
place-self: center center;
}
.author-card .author-picture { place-self: center center; }

.author-card .author-name {
justify-self: center;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Avatar/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Image } from 'astro:assets';
import './styles.css';
interface Props {
image: ImageMetadata,
imageAlt: string,
loading?: 'eager' | 'lazy'
image: ImageMetadata;
imageAlt: string;
loading?: 'eager' | 'lazy';
}
const { image: avatar, imageAlt: avatarAlt, loading } = Astro.props;
Expand Down
18 changes: 7 additions & 11 deletions src/components/Avatar/styles.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
.user-avatar {
--image-size: var(--size-13);

display: block;

width: var(--image-size);
height: var(--image-size);
aspect-ratio: var(--ratio-square);
border-radius: var(--radius-round);
overflow: hidden;
border: solid var(--title-color) var(--size-2);
border-radius: var(--radius-round);
box-shadow: var(--size-1) var(--size-1) var(--size-1) var(--gray-12);
display: block;
height: var(--image-size);
overflow: hidden;
width: var(--image-size);
}

.user-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
width: 100%;
}

@media (max-width: 768px) {
.user-avatar { --image-size: var(--size-12); }
}
@media (max-width: 768px) { .user-avatar { --image-size: var(--size-12); } }
102 changes: 0 additions & 102 deletions src/components/HtmlHead/index.astro
Original file line number Diff line number Diff line change
@@ -1,105 +1,3 @@
---
import { pwaInfo } from 'virtual:pwa-info';
import defaultSocialImage from '../../assets/icons/logo.svg';
import printStylesheet from './print.css?url';
interface Props {
htmlTitle?: string[],
title: string,
url: string,
description: string,
tags?: string[],
authors?: string[],
image?: string,
imageAlt?: string,
createdAt?: Date,
updatedAt?: Date,
hasFeed?: boolean
}
const {
htmlTitle, title, url,
description, tags,
authors,
image, imageAlt,
createdAt: publishedDate,
updatedAt: updatedDate,
hasFeed = false
} = Astro.props;
const BLOG_URL = Astro.site?.href;
const fullUrl = new URL(url, Astro.site).toString();
const socialImageAlt = imageAlt ?? 'Logo for TorontoJS, consisting of a red square with the letters &quot;JS&quot; in black on the left, and a sillouette of the CN Tower seen from the ground up on the right.';
const socialImage = `${BLOG_URL}${(image ?? defaultSocialImage.src).replace(/^\//iu, '')}`;
---
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<title>{htmlTitle?.join(' | ') ?? title}</title>

<!-- URLs -->
<link rel="canonical" href={fullUrl} />
<link rel="sitemap" href={`${BLOG_URL}sitemap-index.xml`} />
{ hasFeed && <link rel="alternate" type="application/rss+xml" href={`${BLOG_URL}feed.xml`} title="TorontoJS Blog" /> }

<!-- App Metadata -->
<link rel="icon" href={`${BLOG_URL}icons/icon.svg`} sizes="any" type="image/svg+xml" />
<meta name="theme-color" content="#ee2e24" />
<link rel="license" href={`${BLOG_URL}license`} />

{/* eslint-disable-next-line astro/no-set-html-directive */}
{pwaInfo && (<Fragment set:html={pwaInfo.webManifest.linkTag} />)}

<!-- Social metadata -->
<meta property="og:title" name="twitter:title" itemprop="name" content={title} />

<meta property="og:type" content={hasFeed ? 'article' : 'website'} />
<meta name="twitter:card" content={socialImage ? 'summary_large_image' : 'summary'} />

<meta property="og:locale" itemprop="inLanguage" content="en_US" />
<meta property="og:url" itemprop="url" content={fullUrl} />

<meta property="og:description" name="description" itemprop="abstract" content={description} />
<meta name="twitter:description" content={description} />

<meta property="og:image" name="twitter:image" itemprop="image" content={socialImage} />
<meta property="og:image:alt" name="twitter:image:alt" content={socialImageAlt} />

{authors?.map((author) => (
<>
<meta property="article:author" name="author" content={author} />
<meta name="twitter:creator" content={author} />
<!-- TODO: fix to specifically reference to twitter handle -->
</>
))}

<meta name="twitter:dnt" content="on" />
<meta name="twitter:widgets:csp" content="on" />
<meta name="twitter:widgets:autoload" content="off" />
<meta name="twitter:widgets:theme" content="dark" />

<meta name="generator" content={Astro.generator} />

{tags && (<meta name="keywords" itemprop="keywords" property="article:tag" content={tags.join(', ')} />)}
{publishedDate && (<meta property="article:published_time" content={publishedDate.toISOString()} />)}
{updatedDate && (<meta property="article:modified_time" content={updatedDate.toISOString()} />)}

<!-- Changelog -->
<link rel="alternate" type="application/rss+xml" href={`${BLOG_URL}changelog.xml`} title="Changelog (Version History)" />

<!-- Apple icons -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

<!-- Print Stylesheet -->
<link rel="stylesheet" type="text/css" href={printStylesheet} media="print" />

<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,700|Inter:400,700" rel="stylesheet" />
</head>
28 changes: 7 additions & 21 deletions src/components/HtmlHead/print.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@media print {
:root {
--body-text: 12pt;

color-scheme: light;
}

Expand All @@ -10,42 +9,29 @@
margin-inline: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
page-break-after: avoid;
}
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }

p, li, blockquote, figure, img, pre .line {
page-break-inside: avoid;
}
p, li, blockquote, figure, img, pre .line { page-break-inside: avoid; }

a {
text-decoration: underline;
}
a { text-decoration: underline; }

a:not(:has(> :is(img, picture)))[href]::after {
content: ' (' attr(href) ')';
font-size: smaller;
}

a[rel~='external']::after {
background: none;
display: inline;
font-size: smaller;
background: none;
vertical-align: baseline;
}

iframe { display: none; }

#post-share {
/* stylelint-disable-next-line declaration-no-important */
display: none !important;
}
#post-share { /* stylelint-disable-next-line declaration-no-important */ display: none !important; }

#related-posts ul {
flex-wrap: wrap;
}
#related-posts ul { flex-wrap: wrap; }

#post-contents p > img:only-child {
--image-size: 10rem;
}
#post-contents p > img:only-child { --image-size: 10rem; }
}
Loading

0 comments on commit 782c1fb

Please sign in to comment.