Skip to content

Commit

Permalink
Merge pull request #633 from dgrebb/feature/618-post-publish-update-d…
Browse files Browse the repository at this point in the history
…ates

feat(front): adds published/updated times to post component
  • Loading branch information
dgrebb authored Sep 7, 2023
2 parents 51d7010 + 14f7f8a commit f4531f3
Show file tree
Hide file tree
Showing 45 changed files with 74 additions and 32 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/bd-fe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
build_deploy:
name: 🚜 Build & Deploy to ${{ github.ref_name == 'main' && 'PRD' || 'STG' }}
runs-on: ubuntu-latest
concurrency:
group: build-deploy
cancel-in-progress: true

environment:
name: ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
Expand Down Expand Up @@ -99,8 +102,6 @@ jobs:
repository: dgrebb/dgrebb.com
ref: ${{ github.ref }}
token: ${{ github.token }}
sparse-checkout: |
front

- name: 📐 Set Environment
env:
Expand Down Expand Up @@ -140,16 +141,18 @@ jobs:
run: |
cd front
if [ ${{ github.ref_name }} == 'main' ]; then
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
DEPLOY_ENV=$DEPLOY_ENV
RELEASE_NAME=${{ env.RELEASE_NAME }}
DIST=${{ env.DIST }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
DEPLOY_ENV=$DEPLOY_ENV \
UPLOAD_SOURCEMAPS=true \
RELEASE_NAME=${{ env.RELEASE_NAME }} \
DIST=${{ env.DIST }} \
npm run build
else
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
DEPLOY_ENV=$DEPLOY_ENV
RELEASE_NAME=${{ env.RELEASE_NAME }}
DIST=${{ env.DIST }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
DEPLOY_ENV=$DEPLOY_ENV \
UPLOAD_SOURCEMAPS=true \
RELEASE_NAME=${{ env.RELEASE_NAME }} \
DIST=${{ env.DIST }} \
npm run build.s
fi
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dispatch-bd-fe--cms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
issues: write
concurrency:
group: cms-publish
cancel-in-progress: true

steps:
- name: ✓ Approve CMS Dispatch
Expand All @@ -28,7 +31,8 @@ jobs:
steps:
- name: 🛰️ Dispatch B&D FE
run: |
curl -X POST https://api.github.com/repos/dgrebb/dgrebb.com/actions/workflows/bd-fe.yml/dispatches \
curl --location 'https://api.github.com/repos/dgrebb/dgrebb.com/actions/workflows/bd-fe.yml/dispatches' \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ secrets.DISPATCH_TOKEN }}' \
--data '{"ref": "${{ github.ref_name }}"}'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions _utils/_scripts/front.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ while test "$1" != --; do
bx | bx)
setFrontEnv ${env}
branch=$(git branch --show-current)
DIST=$(date +%y%m%d-%H%M%S)
RELEASE_NAME=dev-$(sed "s/\//-/g" <<< "$branch")
DEPLOY_ENV=development
cdfront && UPLOAD_SOURCEMAPS=true \
RELEASE_NAME=$RELEASE_NAME DIST=$DIST \
DEPLOY_ENV=$DEPLOY_ENV npm run build.${env}
cdfront &&
SENTRY_AUTH_TOKEN=$(pass dg/sentry/authtoken) \
DIST=$(date +%y%m%d-%H%M%S) \
RELEASE_NAME=dev-$(sed "s/\//-/g" <<<"$branch") \
DEPLOY_ENV=development \
UPLOAD_SOURCEMAPS=true \
RELEASE_NAME=$RELEASE_NAME DIST=$DIST \
DEPLOY_ENV=$DEPLOY_ENV npm run build.${env}
break
;;
s | http-server)
pwd
cdfront && sudo http-server -b -S -p 443 -a local.dgrebb.com \
-C local.dgrebb.com.crt -K local.dgrebb.com.key \
--cors='*' ./build
-C local.dgrebb.com.crt -K local.dgrebb.com.key \
--cors='*' ./build
break
;;
p | preview)
Expand Down
20 changes: 10 additions & 10 deletions _utils/dg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ while test "$1" != --; do
break
;;
f | front)
/bin/bash $directory/_scripts/front.sh $2 $3
/bin/bash $directory/_scripts/front.sh $2 $3 $4
break
;;
d | docker)
Expand All @@ -48,39 +48,39 @@ while test "$1" != --; do
/bin/bash $directory/_scripts/bump.sh
break
;;
g | github )
g | github)
open https://github.com/dgrebb/dgrebb.com
break
;;
gp | github-project )
gp | github-project)
open https://github.com/users/dgrebb/projects/12
break
;;
a | act )
a | act)
/bin/bash $directory/_scripts/act.sh $2 $3
break
;;
tp | test-performance | lighthouse )
tp | test-performance | lighthouse)
/bin/bash $directory/_scripts/perf.sh $2
break
;;
tv | test-visual | backstop )
tv | test-visual | backstop)
/bin/bash $directory/_scripts/visual-regression.sh test $2
break
;;
tvt | test-visual-skip-build | backstop-test )
tvt | test-visual-skip-build | backstop-test)
/bin/bash $directory/_scripts/visual-regression.sh test-now $2
break
;;
tvr | test-visual-remote-service | backstop-remote )
tvr | test-visual-remote-service | backstop-remote)
/bin/bash $directory/_scripts/visual-regression.sh remote $2
break
;;
tvref | test-visual-ref | backstop-reference )
tvref | test-visual-ref | backstop-reference)
/bin/bash $directory/_scripts/visual-regression.sh ref $2
break
;;
tva | test-visual-approve | backstop-approve )
tva | test-visual-approve | backstop-approve)
/bin/bash $directory/_scripts/visual-regression.sh approve $2
break
;;
Expand Down
6 changes: 3 additions & 3 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"preview": "vite --config vite.config.js preview",
"preview.local": "vite --config vite.local.config.js preview",
"postinstall": "patch-package",
"postbuild.l": "npx svelte-sitemap -i '404' -i 'shingle' --domain https://local.dgrebb.com",
"postbuild.s": "npx svelte-sitemap -i '404' -i 'shingle' --domain https://stg.dgrebb.com",
"postbuild": "npx svelte-sitemap -i '404' -i 'shingle' --domain https://www.dgrebb.com"
"postbuild.l": "npx svelte-sitemap -i '404' -i 'shingle' -t --attribution=false --domain https://local.dgrebb.com",
"postbuild.s": "npx svelte-sitemap -i '404' -i 'shingle' -t --attribution=false --domain https://stg.dgrebb.com",
"postbuild": "npx svelte-sitemap -i '404' -i 'shingle' -t --attribution=false --domain https://www.dgrebb.com"
},
"devDependencies": {
"@accuser/svelte-plausible-analytics": "github:dgrebb/svelte-plausible-analytics#release/v0.6.0",
Expand Down
25 changes: 25 additions & 0 deletions front/src/lib/components/posts/Post.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import slugger from 'slugger';
import SvelteMarkdown from 'svelte-markdown';
export let publishedAt;
export let updatedAt;
export let title;
export let summary;
export let content;
Expand All @@ -16,6 +18,19 @@
export let related;
export let pathname;
const pub = new Date(publishedAt).toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: '2-digit',
});
const up = updatedAt
? new Date(updatedAt).toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: '2-digit',
})
: false;
let toc, postNavCheckbox, miniPostNav;
$: toc = [];
function filterTokens(event) {
Expand Down Expand Up @@ -51,11 +66,21 @@
};
</script>

<svelte:head>
<meta name="date" content={publishedAt} />
{#if updatedAt}<meta name="date_modified" content={updatedAt} />{/if}
</svelte:head>

{#if (contents && contents.length) || (categories && categories.length) || (related && related.length)}
<PageNav {contents} {categories} {related} {pathname} mini {setActiveLink} />
{/if}
<h1 class="post-title">{title}</h1>
<article class="post-article" class:full={!showAside}>
<time
class="pubdate"
datetime={publishedAt}
title={updatedAt ? `Updated ${up}` : false}>{pub}</time
>
{#if summary}
<p class="summary">{summary}</p>
{/if}
Expand Down
4 changes: 4 additions & 0 deletions front/src/lib/styles/pages/post.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
line-height: 1.2;
}
}
.pubdate {
color: rgba(var(--text-accent-rgb), 0.77);
font-size: 1rem;
}
.aside-toggle {
display: inline;
float: right;
Expand Down
3 changes: 3 additions & 0 deletions front/src/routes/post/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
: false;
$: heroImage = hero?.url ? hero.url : false;
$: position = post.position || 'center center';
$: ({ publishedAt, updatedAt } = post);
$: summary = post.summary || false;
$: content = post?.content?.length ? post.content : false;
$: footnotes = post.footnotes.length ? post.footnotes : false;
Expand Down Expand Up @@ -57,6 +58,8 @@
{/if}
<a id="main">Main Content</a>
<Post
{publishedAt}
{updatedAt}
{title}
{summary}
{content}
Expand Down
1 change: 1 addition & 0 deletions front/vite.local.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default defineConfig({
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
authToken: process.env.SENTRY_AUTH_TOKEN,
uploadSourceMaps: process.env.UPLOAD_SOURCEMAPS || false,
telemetry: false,
debug: true,
Expand Down

0 comments on commit f4531f3

Please sign in to comment.