-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to allow for more flexibility and customization options in the future #45
Changes from 1 commit
c688736
1b6fcd6
231ef34
5e795d9
f8a498f
8fa0763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
import Config from 'virtual:studiocms/config'; | ||
import { renderMarkDoc } from '../../utils/markdoc'; | ||
import { renderMarked } from '../../utils/marked'; | ||
|
||
type Props = { | ||
content: string; | ||
}; | ||
|
||
const { content } = Astro.props; | ||
|
||
function contentRenderer() { | ||
if (Config.contentRenderer === 'markdoc') { | ||
return renderMarkDoc(content); | ||
} | ||
return renderMarked(content); | ||
} | ||
--- | ||
|
||
<Fragment set:html={contentRenderer()} /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
--- | ||
// @ts-expect-error - This is a missing type definition for the `astro:db` import since its a virtual module during Astro Runtime | ||
import { Blog, db, eq } from 'astro:db'; | ||
import Dashboard from '../../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../../utils/rankcheck'; | ||
import type { Locals } from '../locals'; | ||
import sitemap from 'sitemap-ext:config'; | ||
sitemap(false); // opt-out | ||
import Dashboard from '../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../utils/rankcheck'; | ||
import type { Locals } from '../../schemas/locals'; | ||
import Config from 'virtual:studiocms/config'; | ||
|
||
if (Config.includedIntegrations.useInoxSitemap) { | ||
import('sitemap-ext:config').then((sitemap) => { | ||
sitemap.default(false) | ||
}) | ||
} | ||
|
||
function redirectToPath(path: string) { | ||
return Astro.redirect(import.meta.env.BASE_URL + path); | ||
|
@@ -131,19 +136,24 @@ if (Astro.request.method === 'POST') { | |
</Dashboard> | ||
|
||
<script> | ||
import { markdown } from "../../../utils/marked"; | ||
import Config from 'virtual:astro-studio-cms:config'; | ||
import { renderMarkDoc } from '../../../utils/markdoc'; | ||
import Config from 'virtual:studiocms/config'; | ||
import { renderMarked } from "../../utils/marked"; | ||
import { renderMarkDoc } from '../../utils/markdoc'; | ||
|
||
//@ts-ignore | ||
document.getElementById('content').addEventListener('input', async function () { | ||
const markdownContent = document.getElementById('content'); | ||
const htmlPreview = document.getElementById('html-preview'); | ||
|
||
if (Config.contentRenderer === 'marked' ) { | ||
const htmlContent = await markdown(markdownContent.value); | ||
//@ts-ignore | ||
const htmlContent = await renderMarked(markdownContent.value); | ||
//@ts-ignore | ||
htmlPreview.innerHTML = htmlContent; | ||
} else if (Config.contentRenderer === 'markdoc') { | ||
//@ts-ignore | ||
const htmlContent = await renderMarkDoc(markdownContent.value); | ||
//@ts-ignore | ||
Comment on lines
+146
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the issue with ts here? |
||
htmlPreview.innerHTML = htmlContent; | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
--- | ||
// @ts-expect-error - This is a missing type definition for the `astro:db` import since its a virtual module during Astro Runtime | ||
import { Pages, db, eq } from 'astro:db'; | ||
import Dashboard from '../../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../../utils/rankcheck'; | ||
import type { Locals } from '../locals'; | ||
import sitemap from 'sitemap-ext:config'; | ||
sitemap(false); // opt-out | ||
import Dashboard from '../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../utils/rankcheck'; | ||
import type { Locals } from '../../schemas/locals'; | ||
import Config from 'virtual:studiocms/config'; | ||
|
||
if (Config.includedIntegrations.useInoxSitemap) { | ||
import('sitemap-ext:config').then((sitemap) => { | ||
sitemap.default(false) | ||
}) | ||
} | ||
|
||
const postArrayed = await db.select().from(Pages).where(eq(Pages.slug, 'about')); | ||
const post = postArrayed[0]; | ||
|
@@ -124,19 +129,24 @@ if (Astro.request.method === 'POST') { | |
</Dashboard> | ||
|
||
<script> | ||
import { markdown } from "../../../utils/marked"; | ||
import Config from 'virtual:astro-studio-cms:config'; | ||
import { renderMarkDoc } from '../../../utils/markdoc'; | ||
import Config from 'virtual:studiocms/config'; | ||
import { renderMarked } from "../../utils/marked"; | ||
import { renderMarkDoc } from '../../utils/markdoc'; | ||
|
||
//@ts-ignore | ||
document.getElementById('content').addEventListener('input', async function () { | ||
const markdownContent = document.getElementById('content'); | ||
const htmlPreview = document.getElementById('html-preview'); | ||
|
||
if (Config.contentRenderer === 'marked' ) { | ||
const htmlContent = await markdown(markdownContent.value); | ||
//@ts-ignore | ||
const htmlContent = await renderMarked(markdownContent.value); | ||
//@ts-ignore | ||
htmlPreview.innerHTML = htmlContent; | ||
} else if (Config.contentRenderer === 'markdoc') { | ||
//@ts-ignore | ||
const htmlContent = await renderMarkDoc(markdownContent.value); | ||
//@ts-ignore | ||
Comment on lines
+140
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here |
||
htmlPreview.innerHTML = htmlContent; | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
--- | ||
// @ts-expect-error - This is a missing type definition for the `astro:db` import since its a virtual module during Astro Runtime | ||
import { Admins, Pages, db, eq } from 'astro:db'; | ||
import Dashboard from '../../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../../utils/rankcheck'; | ||
import type { Locals } from '../locals'; | ||
import sitemap from 'sitemap-ext:config'; | ||
sitemap(false); // opt-out | ||
import Dashboard from '../../layouts/Dashboard.astro'; | ||
import { rankCheck } from '../../utils/rankcheck'; | ||
import type { Locals } from '../../schemas/locals'; | ||
import Config from 'virtual:studiocms/config'; | ||
|
||
if (Config.includedIntegrations.useInoxSitemap) { | ||
import('sitemap-ext:config').then((sitemap) => { | ||
sitemap.default(false) | ||
}) | ||
} | ||
|
||
const postArrayed = await db.select().from(Pages).where(eq(Pages.slug, 'index')); | ||
const post = postArrayed[0]; | ||
|
@@ -125,19 +130,24 @@ if (Astro.request.method === 'POST') { | |
</Dashboard> | ||
|
||
<script> | ||
import { markdown } from "../../../utils/marked"; | ||
import Config from 'virtual:astro-studio-cms:config'; | ||
import { renderMarkDoc } from '../../../utils/markdoc'; | ||
import Config from 'virtual:studiocms/config'; | ||
import { renderMarked } from "../../utils/marked"; | ||
import { renderMarkDoc } from '../../utils/markdoc'; | ||
|
||
//@ts-ignore | ||
document.getElementById('content').addEventListener('input', async function () { | ||
const markdownContent = document.getElementById('content'); | ||
const htmlPreview = document.getElementById('html-preview'); | ||
|
||
if (Config.contentRenderer === 'marked' ) { | ||
const htmlContent = await markdown(markdownContent.value); | ||
//@ts-ignore | ||
const htmlContent = await renderMarked(markdownContent.value); | ||
//@ts-ignore | ||
htmlPreview.innerHTML = htmlContent; | ||
} else if (Config.contentRenderer === 'markdoc') { | ||
//@ts-ignore | ||
const htmlContent = await renderMarkDoc(markdownContent.value); | ||
//@ts-ignore | ||
Comment on lines
+140
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, here as well. |
||
htmlPreview.innerHTML = htmlContent; | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in newest commit where i am now actually duplicating some of the astroDB runtime types for the DB tables. 🎉 and implemented your suggestion as well