Skip to content

Commit 2de0f45

Browse files
authored
#105 Update all image paths linked to /wp-content/* (#107)
* enable mdx plugin in the config file / make sure .mdx file works * turn some .md files into .mdx and use resolvePath() in them * add an inline comment for the footnote logic
1 parent 1cfd7b7 commit 2de0f45

12 files changed

+191
-161
lines changed

astro.config.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import mdx from '@astrojs/mdx';
33
import sitemap from '@astrojs/sitemap';
44
import remarkBreaks from 'remark-breaks'; // improves support for newlines in markdown files
55
import remarkGfm from 'remark-gfm'; // support rendering tables in markdown files
6+
import remarkMath from 'remark-math';
7+
import rehypeKatex from 'rehype-katex';
68
// twitter & youtube auto-embed via remark
79
import remarkEmbedder from '@remark-embedder/core';
810
import oembedTransformer from '@remark-embedder/transformer-oembed';
@@ -37,13 +39,12 @@ export default defineConfig({
3739
base: IS_PROD_BUILD === 'true' ? "/" : '/groupincome.org',
3840
// integrations: [mdx(), sitemap(), vue()],
3941
integrations: [
42+
mdx(),
4043
sitemap(),
4144
vue({ appEntrypoint: '/src/_app' })
4245
],
4346
markdown: {
44-
remarkPlugins: [remarkEmbedPlugin, remarkGfm, remarkBreaks, 'remark-math'],
45-
rehypePlugins: [['rehype-katex', {
46-
// Katex plugin options
47-
}]]
47+
remarkPlugins: [remarkEmbedPlugin, remarkGfm, remarkBreaks, remarkMath],
48+
rehypePlugins: [[rehypeKatex, {}]]
4849
}
4950
});

src/pages/[...blog].astro

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,59 +19,68 @@ const { Content } = Astro.props
1919
<Content />
2020

2121
<script>
22-
const footnoteEl = document.querySelector('section.footnotes')
22+
window.addEventListener('DOMContentLoaded', () => {
23+
// When this script is executed for any blog posts that are written as .mdx format, the logic inside prepFootnotes() does not work for some reason.
24+
// But giving it a reasonable amount of delay ensures it consistently works for both .md and .mdx blog posts.
25+
// (reference: https://github.com/okTurtles/groupincome.org/pull/107#discussion_r1547356061)
26+
setTimeout(prepFootnotes, 100)
27+
})
2328

24-
// NOTE:
25-
// below is a logic to resolve a foonotes related bug(https://github.com/okTurtles/groupincome.org/issues/92)
26-
// which is when links are clicked, the page is not scrolled to the correct positions.
27-
if (footnoteEl) {
28-
const footnoteAnchorSel = 'a[data-footnote-ref]' // selector for an anchor tag linked to a footnote.
29-
const footnoteBackSel = 'a[data-footnote-backref]' // selector for the 'back' anchor tag within a footnote.
30-
const footnoteAnchors = Array.from(document.querySelectorAll(footnoteAnchorSel)) as HTMLAnchorElement[]
31-
const footnoteBackEls = Array.from(document.querySelectorAll(footnoteBackSel)) as HTMLAnchorElement[]
32-
const calcFloatingContents = (): number => {
33-
// calculate the total height of the 'position: fixed' contents of the page.
34-
// currently there is two UI components like that: 'fundraiser-banner', 'header-toolbar'
35-
const floatingEls = ['.fundraiser', '.c-header-wrapper']
36-
let totalHeight = 0
29+
function prepFootnotes () {
30+
const footnoteEl = document.querySelector('section.footnotes')
3731

38-
floatingEls.forEach(sel => {
39-
const el = document.querySelector(sel)
32+
// NOTE:
33+
// below is a logic to resolve a foonotes related bug(https://github.com/okTurtles/groupincome.org/issues/92)
34+
// which is when links are clicked, the page is not scrolled to the correct positions.
35+
if (footnoteEl) {
36+
const footnoteAnchorSel = 'a[data-footnote-ref]' // selector for an anchor tag linked to a footnote.
37+
const footnoteBackSel = 'a[data-footnote-backref]' // selector for the 'back' anchor tag within a footnote.
38+
const footnoteAnchors = Array.from(document.querySelectorAll(footnoteAnchorSel)) as HTMLAnchorElement[]
39+
const footnoteBackEls = Array.from(document.querySelectorAll(footnoteBackSel)) as HTMLAnchorElement[]
40+
const calcFloatingContents = (): number => {
41+
// calculate the total height of the 'position: fixed' contents of the page.
42+
// currently there is two UI components like that: 'fundraiser-banner', 'header-toolbar'
43+
const floatingEls = ['.fundraiser', '.c-header-wrapper']
44+
let totalHeight = 0
4045

41-
if (el) {
42-
const bbox = el.getBoundingClientRect()
43-
totalHeight += bbox.height
46+
floatingEls.forEach(sel => {
47+
const el = document.querySelector(sel)
48+
49+
if (el) {
50+
const bbox = el.getBoundingClientRect()
51+
totalHeight += bbox.height
52+
}
53+
})
54+
55+
return totalHeight
56+
}
57+
const getAdjustedTargetScrollPosition = (targetId: string): number => {
58+
// get adjusted scroll-Y value of the target element of an anchor tag.
59+
// 'adjusted' here means subtracting the total heights of the floating contents of the page.
60+
const targetEl = document.querySelector(`#${targetId}`)
61+
if (targetEl) {
62+
const bbox = targetEl.getBoundingClientRect()
63+
return bbox.top + document.documentElement.scrollTop - calcFloatingContents()
4464
}
45-
})
65+
return 0
66+
}
67+
const addClickHandlerWithAdjustment = (aTag: HTMLAnchorElement) => {
68+
const href = aTag.href as string
69+
const targetId = href ? href.split('#')[1] : ''
4670

47-
return totalHeight
48-
}
49-
const getAdjustedTargetScrollPosition = (targetId: string): number => {
50-
// get adjusted scroll-Y value of the target element of an anchor tag.
51-
// 'adjusted' here means subtracting the total heights of the floating contents of the page.
52-
const targetEl = document.querySelector(`#${targetId}`)
53-
if (targetEl) {
54-
const bbox = targetEl.getBoundingClientRect()
55-
return bbox.top + document.documentElement.scrollTop - calcFloatingContents()
56-
}
57-
return 0
58-
}
59-
const addClickHandlerWithAdjustment = (aTag: HTMLAnchorElement) => {
60-
const href = aTag.href as string
61-
const targetId = href ? href.split('#')[1] : ''
71+
aTag.addEventListener('click', e => {
72+
e.preventDefault()
6273

63-
aTag.addEventListener('click', e => {
64-
e.preventDefault()
74+
const targetPositionY = getAdjustedTargetScrollPosition(targetId)
75+
if (targetPositionY > 0) {
76+
window.scrollTo({ top: targetPositionY, behavior: 'instant' })
77+
}
78+
})
79+
}
6580

66-
const targetPositionY = getAdjustedTargetScrollPosition(targetId)
67-
if (targetPositionY > 0) {
68-
window.scrollTo({ top: targetPositionY, behavior: 'instant' })
69-
}
70-
})
81+
footnoteAnchors.forEach(addClickHandlerWithAdjustment)
82+
footnoteBackEls.forEach(addClickHandlerWithAdjustment)
7183
}
72-
73-
footnoteAnchors.forEach(addClickHandlerWithAdjustment)
74-
footnoteBackEls.forEach(addClickHandlerWithAdjustment)
7584
}
7685
</script>
7786

src/posts/a-reliable-safety-net-for-small-communities.md renamed to src/posts/a-reliable-safety-net-for-small-communities.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permalink: /2020/07/a-reliable-safety-net-for-small-communities/
1313
categories:
1414
- Uncategorized
1515
---
16+
import { resolvePath } from '@/utils/helpers.js'
1617

1718
As misfortunes don't seem to come singly in 2020, the [COVID-19 pandemic](https://www.who.int/emergencies/diseases/novel-coronavirus-2019) is magnifying [social and economic inequality](https://graduateinstitute.ch/coronavirus-information-our-community-and-visitors/covid-19-magnifier-social-inequality) and accelerating an [economic collapse](https://www.cnbc.com/2020/06/29/nearly-half-the-us-population-is-without-a-job-showing-how-far-the-labor-recovery-has-to-go.html). As an answer, some people are [demanding disruptive change](https://www.chicagoreader.com/chicago/police-abolitionist-movement-alternatives-cops-chicago/Content?oid=23289710), because governments have been slow and [unsatisfactory in their response](https://www.ohchr.org/en/NewsEvents/Pages/DisplayNews.aspx?NewsID=25793&amp;LangID=E). There are several viewpoints on how to address these issues, but we came down to a dilemma: Should we rely on malfunctioning governments to be the answer? Or should we be resourceful and find tools, like Group Income, to build safety nets for ourselves and our communities?
1819

@@ -28,7 +29,7 @@ Group Income solely relies on our sense of community, our ability to care for ea
2829

2930
- **Why we consider communities so vital**
3031

31-
<img src="https://groupincome.org/wp-content/uploads/2020/07/society-three-pillars.jpg" alt="" width="700" height="560" class="aligncenter size-full wp-image-1429" />
32+
<img src={resolvePath('wp-content/uploads/2020/07/society-three-pillars.jpg')} alt="" width="700" height="560" class="aligncenter size-full wp-image-1429" />
3233

3334
Communities keep society balanced. Let's have a look at it from the standpoint of [Raghuram Rajan](https://www.chicagobooth.edu/faculty/directory/r/raghuram-g-rajan). The Chicago Booth professor explains that society is upheld by three fundamental pillars: governments (political pillar), markets (economic pillar), and communities (sociological pillar).
3435

@@ -42,7 +43,7 @@ According to Rajan, what happened across the industrial world was a continued vi
4243

4344
**The consequence? The sociological pillar is now too fragile and there's an imbalance in society.**
4445

45-
<img src="https://groupincome.org/wp-content/uploads/2020/07/society-broken-communities.jpg" alt="" width="700" height="560" class="aligncenter size-full wp-image-1430" />
46+
<img src={resolvePath('/wp-content/uploads/2020/07/society-broken-communities.jpg')} alt="" width="700" height="560" class="aligncenter size-full wp-image-1430" />
4647

4748
**We no longer can deny [this imbalance](https://www.weforum.org/agenda/2018/11/unmanaged-globalisation-damaging-local-communities-heres-how). But how do we rectify it?**
4849

src/posts/aniko-fejes-and-sandrina-pereira-join-group-income.md renamed to src/posts/aniko-fejes-and-sandrina-pereira-join-group-income.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ permalink: /2018/08/aniko-fejes-and-sandrina-pereira-join-group-income/
1313
categories:
1414
- Uncategorized
1515
---
16+
import { resolvePath } from '@/utils/helpers.js'
1617

1718
Recently we bid farewell to [Victor Morrow](/articles/victor-morrow-joins-group-income/) who's moved on to exciting new [DARPA](https://www.darpa.mil) related work. Victor is still with us, now in a volunteer capacity. Thanks to his help, we've made great progress on Group Income. However, with his departure as full-time contractor, we needed to find someone to fill his shoes.
1819

19-
<img src="https://groupincome.org/wp-content/uploads/2018/08/aniko-214x300.jpg" alt="" width="214" height="300" class="alignright size-medium wp-image-1133" />
20+
<img src={resolvePath('/wp-content/uploads/2018/08/aniko-214x300.jpg')} alt="" width="214" height="300" class="alignright size-medium wp-image-1133" />
2021

2122
It was fortunate, therefore, that [Tamas Kalman](https://twitter.com/dH2K), another volunteer, introduced us to **Anikó Fejes**, a very talented developer and community organizer from Hungary.
2223

@@ -26,7 +27,7 @@ Follow [@hubudibu](https://twitter.com/hubudibu) for the occasional tweet from h
2627

2728
With Anikó on board, we were able to bring Group Income to the point where our focus had to shift away from internals and to the UI and UX of the app. In other words, we needed an expert frontend designer, and we found exactly what we were looking for in **Sandrina Pereira**.
2829

29-
<img src="https://groupincome.org/wp-content/uploads/2018/08/sandrina-300x300.jpg" alt="" width="300" height="300" class="alignright size-medium wp-image-1132" />
30+
<img src={resolvePath('/wp-content/uploads/2018/08/sandrina-300x300.jpg')} alt="" width="300" height="300" class="alignright size-medium wp-image-1132" />
3031

3132
Sandrina is a frontend developer with a great passion for interaction design. She loves to create unique experiences for <strike>users</strike> humans like you through the web.
3233

src/posts/basic-security-our-real-goal.md renamed to src/posts/basic-security-our-real-goal.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permalink: /2017/03/basic-security-our-real-goal/
1313
categories:
1414
- Uncategorized
1515
---
16+
import { resolvePath } from '@/utils/helpers.js'
1617

1718
Money is simply a tool that exists in circumstances when there is scarcity within an economy. It is a way of measuring the scarcity-demand for something. It is therefore a way of restricting access to that something. But when a lot of people choose to charge for scarce items using money, it gives money itself value -- value it otherwise would not have.
1819

@@ -22,7 +23,7 @@ Confused, you'd ask, _"Kindness? What's that, and where do I get some?"_
2223

2324
_"Well,"_ the shopkeep would say, _"You have to have a homeless person vouch for you. Their word is the currency that we take."_
2425

25-
<img src="https://groupincome.org/wp-content/uploads/2017/03/kindness.jpg" alt="visual depiction of surrounding text" width="1420" height="569" class="alignnone size-full wp-image-943" />
26+
<img src={resolvePath('/wp-content/uploads/2017/03/kindness.jpg')} alt="visual depiction of surrounding text" width="1420" height="569" class="alignnone size-full wp-image-943" />
2627

2728
You can imagine that would create an interesting situation. Suddenly, the value of simply being a homeless person would go up. These people would also have more power over society. The same thing happens with any currency, even dollars. If the creation of dollars is controlled by a small group (as it is), and those dollars are what shopkeeps around the country ask for, then that group suddenly becomes very powerful over society.
2829

src/posts/bulgaria-hackathon-2019.md renamed to src/posts/bulgaria-hackathon-2019.mdx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ permalink: /2021/06/bulgaria-hackathon-2019-roadmap-updates-hiring/
1414
categories:
1515
- Uncategorized
1616
---
17+
import { resolvePath } from '@/utils/helpers.js'
1718

1819
Some say it's not the destination that matters so much, but the journey and friends you meet along the way.
1920

2021
I couldn't agree more. But also, destinations aren't to be underestimated either! Back in 2019, during the Before Times, our team — a mixture of independent contractors and volunteers — got together in the beautiful land of Bulgaria for **Hackathon #8**!
2122

22-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_3732-768x1024.jpeg" alt="" width="768" height="1024" class="aligncenter size-large wp-image-1480" />
23+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_3732-768x1024.jpeg')} alt="" width="768" height="1024" class="aligncenter size-large wp-image-1480" />
2324

2425
**In This Post**
2526

@@ -36,13 +37,13 @@ Remember when people traveled? And did stuff? Together? In the same place? Wasn'
3637
Teammates from various parts of the world joined under a single roof, and this roof had two kinds of pools.
3738

3839
<div class="gallery">
39-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4028-300x225.jpeg"/>
40-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4022-300x225.jpeg"/>
40+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_4028-300x225.jpeg')} />
41+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_4022-300x225.jpeg')} />
4142
</div>
4243

4344
In attendance were familiar characters as well as new ones, including a brilliant young engineer and Group Income volunteer from South Korea by the name of [Sebin Song](https://sebinsong.github.io/).
4445

45-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_20191018_172603.jpg"/>
46+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_20191018_172603.jpg')} />
4647

4748
Sebin is one of the coolest people I've had to good fortune of meeting. He's an extremely intelligent, humble, and kind person whose talents in frontend development are exemplary.
4849

@@ -58,36 +59,36 @@ I asked Sebin what he found exciting about Group Income, and what drew him to vo
5859
5960
Most days we spent the morning, afternoon, and evenings working on Group Income.
6061

61-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_3996.jpeg"/>
62+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_3996.jpeg')} />
6263

6364
The team worked hard on implementing [Margarida's new dashboard designs](/2020/01/margarida-botelho-and-pierre-schweiger-join-group-income/):
6465

65-
<img src="https://groupincome.org/wp-content/uploads/2020/01/gi-design-2-1024x682.jpg"/>
66+
<img src={resolvePath('/wp-content/uploads/2020/01/gi-design-2-1024x682.jpg')} />
6667

6768
### Food and exploration
6869

6970
Andrea was our master vegan chef for the hackathon, and prepared a variety of delicious food for the team.
7071

71-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4025.jpeg"/>
72+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_4025.jpeg')} />
7273

7374
Of course, we took time to explore Bulgaria too.
7475

7576
The Black Sea is beautiful and was close to where we were staying.
7677

77-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_3890.jpg"/>
78+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_3890.jpg')} />
7879

79-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_20191021_174556.jpg"/>
80+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_20191021_174556.jpg')} />
8081

81-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_20191021_175003.jpg"/>
82+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_20191021_175003.jpg')} />
8283

8384

8485
Pierre, always a fan of high-end restaurants, insisted that we visit one on the trip. This turned out to be a rather good idea, as the team loved the care with which one of Bulgaria's Master Chefs prepared each and every dish:
8586

86-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_3899-1024x768.jpg"/>
87+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_3899-1024x768.jpg')} />
8788

8889
I asked Pierre about his thoughts on Group Income. What was it that drew him to working on Group Income?
8990

90-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_20191021_174559-300x300.jpg"/>
91+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_20191021_174559-300x300.jpg')} />
9192

9293
> **"Our project is dedicated to people that care about each other and you can feel it from the inside: I've never been in a company that considers its people as human beings before being a workforce… and it just feels right."**
9394
>
@@ -97,9 +98,9 @@ I asked Pierre about his thoughts on Group Income. What was it that drew him to
9798

9899
### Show & Tell
99100
<div class="gallery">
100-
<img width="300" height="225" src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4035-300x225.jpeg"/>
101-
<img width="300" height="225" src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4039-300x225.jpeg"/>
102-
<img width="300" height="225" src="https://groupincome.org/wp-content/uploads/2020/10/IMG_4046-300x225.jpeg"/>
101+
<img width="300" height="225" src={resolvePath('/wp-content/uploads/2020/10/IMG_4035-300x225.jpeg')} />
102+
<img width="300" height="225" src={resolvePath('/wp-content/uploads/2020/10/IMG_4039-300x225.jpeg')} />
103+
<img width="300" height="225" src={resolvePath('/wp-content/uploads/2020/10/IMG_4046-300x225.jpeg')} />
103104
</div>
104105

105106
Our hard work had paid off! We now have a mostly-functioning demo that anyone with a little bit of Git knowledge can [download and try out for themselves](https://github.com/okTurtles/group-income-simple)!
@@ -116,7 +117,7 @@ Many features came together during this hackathon:
116117
- Early implementation of the Pay Group page.
117118
- And my many more features and squashed bugs!
118119

119-
<img src="https://groupincome.org/wp-content/uploads/2020/10/margarida-278x300.jpg"/>
120+
<img src={resolvePath('/wp-content/uploads/2020/10/margarida-278x300.jpg')} />
120121

121122
> **"Working on this project has been one of the highlights of my professional life. I will be forever grateful for the opportunity to use my expertise, knowledge and time to contribute to this amazing project.**
122123
>
@@ -155,7 +156,7 @@ Join our team!
155156
We're looking for:
156157

157158
<ul>
158-
<li><h4 style="font-family: sans-serif"><a href="/pos-infosec/">JavaScript + InfoSec + Protocol Developer</a> ($1000 referral reward!)</a></h4></li>
159+
<li><h4 style="font-family: sans-serif"><a href="/pos-infosec/">JavaScript + InfoSec + Protocol Developer</a> ($1000 referral reward!)</h4></li>
159160
<li><h4 style="font-family: sans-serif"><a href="/pos-crypto-integration/">Cryptocurrency Integration with Node.js</a></h4></li>
160161
<li><h4 style="font-family: sans-serif"><a href="/pos-technical-writer/">Technical Writer</a></h4></li>
161162
<li><h4 style="font-family: sans-serif"><a href="/pos-fundraiser-marketer/">Fundraiser - OR - Marketer with Fundraising Experience</a></h4></li>
@@ -167,7 +168,7 @@ We're looking for:
167168
- **478 [issues closed](https://github.com/okTurtles/group-income-simple/issues?q=is%3Aissue+is%3Aclosed)**
168169
- **398 [pull requests reviewed](https://github.com/okTurtles/group-income-simple/pulls?q=is%3Apr+is%3Aclosed)**
169170

170-
<img src="https://groupincome.org/wp-content/uploads/2020/10/IMG_3855.jpg"/>
171+
<img src={resolvePath('/wp-content/uploads/2020/10/IMG_3855.jpg')} />
171172

172173
## Participate In Group Income
173174

0 commit comments

Comments
 (0)