chore: update deps; add ultrahtml dep
This commit is contained in:
parent
be13713a49
commit
8470e5bee6
5 changed files with 1619 additions and 1446 deletions
|
@ -1,8 +1,11 @@
|
||||||
import { defineConfig } from "astro/config";
|
import { defineConfig } from "astro/config";
|
||||||
import netlify from "@astrojs/netlify/functions";
|
import netlify from "@astrojs/netlify/functions";
|
||||||
|
|
||||||
|
import prefetch from "@astrojs/prefetch";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
output: "server",
|
output: "server",
|
||||||
adapter: netlify()
|
adapter: netlify(),
|
||||||
|
integrations: [prefetch()]
|
||||||
});
|
});
|
3028
package-lock.json
generated
3028
package-lock.json
generated
File diff suppressed because it is too large
Load diff
12
package.json
12
package.json
|
@ -11,13 +11,15 @@
|
||||||
"build": "astro build"
|
"build": "astro build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^2.9.1"
|
"astro": "^3.2.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/netlify": "^2.2.2",
|
"@astrojs/netlify": "^3.0.2",
|
||||||
"@ayco/astro-resume": "^0.3.4",
|
"@astrojs/prefetch": "^0.4.0",
|
||||||
"@extractus/article-extractor": "^7.2.15",
|
"@ayco/astro-resume": "^0.3.9",
|
||||||
|
"@extractus/article-extractor": "^8.0.2",
|
||||||
"astro-iconify": "^1.2.0",
|
"astro-iconify": "^1.2.0",
|
||||||
"sass": "^1.62.1"
|
"sass": "^1.68.0",
|
||||||
|
"ultrahtml": "^1.5.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
import { ArticleData } from "@extractus/article-extractor";
|
import { ArticleData } from "@extractus/article-extractor";
|
||||||
|
import clean from '../utils/sanitizer';
|
||||||
export interface Props {
|
export interface Props {
|
||||||
article: ArticleData | null;
|
article: ArticleData | null;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +13,8 @@ let { article } = Astro.props;
|
||||||
article ??= error;
|
article ??= error;
|
||||||
const datePublished =
|
const datePublished =
|
||||||
article?.published && new Date(article.published).toDateString();
|
article?.published && new Date(article.published).toDateString();
|
||||||
|
|
||||||
|
const cleanContent = clean(article.content ?? '')
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -29,7 +32,7 @@ const datePublished =
|
||||||
{datePublished && <li>️{datePublished}</li>}
|
{datePublished && <li>️{datePublished}</li>}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
<content set:html={article.content} />
|
<content set:html={cleanContent} />
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
15
src/utils/sanitizer.ts
Normal file
15
src/utils/sanitizer.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { transform } from 'ultrahtml'
|
||||||
|
import sanitize from 'ultrahtml/transformers/sanitize'
|
||||||
|
|
||||||
|
export default function clean(html: string) {
|
||||||
|
|
||||||
|
return transform(html, [
|
||||||
|
sanitize({
|
||||||
|
dropElements: ['script'],
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
function set(value: string) {
|
||||||
|
return () => value
|
||||||
|
}
|
Loading…
Reference in a new issue