Skip to content
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

Finding that when using the <Markdown /> component it looks like the internal component is going into a loop or something similar? #38

Open
rebron1900 opened this issue Sep 11, 2024 · 1 comment

Comments

@rebron1900
Copy link

The build time grows progressively for each page, and the odds are that it's stuck in some kind of dead loop.
I've since switched to using the marked library's parse method to build properly.

image

I use JSON data with MD content.

https://memos.1900.live/api/v1/memo?creatorId=101&limit=all

Error page code

---
import { pages, settings, authors, memos } from '../../data/ghost-store.js';
import { marked } from 'marked';
import { Markdown } from 'astro-remote';
import type { GetStaticPathsOptions } from 'astro';

import BaseLayout from '../../layouts/BaseLayout.astro';
import Head from '../../components/Head.astro';
import Relitu from '../../components/Relitu.jsx';
import Header from '../../components/Header.astro';
import Top from '../../components/Top.astro';
import Menu from '../../components/Menu.astro';
import TocTagloop from '../../components/TocTagloop.astro';

const custompage = pages.find((post) => post.slug == 'memos');

export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
    const db = memos;
    return paginate(db, {
        pageSize: 15
    });
}

const { page } = Astro.props;
---

<BaseLayout post={custompage}>
    <Head slot="head" post={custompage} site={settings} title={custompage?.title + ' | ' + settings?.title + ' - ' + settings?.description} />

    <Header slot="header" title={custompage.title} />
    <Menu slot="menu" />

    <div slot="content" class="markdown book-article page-memos">
        <div class="memo-header" style={`background-image: url(${authors.authors[0].cover_image});`}>
            <div class="memo-info">
                <div class="flex align-center">
                    <span class="memo-title">{authors.authors[0].name}</span>
                    <div class="memo-avartar">
                        <img class="" src={authors.authors[0].profile_image} data-sizes="auto" />
                    </div>
                </div>
                <div class="memo-desc">纵使生活有千般不如意,也不要自暴自弃!</div>
            </div>
        </div>

        <div id="atk-memoslist">
            {
                page.data.map((memo) => (
                    <div class="atk-comment">
                        <div class="atk-avatar">
                            <a target="_blank" rel="noreferrer noopener nofollow" href="#">
                                <img src={authors.authors[0].profile_image} />
                            </a>
                        </div>

                        <div class="atk-main">
                            <div class="atk-body">
                                <div class="atk-content">
                                    <Markdown content={memo.content} />
                                    <div class="resource-wrapper">
                                        <div class="images-wrapper my-2" view-image="">
                                            <template x-for="img in item.resourceList">
                                                <div class="memo-resource w-100">
                                                    <img class="lazyload  medium-zoom-image" data-loaded="true" />
                                                </div>
                                            </template>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                ))
            }
            <div class="flex flex-wrap btn-more justify-center" style="padding: 3rem; gap:1.5rem">
                {
                    page.url.next && (
                        <a
                            class="loader"
                            href="javascript:(void)"
                            hx-trigger="revealed"
                            hx-get={`${page.url.next}`}
                            hx-target="#atk-memoslist"
                            hx-swap="beforeend transition:true "
                            hx-select="#atk-memoslist"
                        />
                    )
                }
            </div>
        </div>

        <script>
            import 'https://unpkg.com/[email protected]';
            import 'artalk/dist/Artalk.css';

            document.addEventListener('astro:page-load', () => {
                document.body.addEventListener('htmx:afterSwap', function (event) {
                    document.querySelector('.btn-more')?.remove();
                });
            });
        </script>
    </div>

    <Relitu slot="relitu" />

    <Fragment slot="toc">
        <Relitu />
        <TocTagloop />
        <Top />
    </Fragment>
</BaseLayout>
@rebron1900 rebron1900 changed the title 发现在使用<Markdown />组件时似内部组件进入了循环或类似的问题? Finding that when using the <Markdown /> component it looks like the internal component is going into a loop or something similar? Sep 11, 2024
@twodft
Copy link

twodft commented Sep 12, 2024

This seems similar to #33 , and there is a pr #35 intended to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants