Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Sep 27, 2024
1 parent 532e8bd commit c908e3f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"/Users/chris/i/chris.me/components/PageHeader.vue":"1","/Users/chris/i/chris.me/components/PersonInfo.vue":"2","/Users/chris/i/chris.me/components/repo/RepoCard.vue":"3","/Users/chris/i/chris.me/pages/projects.vue":"4","/Users/chris/i/chris.me/uno.config.ts":"5"},{"size":279,"mtime":1727418215072,"results":"6","hashOfConfig":"7"},{"size":1662,"mtime":1727416548957,"results":"8","hashOfConfig":"7"},{"size":1974,"mtime":1727418876696,"results":"9","hashOfConfig":"7"},{"size":908,"mtime":1727418883308,"results":"10","hashOfConfig":"7"},{"size":4814,"mtime":1727416347488,"results":"11","hashOfConfig":"12"},{"filePath":"13","messages":"14","suppressedMessages":"15","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"75pghd",{"filePath":"16","messages":"17","suppressedMessages":"18","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","suppressedMessages":"21","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","suppressedMessages":"24","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","suppressedMessages":"27","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"12bxb1y","/Users/chris/i/chris.me/components/PageHeader.vue",[],[],"/Users/chris/i/chris.me/components/PersonInfo.vue",[],[],"/Users/chris/i/chris.me/components/repo/RepoCard.vue",[],[],"/Users/chris/i/chris.me/pages/projects.vue",[],[],"/Users/chris/i/chris.me/uno.config.ts",[],["28"],{"ruleId":"29","severity":2,"message":"30","line":49,"column":9,"nodeType":"31","messageId":"32","endLine":49,"endColumn":18,"suppressions":"33"},"regexp/no-super-linear-backtracking","The quantifier '.+?' can exchange characters with '.+'. Using any string accepted by /:+/, this can be exploited to cause at least polynomial backtracking. This might cause exponential backtracking.","Literal","trade",["34"],{"kind":"35","justification":"36"},"directive",""]
11 changes: 11 additions & 0 deletions pages/images.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script lang="ts" setup>
const { data } = await useFetch('/api/images')
console.log(data.value)

Check failure on line 4 in pages/images.vue

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
</script>

<template>
<div class="w-70% mxa">
<ImgBlurHash v-for="src in data" :key="src.id" w-100 :src="src.urls.raw" :blurhash="src.blur_hash" />
</div>
</template>
11 changes: 11 additions & 0 deletions server/api/images.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useUnsplash } from '../utils/unsplash'

export default defineEventHandler(async () => {
if (import.meta.dev) {
const data: any = (await import('~/mock/unsplash.json')).default
return data.response
}

const res = await useUnsplash().photos.getRandom({ count: 20 })
return res.response
})
15 changes: 15 additions & 0 deletions server/utils/unsplash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import fetch from 'node-fetch'
import { createApi } from 'unsplash-js'

let _unsplash: ReturnType<typeof createApi> | null = null

export function useUnsplash() {
if (!_unsplash) {
_unsplash = createApi({
accessKey: process.env.Unsplash_Access_Key as string,
fetch: fetch as any,
})
}

return _unsplash
}

0 comments on commit c908e3f

Please sign in to comment.