resolved how to run scripts in articles, added devbreak broadcasts
This commit is contained in:
11
src/lib/articleContent/onMountScripts.ts
Normal file
11
src/lib/articleContent/onMountScripts.ts
Normal file
@ -0,0 +1,11 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
onMountScripts?: Array<() => void>
|
||||
}
|
||||
}
|
||||
export function runOnMountScripts() {
|
||||
window.onMountScripts?.forEach((fn) => {
|
||||
fn()
|
||||
})
|
||||
}
|
||||
|
@ -19,3 +19,9 @@ globalStyle(`${contentClass} img:only-child`, {
|
||||
display: 'block',
|
||||
margin: '0 auto',
|
||||
})
|
||||
|
||||
globalStyle(`${contentClass} .video-embed`, {
|
||||
margin: '0 auto',
|
||||
maxWidth: vars.width.image,
|
||||
aspectRatio: vars.aspectRatio.monitor,
|
||||
})
|
||||
|
@ -2,8 +2,14 @@
|
||||
import ArticleFooter from '$lib/components/articles/ArticlePreviewFooter/ArticlePreviewFooter.svelte'
|
||||
import type { PageData } from './$types'
|
||||
import { contentClass } from '$lib/styles/article/article.css'
|
||||
import { onMount } from 'svelte'
|
||||
import { runOnMountScripts } from '$lib/articleContent/onMountScripts'
|
||||
|
||||
export let data: PageData
|
||||
|
||||
onMount(() => {
|
||||
runOnMountScripts()
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@ -12,7 +18,7 @@
|
||||
|
||||
<h1>{data.title}</h1>
|
||||
|
||||
<div class="content {contentClass}">
|
||||
<article class="content {contentClass}">
|
||||
{@html data.body}
|
||||
</div>
|
||||
</article>
|
||||
<ArticleFooter article={data} segment="blog" />
|
||||
|
@ -2,8 +2,14 @@
|
||||
import ArticleFooter from '$lib/components/articles/ArticlePreviewFooter/ArticlePreviewFooter.svelte'
|
||||
import type { PageData } from './$types'
|
||||
import { contentClass } from '$lib/styles/article/article.css'
|
||||
import { onMount } from 'svelte'
|
||||
import { runOnMountScripts } from '$lib/articleContent/onMountScripts'
|
||||
|
||||
export let data: PageData
|
||||
|
||||
onMount(() => {
|
||||
runOnMountScripts()
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@ -12,7 +18,7 @@
|
||||
|
||||
<h1>{data.title}</h1>
|
||||
|
||||
<div class="content {contentClass}">
|
||||
<article class="content {contentClass}">
|
||||
{@html data.body}
|
||||
</div>
|
||||
</article>
|
||||
<ArticleFooter article={data} segment="broadcasts" />
|
||||
|
Reference in New Issue
Block a user