Meta tags
This commit is contained in:
parent
7a0b49364f
commit
f44cb83657
|
@ -13,6 +13,10 @@ npm/codemirror@5.65.16/lib/codemirror.min.css,
|
||||||
npm/codemirror@5.65.16/theme/nord.min.css"
|
npm/codemirror@5.65.16/theme/nord.min.css"
|
||||||
/>
|
/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta property="og:title" content="Paste - No-database paste service" />
|
||||||
|
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/bokub/nopaste@images/logo.png" />
|
||||||
|
<meta property="og:url" content="https://paste.scambier.xyz" />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
|
|
@ -33,3 +33,6 @@ export function getLangFromUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const byId = (id: string) => document.getElementById(id)
|
export const byId = (id: string) => document.getElementById(id)
|
||||||
|
|
||||||
|
export const staticMetaDescription =
|
||||||
|
'Paste is a client-side paste service with no database, and no back-end code. The data is stored entirely in the shared link'
|
||||||
|
|
|
@ -10,12 +10,22 @@
|
||||||
import 'highlight.js/styles/nord.min.css'
|
import 'highlight.js/styles/nord.min.css'
|
||||||
import TopBar from '../components/TopBar.svelte'
|
import TopBar from '../components/TopBar.svelte'
|
||||||
import Icon from '@iconify/svelte'
|
import Icon from '@iconify/svelte'
|
||||||
import { getLangFromUrl } from '$lib/utils'
|
import { getLangFromUrl, staticMetaDescription } from '$lib/utils'
|
||||||
|
|
||||||
let decompressed: string
|
let decompressed: string
|
||||||
|
let htmlContent: string
|
||||||
let isMarkdown = false
|
let isMarkdown = false
|
||||||
let isPlainText = false
|
let isPlainText = false
|
||||||
|
|
||||||
|
// Meta description
|
||||||
|
$: metaDescription = (() => {
|
||||||
|
if (decompressed) {
|
||||||
|
const text = decompressed.slice(0, 100)
|
||||||
|
return text + (text.length === 100 ? '...' : '')
|
||||||
|
}
|
||||||
|
return staticMetaDescription
|
||||||
|
})()
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
let lang = getLangFromUrl()
|
let lang = getLangFromUrl()
|
||||||
lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links
|
lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links
|
||||||
|
@ -37,7 +47,7 @@
|
||||||
.use(rehypeStringify)
|
.use(rehypeStringify)
|
||||||
.process(decompressed)
|
.process(decompressed)
|
||||||
isMarkdown = true
|
isMarkdown = true
|
||||||
decompressed = html.toString()
|
htmlContent = html.toString()
|
||||||
}
|
}
|
||||||
// Plain text
|
// Plain text
|
||||||
else if (lang === 'plt' || !lang) {
|
else if (lang === 'plt' || !lang) {
|
||||||
|
@ -45,7 +55,7 @@
|
||||||
}
|
}
|
||||||
// Code
|
// Code
|
||||||
else {
|
else {
|
||||||
decompressed = hljs.highlight(lang, decompressed).value
|
htmlContent = hljs.highlight(lang, decompressed).value
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Redirect to editor page
|
// Redirect to editor page
|
||||||
|
@ -59,7 +69,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="overflow-hidden h-screen flex flex-col">
|
<div class="overflow-hidden h-screen flex flex-col">
|
||||||
{#if decompressed}
|
{#if htmlContent || decompressed}
|
||||||
<TopBar>
|
<TopBar>
|
||||||
<a
|
<a
|
||||||
href={'/editor' + getUrlDataPart()}
|
href={'/editor' + getUrlDataPart()}
|
||||||
|
@ -72,19 +82,23 @@
|
||||||
<div class="overflow-y-auto grow">
|
<div class="overflow-y-auto grow">
|
||||||
<div class="prose dark:prose-invert lg:py-12 p-[0.5em] md:max-w-3xl md:mx-auto lg:max-w-4xl">
|
<div class="prose dark:prose-invert lg:py-12 p-[0.5em] md:max-w-3xl md:mx-auto lg:max-w-4xl">
|
||||||
{#if isMarkdown}
|
{#if isMarkdown}
|
||||||
{@html decompressed}
|
{@html htmlContent}
|
||||||
{:else if isPlainText}
|
{:else if isPlainText}
|
||||||
<div class="whitespace-pre-line">
|
<div class="whitespace-pre-line">
|
||||||
{decompressed}
|
{decompressed}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<pre><code>{@html decompressed}</code></pre>
|
<pre><code>{@html htmlContent}</code></pre>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<meta name="description" property="og:description" content={metaDescription} />
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
:global(pre code.hljs) {
|
:global(pre code.hljs) {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import type { Editor } from 'codemirror'
|
import type { Editor } from 'codemirror'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import * as brotli from '$lib/brotli'
|
import * as brotli from '$lib/brotli'
|
||||||
import { byId } from '$lib/utils'
|
import { byId, staticMetaDescription } from '$lib/utils'
|
||||||
import TopBar from '../../components/TopBar.svelte'
|
import TopBar from '../../components/TopBar.svelte'
|
||||||
import { selectedLang, shareUrl } from '../../store'
|
import { selectedLang, shareUrl } from '../../store'
|
||||||
import EditForm from '../../components/EditForm.svelte'
|
import EditForm from '../../components/EditForm.svelte'
|
||||||
|
@ -69,6 +69,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
<meta name="description" property="og:description" content={staticMetaDescription} />
|
||||||
<script
|
<script
|
||||||
src="https://cdn.jsdelivr.net/combine/
|
src="https://cdn.jsdelivr.net/combine/
|
||||||
npm/codemirror@5.65.16,
|
npm/codemirror@5.65.16,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user