Skip to content

Instantly share code, notes, and snippets.

View samuelhorn's full-sized avatar
👨‍💻
jam stackin'

Samuel Horn af Rantzien samuelhorn

👨‍💻
jam stackin'
View GitHub Profile
@samuelhorn
samuelhorn / menu-items-slicezone.tsx
Last active December 6, 2023 08:45
Menu items rendered in SliceZone as in Prismic's sub menu within a <MenuItemWithSubmenu />
<div className="px-0 container lg:px-8 flex flex-col lg:flex-row">
<div
className="flex flex-col lg:w-[26.6666666667%] lg:py-12 gap-3 my-6 lg:my-0"
>
<SliceZone
slices="{slice.primary.sub_menu.data.slices}"
components="{components}"
/>
</div>
<ColumnSeparator />
@samuelhorn
samuelhorn / menu-items-no-slicezone.tsx
Last active December 6, 2023 08:43
Menu items as Slices without SliceZone, as used in Prismic top level menu
<ul className="flex flex-col lg:items-center lg:flex-row lg:justify-center">
{layout.data.slices1.map((item, index) => {
if (item.variation === "default") {
return (
<MenuItem
key={index}
slice={item}
/>
);
} else {
@samuelhorn
samuelhorn / relatedposts.tsx
Last active October 24, 2023 08:50
How to fetch content relationships in a slice
@samuelhorn
samuelhorn / authorpage.tsx
Last active October 24, 2023 08:51
fetch posts related to author
import { createClient } from "@/prismicio";
import { filter } from "@prismicio/client";
const Author = async ({ params }: { params: { uid: string } }) => {
const client = createClient();
// Fetch the actual author
const author = await client.getByUID("blog_author", params.uid)
// Fetch all blog posts related to author
@samuelhorn
samuelhorn / gist:7883be23f90ab8db376cbf1bcd48bfea
Last active December 22, 2020 13:19
Unsplash image HTML snippet for VSCode
"Unsplash": {
"prefix": "unsplash",
"body": [
"<img src=\"https://source.unsplash.com/${1:1600}x${2:900}/?${3:nature,water}\" alt=\"${4:Placeholder image from Unsplash}\" />"
],
"description": "Image from unsplash"
}
@samuelhorn
samuelhorn / pacman-vscode
Created November 28, 2020 00:11
Vscode pacman caret
.monaco-editor .cursors-layer .cursor {
background: transparent;
border-radius: 100%;
width: 30px !important;
background: conic-gradient(yellow 55deg, transparent 0 125deg, yellow 0);
transform: rotateZ(180deg);
animation: eat 0.5s linear infinite;
}
@keyframes eat {
@samuelhorn
samuelhorn / gulpfile.js
Last active December 9, 2022 09:38
My gulpfile for new projects
/*******************************************************************************
1. DEPENDENCIES
*******************************************************************************/
var gulp = require('gulp'); // gulp core
sass = require('gulp-sass'), // sass compiler
uglify = require('gulp-uglify'), // uglifies the js
jshint = require('gulp-jshint'), // check if js is ok
rename = require("gulp-rename"); // rename files
concat = require('gulp-concat'), // concatinate js
@samuelhorn
samuelhorn / gruntfile.js
Created December 5, 2013 22:33
My gruntfile for new projects
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// chech our JS
jshint: {
options: {
"bitwise": true,
@samuelhorn
samuelhorn / .htaccess
Created December 3, 2013 09:03
Mixed htaccess fixes
<FilesMatch ".(ttf|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
@samuelhorn
samuelhorn / loop.php
Created December 3, 2013 08:59
Custom post type query
<?php
// Makes an array with own query wich not affects the ain loop
$events = new WP_Query(array("post_type" => "event"));
if ($events->have_posts()): while($events->have_posts()): $events->the_post();
get_template_part("loop");
the_content();
endwhile; endif;