mirror of
https://github.com/NotXia/notxia.github.io.git
synced 2025-12-15 19:22:21 +01:00
Update Goodreads component
This commit is contained in:
@ -1,33 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full">
|
<div class="h-full w-fit">
|
||||||
<p>{{ t("now reading") }}</p>
|
<div v-if="is_loading" class="flex h-full w-full items-center justify-center">
|
||||||
<div id="gr_grid_widget_1673812364" class="h-32"></div>
|
<span class="animate-ping absolute inline-flex h-5 w-5 rounded-full bg-slate-800 dark:bg-slate-200 opacity-75"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-show="!is_loading" id="gr_grid_widget_1673812364" class="h-full"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
|
|
||||||
const { t } = useI18n({ messages:
|
const is_loading = ref(true);
|
||||||
{
|
|
||||||
it: {
|
|
||||||
"now reading": "Attualmente sto leggendo"
|
|
||||||
},
|
|
||||||
en: {
|
|
||||||
"now reading": "Currently I'm reading"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (document.getElementById("script-goodreads")) return;
|
if (document.querySelector("#script-goodreads")) { document.querySelector("#script-goodreads")?.remove() };
|
||||||
|
|
||||||
var scriptTag = document.createElement("script");
|
let scriptTag = document.createElement("script");
|
||||||
scriptTag.src = "https://www.goodreads.com/review/grid_widget/158866642?cover_size=medium&hide_link=true&hide_title=true&num_books=20&order=d&shelf=currently-reading&sort=date_updated&widget_id=1673812364";
|
scriptTag.src = "https://www.goodreads.com/review/grid_widget/158866642?cover_size=medium&hide_link=true&hide_title=true&num_books=20&order=d&shelf=currently-reading&sort=date_updated&widget_id=1673812364";
|
||||||
scriptTag.id = "script-goodreads";
|
scriptTag.id = "script-goodreads";
|
||||||
scriptTag.type = "text/javascript";
|
scriptTag.type = "text/javascript";
|
||||||
document.getElementsByTagName("head")[0].appendChild(scriptTag);
|
document.getElementsByTagName("head")[0].appendChild(scriptTag);
|
||||||
|
|
||||||
|
let observer = new MutationObserver(function(mutations) {
|
||||||
|
// @ts-ignore
|
||||||
|
// Replaces the book covers with a higher resolution image
|
||||||
|
document.querySelectorAll("#gr_grid_widget_1673812364 > * img").forEach((image) => image.src = image.src.replace("_SX98_", "_SY475_"));
|
||||||
|
|
||||||
|
observer.disconnect();
|
||||||
|
is_loading.value = false;
|
||||||
|
});
|
||||||
|
observer.observe((document.querySelector("#gr_grid_widget_1673812364") as Node), { childList: true });
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -43,6 +46,7 @@
|
|||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 0.2rem;
|
border-radius: 0.2rem;
|
||||||
|
border: 1px solid #424242;
|
||||||
}
|
}
|
||||||
.gr_grid_book_container:first-child {
|
.gr_grid_book_container:first-child {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user