mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-03-29 16:01:43 +01:00
Fix text previews
This commit is contained in:
parent
ef5b00b16b
commit
56a4c52e24
@ -3,4 +3,5 @@
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
text-align: initial;
|
||||
overflow: auto;
|
||||
}
|
@ -5,15 +5,24 @@ export function TextPreview(props) {
|
||||
let [content, setContent] = useState("Loading..");
|
||||
|
||||
async function getContent(link) {
|
||||
let req = await fetch(link);
|
||||
let req = await fetch(`${link}?t=${new Date().getTime()}`, {
|
||||
headers: {
|
||||
"pragma": "no-cache",
|
||||
"cache-control": "no-cache"
|
||||
}
|
||||
});
|
||||
if (req.ok) {
|
||||
setContent(await req.text());
|
||||
} else {
|
||||
setContent("ERROR :(")
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getContent(props.link);
|
||||
}, []);
|
||||
if (props.link !== undefined && props.link !== "#") {
|
||||
getContent(props.link);
|
||||
}
|
||||
}, [props.link]);
|
||||
|
||||
return (
|
||||
<pre className="text-preview">{content}</pre>
|
||||
|
Loading…
x
Reference in New Issue
Block a user