mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-25 02:56:38 +00:00
temporarily fix img
This commit is contained in:
parent
bd18197688
commit
b67b8fe3f4
1 changed files with 88 additions and 88 deletions
176
astro.config.mts
176
astro.config.mts
|
|
@ -10,94 +10,94 @@ import md5 from "md5"
|
|||
|
||||
function pipeline() {
|
||||
return [
|
||||
() => tree => {
|
||||
visit(tree, "element", (node, index) => {
|
||||
if (node.tagName === "p" && node.children[0].tagName === "img") {
|
||||
node.tagName = "figure"
|
||||
let img = node.children[0]
|
||||
let sign = md5(img.properties.src)
|
||||
let data = img.properties.alt.split("|")
|
||||
let alt = data[0]
|
||||
let size = "big"
|
||||
if (data.length > 1) {
|
||||
size = data[1]
|
||||
}
|
||||
let classes = ["image component image-full-bleed body-copy-wide nr-scroll-animation nr-scroll-animation--on"]
|
||||
classes.push(`image-${size}`)
|
||||
node.properties.className = classes
|
||||
node.children = [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "div",
|
||||
properties: {
|
||||
className: ["component-content"],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "div",
|
||||
properties: {
|
||||
className: ["image-share-sheet"],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "div",
|
||||
properties: {
|
||||
className: [`image image-load image-asset image-${sign}`],
|
||||
id: `lht${sign}`,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "picture",
|
||||
properties: {
|
||||
className: ["picture"],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "img",
|
||||
properties: {
|
||||
"data-src": img.properties.src,
|
||||
alt: alt,
|
||||
className: ["picture-image"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "element",
|
||||
tagName: "div",
|
||||
properties: {
|
||||
className: ["image-description"],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "div",
|
||||
properties: {
|
||||
className: ["image-caption"],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
value: alt,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
},
|
||||
// () => tree => {
|
||||
// visit(tree, "element", (node, index) => {
|
||||
// if (node.tagName === "p" && node.children[0].tagName === "img") {
|
||||
// node.tagName = "figure"
|
||||
// let img = node.children[0]
|
||||
// let sign = md5(img.properties.src)
|
||||
// let data = img.properties.alt.split("|")
|
||||
// let alt = data[0]
|
||||
// let size = "big"
|
||||
// if (data.length > 1) {
|
||||
// size = data[1]
|
||||
// }
|
||||
// let classes = ["image component image-full-bleed body-copy-wide nr-scroll-animation nr-scroll-animation--on"]
|
||||
// classes.push(`image-${size}`)
|
||||
// node.properties.className = classes
|
||||
// node.children = [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "div",
|
||||
// properties: {
|
||||
// className: ["component-content"],
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "div",
|
||||
// properties: {
|
||||
// className: ["image-share-sheet"],
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "div",
|
||||
// properties: {
|
||||
// className: [`image image-load image-asset image-${sign}`],
|
||||
// id: `lht${sign}`,
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "picture",
|
||||
// properties: {
|
||||
// className: ["picture"],
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "img",
|
||||
// properties: {
|
||||
// "data-src": img.properties.src,
|
||||
// alt: alt,
|
||||
// className: ["picture-image"],
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "div",
|
||||
// properties: {
|
||||
// className: ["image-description"],
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "element",
|
||||
// tagName: "div",
|
||||
// properties: {
|
||||
// className: ["image-caption"],
|
||||
// },
|
||||
// children: [
|
||||
// {
|
||||
// type: "text",
|
||||
// value: alt,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ]
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
() => tree => {
|
||||
tree.children.forEach(node => {
|
||||
if (node.type === "raw") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue