mirror of
https://gitlab.com/thelazyoxymoron/siddhartha-golu-website.git
synced 2025-07-27 17:17:58 +02:00
466 lines
25 KiB
HTML
466 lines
25 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en" dir="auto">
|
||
|
||
<head><meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||
<meta name="robots" content="index, follow">
|
||
<title>The Way We Eat: Why Our Food Choices Matter by Peter Singer | Siddhartha Golu</title>
|
||
<meta name="keywords" content="review, debating-ethics, non-fiction, animal-cruelty, favourites">
|
||
<meta name="description" content="The ethical dilemma of eating. Highly recommended!">
|
||
<meta name="author" content="Siddhartha Golu">
|
||
<link rel="canonical" href="https://www.siddharthagolu.com/posts/reading/the-way-we-eat/">
|
||
<script async defer data-website-id="34ce8dc6-488b-49ee-9a2f-8e70a7009f17" src="https://batman.siddharthagolu.com/batman.js"></script>
|
||
<link crossorigin="anonymous" href="/assets/css/stylesheet.4f5576b27f1a8ee2d1559082cedf1e9ca257ea9b767d9780cb0718c2435f78e5.css" integrity="sha256-T1V2sn8ajuLRVZCCzt8enKJX6pt2fZeAywcYwkNfeOU=" rel="preload stylesheet" as="style">
|
||
<script defer crossorigin="anonymous" src="/assets/js/highlight.f413e19d0714851f6474e7ee9632408e58ac146fbdbe62747134bea2fa3415e0.js" integrity="sha256-9BPhnQcUhR9kdOfuljJAjlisFG+9vmJ0cTS+ovo0FeA="
|
||
onload="hljs.initHighlightingOnLoad();"></script>
|
||
<link rel="icon" href="https://www.siddharthagolu.com/favicon.ico">
|
||
<link rel="icon" type="image/png" sizes="16x16" href="https://www.siddharthagolu.com/favicon-16x16.png">
|
||
<link rel="icon" type="image/png" sizes="32x32" href="https://www.siddharthagolu.com/favicon-32x32.png">
|
||
<link rel="apple-touch-icon" href="https://www.siddharthagolu.com/apple-touch-icon.png">
|
||
<link rel="mask-icon" href="https://www.siddharthagolu.com/safari-pinned-tab.svg">
|
||
<meta name="theme-color" content="#2e2e33">
|
||
<meta name="msapplication-TileColor" content="#2e2e33">
|
||
<noscript>
|
||
<style>
|
||
#theme-toggle,
|
||
.top-link {
|
||
display: none;
|
||
}
|
||
|
||
</style>
|
||
<style>
|
||
@media (prefers-color-scheme: dark) {
|
||
:root {
|
||
--theme: rgb(29, 30, 32);
|
||
--entry: rgb(46, 46, 51);
|
||
--primary: rgb(218, 218, 219);
|
||
--secondary: rgb(155, 156, 157);
|
||
--tertiary: rgb(65, 66, 68);
|
||
--content: rgb(196, 196, 197);
|
||
--hljs-bg: rgb(46, 46, 51);
|
||
--code-bg: rgb(55, 56, 62);
|
||
--border: rgb(51, 51, 51);
|
||
}
|
||
|
||
.list {
|
||
background: var(--theme);
|
||
}
|
||
|
||
.list:not(.dark)::-webkit-scrollbar-track {
|
||
background: 0 0;
|
||
}
|
||
|
||
.list:not(.dark)::-webkit-scrollbar-thumb {
|
||
border-color: var(--theme);
|
||
}
|
||
}
|
||
|
||
</style>
|
||
</noscript><!-- isso -->
|
||
<script data-isso="https://comments.siddharthagolu.com/" src="https://comments.siddharthagolu.com/js/embed.min.js"></script>
|
||
<!-- end isso -->
|
||
<meta property="og:title" content="The Way We Eat: Why Our Food Choices Matter by Peter Singer" />
|
||
<meta property="og:description" content="The ethical dilemma of eating. Highly recommended!" />
|
||
<meta property="og:type" content="article" />
|
||
<meta property="og:url" content="https://www.siddharthagolu.com/posts/reading/the-way-we-eat/" />
|
||
<meta property="og:image" content="https://www.siddharthagolu.com/posts/reading/the-way-we-eat/images/the-way-we-eat.jpg" /><meta property="article:section" content="posts" />
|
||
<meta property="article:published_time" content="2021-09-01T10:43:25+05:30" />
|
||
<meta property="article:modified_time" content="2023-06-23T00:36:16+05:30" /><meta property="og:site_name" content="Siddhartha Golu" />
|
||
|
||
<meta name="twitter:card" content="summary_large_image" />
|
||
<meta name="twitter:image" content="https://www.siddharthagolu.com/posts/reading/the-way-we-eat/images/the-way-we-eat.jpg" />
|
||
<meta name="twitter:title" content="The Way We Eat: Why Our Food Choices Matter by Peter Singer"/>
|
||
<meta name="twitter:description" content="The ethical dilemma of eating. Highly recommended!"/>
|
||
|
||
|
||
<script type="application/ld+json">
|
||
{
|
||
"@context": "https://schema.org",
|
||
"@type": "BreadcrumbList",
|
||
"itemListElement": [
|
||
{
|
||
"@type": "ListItem",
|
||
"position": 1 ,
|
||
"name": "Posts",
|
||
"item": "https://www.siddharthagolu.com/posts/"
|
||
},
|
||
{
|
||
"@type": "ListItem",
|
||
"position": 2 ,
|
||
"name": "The Way We Eat: Why Our Food Choices Matter by Peter Singer",
|
||
"item": "https://www.siddharthagolu.com/posts/reading/the-way-we-eat/"
|
||
}
|
||
]
|
||
}
|
||
</script>
|
||
<script type="application/ld+json">
|
||
{
|
||
"@context": "https://schema.org",
|
||
"@type": "BlogPosting",
|
||
"headline": "The Way We Eat: Why Our Food Choices Matter by Peter Singer",
|
||
"name": "The Way We Eat: Why Our Food Choices Matter by Peter Singer",
|
||
"description": "The ethical dilemma of eating. Highly recommended!",
|
||
"keywords": [
|
||
"review", "debating-ethics", "non-fiction", "animal-cruelty", "favourites"
|
||
],
|
||
"articleBody": "Check it out on Goodreads\nEthics is hard.\nIf I’ve learnt something all these years, it is this universal maxim. Everybody wishes they’d make ethically sound choices in their lives, but more often than not, ethical choices are in contrast with cost and convenience. Nowhere is this more apparent than the way we consume food.\nThere are a lot of similarities between food and religion. Both are deeply personal choices which are erroneously thought of as having a clear, set winning answer. Both divide people into disjoint sets where they vehemently try to outdo one another in following “The Right Way”. And of course, both are deeply political.\nMy personal journey in food, as in religion, has been quite tumultuous. Coming from a vegetarian family, I used to feel discomfort in sitting at the same table where somebody was eating meat, used to scoff at the smell of eggs and couldn’t go near anything related to fish (this is still the case). Then somewhere along the way, I decided that I don’t have a right to reject things which I haven’t experienced myself and started indulging in this forbidden fruit. I tried everything I could get my hands on, but never reached that stage where I could appreciate the hype. Having gotten a taste of the other side, I made the decision to quit everything and slowly move back to being a vegetarian/vegan.\nThis was the point where I started to seek out reasons to convince me of my choice, and came across this book.\nI wouldn’t call this a balanced book in the sense that the authors’ convictions are clear from the start, however where this shines is the way they use evidence to reach their conclusions rather than playing on guilt and shame. The basic fact remains, and this I have confirmed with many of my non-vegetarian friends as well, that we know too little about where our food comes from and our choices would be different if we were armed with this knowledge. The authors visit few American families and observe their eating habits, and then take us through some factory farms where the brutalities are quite graphic and sometimes hard to read and difficult to digest.\nHowever, one qualm that I had while reading through these chapters, was the over-importance of ethics in our everyday choices. Not everyone wants to live a Kantian life full of moments filled with questioning their every choice. Life is hard to live anyway. I was delighted though to find a section dealing with this exhaustion:\nSometimes the very success of the ethical consumer movement and the proliferation of consumer concerns it has spawned seems to threaten the entire ethical consumption project. When one ethical concern is heaped upon another and we struggle to be sure that our purchases do not contribute to slave labor, animal exploitation, land degradation, wetland pollution, rural depopulation, unfair trade practices, global warming, and the destruction of rain-forests, it may all seem so complicated that we could be tempted to forget about everything except eating what we like and can afford.\nI’m facing this situation myself when I eat eggs and drink milk in the morning - if every time I consume an animal product, I have to think about where this is coming from and whether I’ve unintentionally hurt an animal - to say that my day-to-day life would be unpleasant would be an understatement. However, we should be cautious of throwing the baby out with bathwater - the choice doesn’t have to be between over-indulgence and starvation; we just need to be a bit more conscious of what we consume. To borrow an economist’s favorite phrase: there’s always a trade-off. We just need to be aware of the ones we are making.\nAll in all, I found this to be quite an informative read, albeit a bit dry in places, but would definitely recommend.\n",
|
||
"wordCount" : "650",
|
||
"inLanguage": "en",
|
||
"image":"https://www.siddharthagolu.com/posts/reading/the-way-we-eat/images/the-way-we-eat.jpg","datePublished": "2021-09-01T10:43:25+05:30",
|
||
"dateModified": "2023-06-23T00:36:16+05:30",
|
||
"author":[{
|
||
"@type": "Person",
|
||
"name": "Siddhartha Golu"
|
||
}],
|
||
"mainEntityOfPage": {
|
||
"@type": "WebPage",
|
||
"@id": "https://www.siddharthagolu.com/posts/reading/the-way-we-eat/"
|
||
},
|
||
"publisher": {
|
||
"@type": "Organization",
|
||
"name": "Siddhartha Golu",
|
||
"logo": {
|
||
"@type": "ImageObject",
|
||
"url": "https://www.siddharthagolu.com/favicon.ico"
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
</head>
|
||
|
||
<body class="" id="top">
|
||
<script>
|
||
if (localStorage.getItem("pref-theme") === "dark") {
|
||
document.body.classList.add('dark');
|
||
} else if (localStorage.getItem("pref-theme") === "light") {
|
||
document.body.classList.remove('dark')
|
||
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||
document.body.classList.add('dark');
|
||
}
|
||
|
||
</script>
|
||
|
||
<header class="header">
|
||
<nav class="nav">
|
||
<div class="logo">
|
||
<a href="https://www.siddharthagolu.com/" accesskey="h" title="Siddhartha Golu (Alt + H)">
|
||
<img src="https://www.siddharthagolu.com/apple-touch-icon.png" alt="" aria-label="logo"
|
||
height="30">Siddhartha Golu</a>
|
||
<div class="logo-switches">
|
||
<button id="theme-toggle" accesskey="t" title="(Alt + T)">
|
||
<svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24"
|
||
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||
stroke-linejoin="round">
|
||
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
|
||
</svg>
|
||
<svg id="sun" xmlns="http://www.w3.org/2000/svg" width="24" height="18" viewBox="0 0 24 24"
|
||
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||
stroke-linejoin="round">
|
||
<circle cx="12" cy="12" r="5"></circle>
|
||
<line x1="12" y1="1" x2="12" y2="3"></line>
|
||
<line x1="12" y1="21" x2="12" y2="23"></line>
|
||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
|
||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
|
||
<line x1="1" y1="12" x2="3" y2="12"></line>
|
||
<line x1="21" y1="12" x2="23" y2="12"></line>
|
||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
|
||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
|
||
</svg>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<ul id="menu">
|
||
<li>
|
||
<a href="https://www.siddharthagolu.com/about" title="About">
|
||
<span>About</span>
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="https://www.siddharthagolu.com/archive" title="Archive">
|
||
<span>Archive</span>
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="https://www.siddharthagolu.com/categories" title="Categories">
|
||
<span>Categories</span>
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="https://www.siddharthagolu.com/tags/" title="Tags">
|
||
<span>Tags</span>
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="https://www.siddharthagolu.com/search/" title="Search (Alt + /)" accesskey=/>
|
||
<span>Search</span>
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</nav>
|
||
</header>
|
||
<main class="main">
|
||
|
||
<article class="post-single">
|
||
<header class="post-header">
|
||
<div class="breadcrumbs"><a href="https://www.siddharthagolu.com/">Home</a> » <a href="https://www.siddharthagolu.com/posts/">Posts</a></div>
|
||
<h1 class="post-title">
|
||
The Way We Eat: Why Our Food Choices Matter by Peter Singer
|
||
</h1>
|
||
<div class="post-meta">
|
||
|
||
<span title='2021-09-01 10:43:25 +0530 IST'>🗓 September 1, 2021</span> <span title='2023-06-23 00:36:16 +0530 IST'>🔄 June 23, 2023</span> 4 min 🔖 <a href="/tags/review"> review</a> · <a href="/tags/debating-ethics"> debating-ethics</a> · <a href="/tags/non-fiction"> non-fiction</a> · <a href="/tags/animal-cruelty"> animal-cruelty</a> · <a href="/tags/favourites"> favourites</a>
|
||
|
||
</div>
|
||
</header>
|
||
<div class="post-content"><p><a href="https://www.goodreads.com/review/show/4125010337">Check it out on Goodreads</a></p>
|
||
<hr>
|
||
<p><img loading="lazy" src="/images/the-way-we-eat.jpg#center" alt="The Way We Eat Cover" title="The Way We Eat Cover" />
|
||
</p>
|
||
<p>Ethics is hard.</p>
|
||
<p>If I’ve learnt something all these years, it is this universal maxim. Everybody wishes they’d make ethically sound choices in their lives, but more often than not, ethical choices are in contrast with cost and convenience. Nowhere is this more apparent than the way we consume food.</p>
|
||
<p>There are a lot of similarities between food and religion. Both are deeply personal choices which are erroneously thought of as having a clear, set winning answer. Both divide people into disjoint sets where they vehemently try to outdo one another in following “The Right Way”. And of course, both are deeply political.</p>
|
||
<p>My personal journey in food, as in religion, has been quite tumultuous. Coming from a vegetarian family, I used to feel discomfort in sitting at the same table where somebody was eating meat, used to scoff at the smell of eggs and couldn’t go near anything related to fish (this is still the case). Then somewhere along the way, I decided that I don’t have a right to reject things which I haven’t experienced myself and started indulging in this forbidden fruit. I tried everything I could get my hands on, but never reached that stage where I could appreciate the hype. Having gotten a taste of the other side, I made the decision to quit everything and slowly move back to being a vegetarian/vegan.</p>
|
||
<p>This was the point where I started to seek out reasons to convince me of my choice, and came across this book.</p>
|
||
<p>I wouldn’t call this a balanced book in the sense that the authors’ convictions are clear from the start, however where this shines is the way they use evidence to reach their conclusions rather than playing on guilt and shame. The basic fact remains, and this I have confirmed with many of my non-vegetarian friends as well, that we know too little about where our food comes from and our choices would be different if we were armed with this knowledge. The authors visit few American families and observe their eating habits, and then take us through some factory farms where the brutalities are quite graphic and sometimes hard to read and difficult to digest.</p>
|
||
<p>However, one qualm that I had while reading through these chapters, was the over-importance of ethics in our everyday choices. Not everyone wants to live a Kantian life full of moments filled with questioning their every choice. Life is hard to live anyway. I was delighted though to find a section dealing with this exhaustion:</p>
|
||
<blockquote>
|
||
<p>Sometimes the very success of the ethical consumer movement and the proliferation of consumer concerns it has spawned seems to threaten the entire ethical consumption project. When one ethical concern is heaped upon another and we struggle to be sure that our purchases do not contribute to slave labor, animal exploitation, land degradation, wetland pollution, rural depopulation, unfair trade practices, global warming, and the destruction of rain-forests, it may all seem so complicated that we could be tempted to forget about everything except eating what we like and can afford.</p>
|
||
</blockquote>
|
||
<p>I’m facing this situation myself when I eat eggs and drink milk in the morning - if every time I consume an animal product, I have to think about where this is coming from and whether I’ve unintentionally hurt an animal - to say that my day-to-day life would be unpleasant would be an understatement. However, we should be cautious of throwing the baby out with bathwater - the choice doesn’t have to be between over-indulgence and starvation; we just need to be a bit more conscious of what we consume. To borrow an economist’s favorite phrase: there’s always a trade-off. We just need to be aware of the ones we are making.</p>
|
||
<p>All in all, I found this to be quite an informative read, albeit a bit dry in places, but would definitely recommend.</p>
|
||
|
||
|
||
</div>
|
||
|
||
<footer class="post-footer">
|
||
<ul class="post-tags">
|
||
<li><a href="https://www.siddharthagolu.com/tags/review/">review</a></li>
|
||
<li><a href="https://www.siddharthagolu.com/tags/debating-ethics/">debating-ethics</a></li>
|
||
<li><a href="https://www.siddharthagolu.com/tags/non-fiction/">non-fiction</a></li>
|
||
<li><a href="https://www.siddharthagolu.com/tags/animal-cruelty/">animal-cruelty</a></li>
|
||
<li><a href="https://www.siddharthagolu.com/tags/favourites/">favourites</a></li>
|
||
</ul>
|
||
<nav class="paginav">
|
||
<a class="prev" href="https://www.siddharthagolu.com/posts/cinema/3-iron/">
|
||
<span class="title">« Prev</span>
|
||
<br>
|
||
<span>3 Iron (2004) by Kim Ki-duk</span>
|
||
</a>
|
||
<a class="next" href="https://www.siddharthagolu.com/posts/reading/shame-rushdie/">
|
||
<span class="title">Next »</span>
|
||
<br>
|
||
<span>Shame by Salman Rushdie</span>
|
||
</a>
|
||
</nav>
|
||
|
||
</footer>
|
||
|
||
<hr>
|
||
<section class="webring">
|
||
<h3 class="header">Articles from blogs I follow around the net</h3>
|
||
<section class="articles">
|
||
|
||
<div class="article">
|
||
<h4 class="title">
|
||
<a href="https://www.strangeloopcanon.com/p/innovation" target="_blank" rel="noopener">Innovation</a>
|
||
</h4>
|
||
<p class="summary">A data based look at how innovations came about through all of human history</p>
|
||
<small class="source">
|
||
via <a href="https://www.strangeloopcanon.com">Strange Loop Canon</a>
|
||
</small>
|
||
<small class="date">September 18, 2023</small>
|
||
</div>
|
||
|
||
<div class="article">
|
||
<h4 class="title">
|
||
<a href="https://fasterthanli.me/articles/cracking-electron-apps-open" target="_blank" rel="noopener">Cracking Electron apps open</a>
|
||
</h4>
|
||
<p class="summary">
|
||
I use the draw.io desktop app to
|
||
make diagrams for my website. I run it on an actual desktop, like Windows or
|
||
macOS, but the asset pipeline that converts .drawio files, to .pdf, to
|
||
.svg, and then to .svg again (but smaller) runs on Linux.
|
||
</p>
|
||
<small class="source">
|
||
via <a href="https://fasterthanli.me">fasterthanli.me</a>
|
||
</small>
|
||
<small class="date">July 3, 2023</small>
|
||
</div>
|
||
|
||
<div class="article">
|
||
<h4 class="title">
|
||
<a href="http://feedproxy.google.com/~r/zenpencils/~3/j54gzBYaIjQ/" target="_blank" rel="noopener">UPDATE: Moving on, a new project and new challenge</a>
|
||
</h4>
|
||
<p class="summary">Hey everyone! A little update with me. Sigh, I knew this would happen. As soon as I release the first chapter of a big new ongoing comic (see my latest comic, Little Warrior Chapter 1), life throws a spanner in […] ↓ Read the rest of this entry...</p>
|
||
<small class="source">
|
||
via <a href="https://www.zenpencils.com/">ZEN PENCILS</a>
|
||
</small>
|
||
<small class="date">August 22, 2018</small>
|
||
</div>
|
||
|
||
</section>
|
||
<p class="attribution">
|
||
Generated by
|
||
<a href="https://git.sr.ht/~sircmpwn/openring">openring</a>
|
||
</p>
|
||
</section>
|
||
<style>
|
||
.webring .header {
|
||
margin: 0 0 12px;
|
||
}
|
||
.webring .articles {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin: -0.5rem;
|
||
}
|
||
.webring .title {
|
||
margin: 4px 0 12px;
|
||
}
|
||
.webring .article {
|
||
flex: 1 1 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
margin: 0.5rem;
|
||
padding: 0.5rem;
|
||
background: var(--openring-bg);
|
||
min-width: 10rem;
|
||
}
|
||
.webring .summary {
|
||
font-size: 0.8rem;
|
||
flex: 1 1 0;
|
||
}
|
||
.webring .attribution {
|
||
text-align: right;
|
||
font-size: 0.8rem;
|
||
color: #555;
|
||
}
|
||
</style>
|
||
<!-- begin comments //-->
|
||
<section id = "isso-thread">
|
||
|
||
</section>
|
||
<!-- end comments //-->
|
||
|
||
</article>
|
||
</main>
|
||
|
||
<footer class="footer">
|
||
<span>© 2023 <a href="https://www.siddharthagolu.com/">Siddhartha Golu</a></span>
|
||
<span>
|
||
Powered by
|
||
<a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
|
||
<a href="https://github.com/adityatelange/hugo-PaperMod/" rel="noopener" target="_blank">PaperMod</a>
|
||
</span>
|
||
</footer>
|
||
<a href="#top" aria-label="go to top" title="Go to Top (Alt + G)" class="top-link" id="top-link" accesskey="g">
|
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentColor">
|
||
<path d="M12 6H0l6-6z" />
|
||
</svg>
|
||
</a>
|
||
|
||
<script>
|
||
let menu = document.getElementById('menu')
|
||
if (menu) {
|
||
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
|
||
menu.onscroll = function () {
|
||
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
|
||
}
|
||
}
|
||
|
||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
||
anchor.addEventListener("click", function (e) {
|
||
e.preventDefault();
|
||
var id = this.getAttribute("href").substr(1);
|
||
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
|
||
behavior: "smooth"
|
||
});
|
||
} else {
|
||
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
|
||
}
|
||
if (id === "top") {
|
||
history.replaceState(null, null, " ");
|
||
} else {
|
||
history.pushState(null, null, `#${id}`);
|
||
}
|
||
});
|
||
});
|
||
|
||
</script>
|
||
<script>
|
||
var mybutton = document.getElementById("top-link");
|
||
window.onscroll = function () {
|
||
if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
|
||
mybutton.style.visibility = "visible";
|
||
mybutton.style.opacity = "1";
|
||
} else {
|
||
mybutton.style.visibility = "hidden";
|
||
mybutton.style.opacity = "0";
|
||
}
|
||
};
|
||
|
||
</script>
|
||
<script>
|
||
document.getElementById("theme-toggle").addEventListener("click", () => {
|
||
if (document.body.className.includes("dark")) {
|
||
document.body.classList.remove('dark');
|
||
localStorage.setItem("pref-theme", 'light');
|
||
} else {
|
||
document.body.classList.add('dark');
|
||
localStorage.setItem("pref-theme", 'dark');
|
||
}
|
||
})
|
||
|
||
</script>
|
||
<script>
|
||
document.querySelectorAll('pre > code').forEach((codeblock) => {
|
||
const container = codeblock.parentNode.parentNode;
|
||
|
||
const copybutton = document.createElement('button');
|
||
copybutton.classList.add('copy-code');
|
||
copybutton.innerHTML = 'copy';
|
||
|
||
function copyingDone() {
|
||
copybutton.innerHTML = 'copied!';
|
||
setTimeout(() => {
|
||
copybutton.innerHTML = 'copy';
|
||
}, 2000);
|
||
}
|
||
|
||
copybutton.addEventListener('click', (cb) => {
|
||
if ('clipboard' in navigator) {
|
||
navigator.clipboard.writeText(codeblock.textContent);
|
||
copyingDone();
|
||
return;
|
||
}
|
||
|
||
const range = document.createRange();
|
||
range.selectNodeContents(codeblock);
|
||
const selection = window.getSelection();
|
||
selection.removeAllRanges();
|
||
selection.addRange(range);
|
||
try {
|
||
document.execCommand('copy');
|
||
copyingDone();
|
||
} catch (e) { };
|
||
selection.removeRange(range);
|
||
});
|
||
|
||
if (container.classList.contains("highlight")) {
|
||
container.appendChild(copybutton);
|
||
} else if (container.parentNode.firstChild == container) {
|
||
|
||
} else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
|
||
|
||
codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
|
||
} else {
|
||
|
||
codeblock.parentNode.appendChild(copybutton);
|
||
}
|
||
});
|
||
</script>
|
||
</body>
|
||
|
||
</html>
|