Skip to content

Instantly share code, notes, and snippets.

View ekrist1's full-sized avatar

ekrist1

View GitHub Profile
@ekrist1
ekrist1 / nuxt-file
Created April 22, 2023 14:54
Sanity serializers to convert a tag to nuxt-link (nuxt 3).
//helpers/link.vue
<template>
<nuxt-link :to="href" v-if="isInternalLink"> <slot /></nuxt-link>
<a :href="href" v-else> <slot /></a>
</template>
<script setup>
const props = defineProps({
@ekrist1
ekrist1 / GenerateSitemap.php
Created September 11, 2018 13:29
Laravelium Sitemap Example
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Item;
@ekrist1
ekrist1 / TruncateText
Created August 11, 2018 11:39
Truncate text using Vue + Laravel
<template>
<div>
{{ text | truncate(isTruncated) }} <button class="text-blue" @click="isTruncated = !isTruncated">{{ isTruncated ? showMoreText : shotLessText }}</button>
</div>
</template>
<script>
export default {
props: ['body'],
data () {
@ekrist1
ekrist1 / stream_file.php
Created April 15, 2018 21:30 — forked from fideloper/stream_file.php
Stream file from S3 to browser, assume Laravel Filesystem usage
<?php
/*************************************************************************
* Get File Information
*/
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
@ekrist1
ekrist1 / Payment.blade.php
Last active February 7, 2018 20:44
Larvel Vue Stripe (frontend)
<previewvacancy
name="Stillingsannonse"
description="Annonse aktiveres rett etter kjøp"
stripekey="{{ config('services.stripe.key') }}"
email="{{ $vacancy->user->email }}">
</previewvacancy>
@section('stripe')
@ekrist1
ekrist1 / imageslider.vue
Last active December 23, 2017 21:13
Super simple image carousel with Vue and Laravel
<template>
<div>
<div class="items-center flex">
<img itemprop="img" class="w-32 h-32 rounded-full mr-4 mr-auto ml-auto" :src="images[currentNumber]" alt="Produktbilder" />
</div>
<div class="mt-4 text-center">
<a href="#" @click="prev" class="text-grey">Forrige bilde</a> <a href="#" @click="next" class="ml-3 text-grey">Neste bilde</a>
</div>
</div>
</template>
@ekrist1
ekrist1 / default.blade.php
Created December 19, 2017 21:52
Tailwindcss blade pagination
@if ($paginator->hasPages())
<ul class="flex list-reset w-auto justify-center">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="block hover:text-white hover:bg-blue text-grey border-r border-grey-light px-3 py-2 cursor-not-allowed"><span>&laquo;</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="block hover:text-white hover:bg-blue text-blue border-r border-grey-light px-3 py-2">&laquo;</a></li>
@endif
{{-- Pagination Elements --}}
@ekrist1
ekrist1 / Parent.vue
Last active November 5, 2017 21:47
Vue Trix-Editor component
<template>
<div>
<input id="trixJsEditor" type="hidden" name="content" value="init value">
<trix-vue content="test"></trix-vue>
</div>
</div>
</template>
<script>
import TrixVue from './Trix.vue';
@ekrist1
ekrist1 / Tabs.vue
Created October 18, 2017 19:14
Vue Bulma Laravel Tabs
<template>
<div>
<div class="tabs">
<ul>
<li v-for="tab in tabs" :key="tab.id" :class="{ 'is-active': isActivated(tab) }"><a @click="selectTab(tab)">{{ tab.name }}</a></li>
</ul>
</div>
</div>
</template>
@ekrist1
ekrist1 / Instruction
Created October 1, 2017 14:00
Laravel Vue Bulma pagination component
Add eventHub to your app.js file:
Vue.prototype.$eventHub = new Vue();
In your controller:
Generate a new resource-class (pagination metadata is included in the response)
https://laravel.com/docs/5.5/eloquent-resources
How to use the child-component in your vue-file: