11<script lang="ts">
2+ import { ref } from ' vue'
3+
24// shared data across instances so we load only once
35const base = ' https://app.vuejobs.com/feed/vuejs/docs?format=json'
46
5- let items = $ ref <Jobs []>([])
7+ const items = ref <Jobs []>([])
68
79type Jobs = {
810 organization: Organization
@@ -21,19 +23,19 @@ type Organization = {
2123< script setup lang = " ts" >
2224import { onMounted , computed } from ' vue'
2325
24- let vuejobs = $ref <HTMLElement >()
25-
2626const openings = computed (() =>
27- items .sort (() => 0.5 - Math .random ()).slice (0 , 2 )
27+ items .value . sort (() => 0.5 - Math .random ()).slice (0 , 2 )
2828)
2929
3030onMounted (async () => {
31- if (! items .length ) items = (await (await fetch (` ${base } ` )).json ()).data
31+ if (! items .value .length ) {
32+ items .value = (await (await fetch (` ${base } ` )).json ()).data
33+ }
3234})
3335 </script >
3436
3537<template >
36- <div class =" vuejobs-wrapper" ref = " vuejobs " >
38+ <div class =" vuejobs-wrapper" >
3739 <div class =" vj-container" >
3840 <a
3941 class =" vj-item"
@@ -45,15 +47,17 @@ onMounted(async () => {
4547 <div class =" vj-company-logo" >
4648 <img
4749 :src =" job.organization.avatar"
48- :alt =" `Logo for ${job.organization.name}`" />
50+ :alt =" `Logo for ${job.organization.name}`"
51+ />
4952 </div >
5053 <div
5154 style ="
5255 overflow : hidden ;
5356 display : flex ;
5457 flex-direction : column ;
5558 justify-content : center ;
56- " >
59+ "
60+ >
5761 <div class =" vj-job-title" >{{ job.title }}</div >
5862 <div class =" vj-job-info" >
5963 {{ job.organization.name }} <span >· </span >
0 commit comments