Skip to content

Instantly share code, notes, and snippets.

View sharu725's full-sized avatar
🦧
Learning Svelte

Sharath Kumar sharu725

🦧
Learning Svelte
View GitHub Profile
@sharu725
sharu725 / Analytics.svelte
Last active December 5, 2023 22:09
Google Analytics in Sveltekit
<!-- Change the GA ID before using this -->
<script>
let analytics = true;
if (process.env.NODE_ENV == "development") {
analytics = false;
}
</script>
import { writable } from "svelte/store";
import { browser } from "$app/environment";
//string
export const userName = writable(
(browser && localStorage.getItem("userName")) || "hello world"
);
userName.subscribe((val) => browser && (localStorage.userName = val));
// array
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
@sharu725
sharu725 / Reading-time.html
Created August 19, 2017 07:33
Reading Time in minutes for posts
<!--
Before using this Jekyll Snippet make sure you
1. don't care if your IDE shows tag errors
2. may have to add the words "Reading Time". Currently it uses an icon from https://github.com/danklammer/bytesize-icons
-->
<span class="read-time" title="Estimated read time">
<svg id="i-clock" viewBox="0 0 32 32" width="20" height="20" fill="none" stroke="currentcolor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"><circle cx="16" cy="16" r="14" /><path d="M16 8 L16 16 20 20" /></svg>
<!--
Before you implement this Jekyll Snippet make sure
1. to thank css-tricks.com
2. define "disqus: DISQUS-SHORTNAME" in _config.yml file.
-->
<div class="disqus"></div>
<div class="disqus-loading">Loading comments&hellip;</div>
<style>
.disqus-placeholder.is-hidden { display: none; }
@sharu725
sharu725 / table-of-contents.html
Last active August 19, 2017 07:38
Jekyll Table of Contents
<!--
Before implementing this Jekyll snippet make sure
1. you have defined "markdown: kramdown" in _config.yml.
-->
* Do not remove this line (it will not be displayed)
{:toc}
@sharu725
sharu725 / subscribe-form.html
Last active December 7, 2023 20:36
Jekyll Subscribe Form using Mailchimp
<!--
Before implementing this jekyll snippet make sure
1. you have signed up with Mailchimp.
2. you have created a list in Mailchimp.
3. you have defined the list in _config.yml,
for ex: "mailchimp-list: //redgadgets.us10.list-manage.com/subscribe/post?u=210acce5db69d3d4a04b0e25d&amp;id=08c6708f40"
-->
<form action="{{site.mailchimp-list}}" method="post" name="mc-embedded-subscribe-form" class="wj-contact-form validate" target="_blank" novalidate>
<div class="mc-field-group">
@sharu725
sharu725 / contact-form.html
Last active May 2, 2019 17:16
Jekyll Contact Form using Formspree
<!--
After implementing this contact form make sure
1. you have defined "email: youremail@email.com" in _config.yml file.
2. you verify your form on formspree.io.
-->
<form class="wj-contact" action="https://formspree.io/{{site.email}}" method="POST">
<input type="text" name="email" placeholder="Email Address">
<textarea type="text" name="content" rows="10" placeholder="Message"></textarea>
<input type="hidden" name="_next" value="<REDIRECTION LINK> ">
@sharu725
sharu725 / pagination.html
Last active December 2, 2021 00:54
Jekyll Pagination
<!--
Before implementing this Jekyll snippet make sure
1. "plugins: jekyll-paginate" is added in the _config.yml file.
2. for loop has "paginator.post" instead of "site.posts".
-->
{% if paginator.total_pages > 1 %}
<div class="wj-pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&laquo; Prev</a>