rendercontent package is deprecated. removed from repo
This commit is contained in:
parent
b74f2f4bfd
commit
458e087429
|
@ -1,60 +0,0 @@
|
||||||
# @matthiesenxyz/astro-ghostcms-rendercontent
|
|
||||||
|
|
||||||
## 0.0.9
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 2724119: Prep to deprecate this package. Moving to `astro-remote`
|
|
||||||
|
|
||||||
## 0.0.8
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- f921005: Bump dependencies:
|
|
||||||
|
|
||||||
- vite from to
|
|
||||||
- @eliancodes/brutal-ui from to
|
|
||||||
- typescript from to
|
|
||||||
- ultrahtml from to
|
|
||||||
- @fontsource-variable/inter from to
|
|
||||||
- astro-seo from to
|
|
||||||
- astro from to
|
|
||||||
- sass from to
|
|
||||||
- @astrojs/starlight from to
|
|
||||||
- sharp from to
|
|
||||||
|
|
||||||
## 0.0.7
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 1f850db: Bump dependencies:
|
|
||||||
|
|
||||||
- astro from to
|
|
||||||
- vite from to
|
|
||||||
- astro-seo from to
|
|
||||||
- sass from to
|
|
||||||
|
|
||||||
## 0.0.6
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 3a5aea9: Updated Tests and Linted packages
|
|
||||||
|
|
||||||
## 0.0.5
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 455ad3f: Bump astro from 4.0.0 to 4.3.7
|
|
||||||
- 12be739: Depencency updates
|
|
||||||
|
|
||||||
## 0.0.4
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- Fix License File
|
|
||||||
|
|
||||||
## 0.0.3
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- Initialization of changeset cli
|
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 MatthiesenXYZ - Astro-GhostCMS
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Astro GhostCMS Content API HTML Processor
|
|
||||||
|
|
||||||
## NOTE: This package is no longer in use - Please switch to [`astro-remote`](https://github.com/natemoo-re/astro-remote)
|
|
||||||
|
|
||||||
Render remote GhostCMS HTML in Astro with full control over the output.
|
|
||||||
|
|
||||||
Powered by [`ultrahtml`](https://github.com/natemoo-re/ultrahtml).
|
|
||||||
|
|
||||||
## Rendering Remote Content
|
|
||||||
|
|
||||||
The most basic function of `astro-ghostcms-rendercontent` is to convert a string of HTML to Astro friendly HTML. Use the `GhostRender` component.
|
|
||||||
|
|
||||||
```astro
|
|
||||||
---
|
|
||||||
import { GhostRender } from "@matthiesenxyz/astro-ghostcms-rendercontent";
|
|
||||||
---
|
|
||||||
|
|
||||||
<GhostRender content={post.html} />
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customization
|
|
||||||
|
|
||||||
`GhostRender` allows full control over the rendering of output. The `components` option allows you to replace a standard HTML element with a custom component.
|
|
||||||
|
|
||||||
```astro
|
|
||||||
---
|
|
||||||
import { GhostRender } from "@matthiesenxyz/astro-ghostcms-rendercontent";
|
|
||||||
import Title from '../components/Title.astro';
|
|
||||||
---
|
|
||||||
|
|
||||||
<!-- Render <h1> as custom <Title> component -->
|
|
||||||
<GhostRender content={post.html} components={{ h1: Title }} />
|
|
||||||
```
|
|
||||||
|
|
||||||
For examples on how to setup custom components check [examples](./examples/)
|
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
import { Code } from "astro/components"
|
|
||||||
import { parse } from "ultrahtml"
|
|
||||||
import { querySelector } from "ultrahtml/selector"
|
|
||||||
|
|
||||||
const html = await Astro.slots.render("default")
|
|
||||||
const ast = await parse(html)
|
|
||||||
const codetag = querySelector(ast,'code')
|
|
||||||
const { children } = codetag
|
|
||||||
const code = children[0].value
|
|
||||||
---
|
|
||||||
<Code code={code} lang={"sh"} theme={"monokai"}/>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h1 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h1>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h2 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h2>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h3 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h3>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h4 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h4>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h5 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h5>
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<h6 class="righteous">
|
|
||||||
<slot />
|
|
||||||
</h6>
|
|
|
@ -1,21 +0,0 @@
|
||||||
---
|
|
||||||
---
|
|
||||||
<p class="my-5"><slot /></p>
|
|
||||||
|
|
||||||
<style is:inline>
|
|
||||||
#ghost p a {
|
|
||||||
color: rgb(0, 123, 247);
|
|
||||||
}
|
|
||||||
#ghost ul li a {
|
|
||||||
color: rgb(0, 123, 247);
|
|
||||||
}
|
|
||||||
#ghost ul li {
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
margin-left: 2rem;
|
|
||||||
list-style: circle;
|
|
||||||
}
|
|
||||||
#ghost ul {
|
|
||||||
margin-top: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,8 +0,0 @@
|
||||||
export { default as H1 } from "./H1.astro";
|
|
||||||
export { default as H2 } from "./H2.astro";
|
|
||||||
export { default as H3 } from "./H3.astro";
|
|
||||||
export { default as H4 } from "./H4.astro";
|
|
||||||
export { default as H5 } from "./H5.astro";
|
|
||||||
export { default as H6 } from "./H6.astro";
|
|
||||||
export { default as CodeSlot } from "./CodeSlot.astro";
|
|
||||||
export { default as Paragraph } from "./Paragraph.astro";
|
|
|
@ -1 +0,0 @@
|
||||||
export { default as GhostRender } from "./lib/GhostRender.astro";
|
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
import { createComponentProxy, html } from './utils';
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
content?: string;
|
|
||||||
components?: Record<string, any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const input = Astro.props.content ?? await Astro.slots.render('default');
|
|
||||||
if (!input) {
|
|
||||||
throw new Error('Unable to render <GhostRender> without a content prop or children')
|
|
||||||
}
|
|
||||||
// @ts-ignore
|
|
||||||
const components = createComponentProxy($$result, Astro.props.components);
|
|
||||||
const content = await html(input, { components });
|
|
||||||
---
|
|
||||||
|
|
||||||
<Fragment set:html={content} />
|
|
|
@ -1 +0,0 @@
|
||||||
/// <reference types="astro/client" />
|
|
|
@ -1,59 +0,0 @@
|
||||||
import { jsx as h } from "astro/jsx-runtime";
|
|
||||||
import { renderJSX } from "astro/runtime/server/jsx";
|
|
||||||
import * as entities from "entities";
|
|
||||||
import { transform } from "ultrahtml";
|
|
||||||
import { __unsafeHTML } from "ultrahtml";
|
|
||||||
import swap from "ultrahtml/transformers/swap";
|
|
||||||
|
|
||||||
export function createComponentProxy(
|
|
||||||
result,
|
|
||||||
_components: Record<string, any> = {},
|
|
||||||
) {
|
|
||||||
const components = {};
|
|
||||||
for (const [key, value] of Object.entries(_components)) {
|
|
||||||
if (typeof value === "string") {
|
|
||||||
components[key] = value;
|
|
||||||
} else {
|
|
||||||
components[key] = async (props, children) => {
|
|
||||||
if (key === "CodeBlock" || key === "CodeSpan") {
|
|
||||||
props.code = entities.decode(JSON.parse(`"${props.code}"`));
|
|
||||||
}
|
|
||||||
const output = await renderJSX(
|
|
||||||
result,
|
|
||||||
h(value, { ...props, "set:html": children.value }),
|
|
||||||
);
|
|
||||||
return __unsafeHTML(output);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return components;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIndent(ln: string): string {
|
|
||||||
if (ln.trim() === ln) return "";
|
|
||||||
return ln.slice(0, ln.length - ln.trim().length);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function dedent(str: string): string {
|
|
||||||
const lns = str.replace(/^[\r\n]+/, "").split("\n");
|
|
||||||
let indent = getIndent(lns[0]);
|
|
||||||
if (indent.length === 0 && lns.length > 1) {
|
|
||||||
indent = getIndent(lns[1]);
|
|
||||||
}
|
|
||||||
return lns
|
|
||||||
.map((ln) => (ln.startsWith(indent) ? ln.slice(indent.length) : ln))
|
|
||||||
.map((ln, i, { length }) => (i === length - 1 ? ln.trim() : ln))
|
|
||||||
.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface HTMLOptions {
|
|
||||||
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
||||||
components?: {};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function html(
|
|
||||||
input: string,
|
|
||||||
opts: HTMLOptions = {},
|
|
||||||
): Promise<string> {
|
|
||||||
return transform(dedent(input), [swap(opts.components)]);
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@matthiesenxyz/astro-ghostcms-rendercontent",
|
|
||||||
"type": "module",
|
|
||||||
"version": "0.0.9",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/MatthiesenXYZ/astro-ghostcms.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/MatthiesenXYZ/astro-ghostcms/issues",
|
|
||||||
"email": "issues@astro-ghostcms.xyz"
|
|
||||||
},
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"sideEffects": false,
|
|
||||||
"homepage": "https://astro-ghostcms.xyz",
|
|
||||||
"files": [
|
|
||||||
"examples",
|
|
||||||
"lib",
|
|
||||||
"index.ts",
|
|
||||||
"CHANGELOG.md"
|
|
||||||
],
|
|
||||||
"types": "./index.ts",
|
|
||||||
"exports": {
|
|
||||||
".": "./index.ts",
|
|
||||||
"./lib/*": "./lib/*",
|
|
||||||
"./examples/*": "./examples/*",
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"astro-ghostcms"
|
|
||||||
],
|
|
||||||
"author": {
|
|
||||||
"email": "adam@matthiesen.xyz",
|
|
||||||
"name": "Adam Matthiesen - MatthiesenXYZ",
|
|
||||||
"url": "https://matthiesen.xyz"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"entities": "^4.5.0",
|
|
||||||
"ultrahtml": "^1.5.3"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"astro": "4.4.13"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue