krokyze / flutter_seo

Flutter package for SEO support on Web.
MIT License
46 stars 5 forks source link

Need better system for text spans / rich text #23

Closed emmett-deen closed 1 year ago

emmett-deen commented 1 year ago

I am currently just wrapping the rich text with a link since I think that is more important for me than the text contained, but either way we need a way to accomplish both with text spans. See code example:

            Seo.link(
                href: 'https://twitter.com/Emmett_Deen',
                anchor: 'Twitter',
                child: Text.rich(
                  TextSpan(text: 'Made with ', children: [
                    TextSpan(text: '❤️', style: GoogleFonts.roboto()),
                    const TextSpan(text: ' by '),
                    TextSpan(
                      text: '@Emmett_Deen',
                      recognizer: TapGestureRecognizer()
                        ..onTap = () => html.window
                            .open('https://twitter.com/Emmett_Deen', 'Twitter'),
                      style: TextStyle(
                          color: Theme.of(context).colorScheme.secondary,
                          fontWeight: FontWeight.bold),
                    ),
                  ]),
                  style: Theme.of(context)
                      .textTheme
                      .titleSmall
                      ?.copyWith(color: Colors.white),
                ))
fredx21 commented 1 year ago

I am in the same situation. Having rich text / text spans wrapped in seo object would make flutter a whole lot more usable as an SEO capable framework.

krokyze commented 1 year ago

Hey. You can do like this:

Seo.text(
  text: 'Made with ❤️ by',
  child: Seo.link(
    href: 'https://twitter.com/Emmett_Deen',
    anchor: '@Emmett_Deen',
    child: Text.rich(...),
  ),
)