Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 348 additions & 18 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs-src/blog/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Summary

- [Dioxus 0.1 $ Jan 3 2022 $ Release Notes $ After months of work, we're very excited to release the first version of Dioxus! Dioxus is a new library for building interactive user interfaces with Rust.](introducing-dioxus.md)
- [Dioxus 0.1 $ Release Notes $ Jan 3, 2022 $ After months of work, we're very excited to release the first version of Dioxus! Dioxus is a new library for building interactive user interfaces with Rust.](introducing-dioxus.md)
- [Dioxus 0.2 $ Release Notes $ March 9, 2022 $ Just over two months in, and we already have a ton of awesome changes to Dioxus!](release-020.md)
- [Making Dioxus (almost) as fast as SolidJS $ Tech $ December 11, 2022 $ Using a new technique called subtree memoization, Dioxus is now almost as fast as SolidJS.](templates-diffing.md)
- [Dioxus 0.3 $ Release Notes $ February 8, 2023 $ The next big release of Dioxus is here! Templates, autoformatting, multiwindow support, and more!](release-030.md)
Expand Down
7 changes: 7 additions & 0 deletions packages/docsite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dioxus-search = { workspace = true }
# dioxus-playground = { workspace = true }

askama_escape = { version = "0.10.3", optional = true }
resvg = { version = "0.48.1", default-features = false, features = ["text", "raster-images"], optional = true }
ab_glyph = { version = "0.2.32", optional = true }
base64 = { version = "0.22.1", optional = true }
getrandom = { workspace = true, features = ["js"] }
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
Expand Down Expand Up @@ -60,6 +63,7 @@ gloo-timers = { version = "0.3.0", features = ["futures"] }
js-sys = "0.3.64"
serde-wasm-bindgen = "0.6.5"
automod = "1.0.13"
pulldown-cmark = { version = "0.13.0", default-features = false }
stork-lib = { workspace = true, features = [
"build-v3",
], default-features = false }
Expand All @@ -79,6 +83,9 @@ server = [
"dioxus/ssr",
"dioxus-docs-examples/server",
"dep:askama_escape",
"dep:resvg",
"dep:ab_glyph",
"dep:base64",
]
production = [
"dioxus-docs-examples/production",
Expand Down
Binary file added packages/docsite/og/fonts/Inter-Bold.ttf
Binary file not shown.
Binary file added packages/docsite/og/fonts/Inter-Medium.ttf
Binary file not shown.
Binary file added packages/docsite/og/fonts/Inter-Regular.ttf
Binary file not shown.
92 changes: 92 additions & 0 deletions packages/docsite/og/fonts/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
24 changes: 13 additions & 11 deletions packages/docsite/src/components/blog.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::icons;
use crate::Link;
use crate::{docs::router_blog::BookRoute as BlogRoute, Route};
use dioxus::prelude::*;
Expand Down Expand Up @@ -124,20 +123,23 @@ fn use_current_blog() -> Option<BlogMeta> {
Some(page_to_meta(page))
}

struct BlogMeta {
title: &'static str,
category: &'static str,
description: &'static str,
date: &'static str,
author: &'static str,
pub(crate) struct BlogMeta {
pub(crate) title: &'static str,
pub(crate) category: &'static str,
pub(crate) description: &'static str,
pub(crate) date: &'static str,
pub(crate) author: &'static str,
}

fn page_to_meta(page: &'static use_mdbook::mdbook_shared::Page<BlogRoute>) -> BlogMeta {
let raw_title = &page.title;
pub(crate) fn page_to_meta(page: &'static use_mdbook::mdbook_shared::Page<BlogRoute>) -> BlogMeta {
let raw_title = page.title.as_str();

// Posts are titled "Title $ Category $ Date $ Description", but fall back
// gracefully if a post doesn't match (e.g. fields swapped or missing)
let items = raw_title.splitn(4, " $ ").collect::<Vec<_>>();
let [title, category, date, description, ..] = items.as_slice() else {
panic!("Invalid post structure:");
let (title, category, date, description) = match items.as_slice() {
[title, category, date, description, ..] => (*title, *category, *date, *description),
_ => (raw_title, "", "", ""),
};

BlogMeta {
Expand Down
19 changes: 19 additions & 0 deletions packages/docsite/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub trait AnyBookRoute: Routable + PartialEq + Hash + Eq + Clone + Copy {
fn short_version() -> &'static str;
fn full_version() -> &'static str;
fn index() -> Self;
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str;
}

impl AnyBookRoute for router_blog::BookRoute {
Expand Down Expand Up @@ -117,6 +118,9 @@ impl AnyBookRoute for router_blog::BookRoute {
fn index() -> Self {
todo!()
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_blog::BookRoute::page_markdown(id)
}
}

impl AnyBookRoute for router_03::BookRoute {
Expand Down Expand Up @@ -159,6 +163,9 @@ impl AnyBookRoute for router_03::BookRoute {
section: Default::default(),
}
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_03::BookRoute::page_markdown(id)
}
}
impl AnyBookRoute for router_04::BookRoute {
fn sections(&self) -> &[use_mdbook::mdbook_shared::Section] {
Expand Down Expand Up @@ -200,6 +207,9 @@ impl AnyBookRoute for router_04::BookRoute {
section: Default::default(),
}
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_04::BookRoute::page_markdown(id)
}
}
impl AnyBookRoute for router_05::BookRoute {
fn sections(&self) -> &[use_mdbook::mdbook_shared::Section] {
Expand Down Expand Up @@ -241,6 +251,9 @@ impl AnyBookRoute for router_05::BookRoute {
section: Default::default(),
}
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_05::BookRoute::page_markdown(id)
}
}

impl AnyBookRoute for router_06::BookRoute {
Expand Down Expand Up @@ -281,6 +294,9 @@ impl AnyBookRoute for router_06::BookRoute {
section: Default::default(),
}
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_06::BookRoute::page_markdown(id)
}
}

impl AnyBookRoute for router_07::BookRoute {
Expand Down Expand Up @@ -321,4 +337,7 @@ impl AnyBookRoute for router_07::BookRoute {
section: Default::default(),
}
}
fn page_markdown(id: use_mdbook::mdbook_shared::PageId) -> &'static str {
router_07::BookRoute::page_markdown(id)
}
}
64 changes: 49 additions & 15 deletions packages/docsite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use serde::{Deserialize, Serialize};
pub mod components;
pub mod docs;
pub mod icons;
#[cfg(feature = "server")]
pub mod og_image;
pub mod seo;
pub mod shortcut;
pub mod snippets;
pub use components::*;
Expand All @@ -21,6 +24,7 @@ fn main() {
if std::env::args().any(|arg| arg == "--generate-search-index") {
llms::generate_llms_txt();
search::generate_search_index();
og_image::generate_og_images();
return;
}

Expand Down Expand Up @@ -97,14 +101,30 @@ fn Head() -> Element {

// Tell google to not index old documentation
let current_doc_route = use_route::<Route>();
let don_t_index = current_doc_route.is_docs() && !current_doc_route.is_latest_docs();
let meta = seo::PageMeta::for_route(&current_doc_route);
// Generated per-page images live at a stable unhashed path; the default
// image goes through asset!() which serves it at a hashed path
let og_image = if seo::has_generated_og_image(&current_doc_route) {
meta.image.clone()
} else {
format!(
"{}{}",
seo::SITE_URL,
asset!("/assets/static/opengraph.png")
)
};
let og_type = match meta.kind {
seo::PageKind::Article { .. } => "article",
seo::PageKind::Website => "website",
};

rsx! {
Title { "Dioxus | Fullstack crossplatform app framework for Rust" }
Title { "{meta.title}" }
Meta {
name: "description",
content: "Dioxus | A fullstack crossplatform app framework for Rust. Supports Web, Desktop, SSR, Liveview, and Mobile.",
content: "{meta.description}",
}
Link { rel: "canonical", href: "{meta.url}" }
Link {
rel: "icon shortcut",
r#type: "image/png",
Expand Down Expand Up @@ -133,31 +153,45 @@ fn Head() -> Element {
}
Meta {
property: "og:title",
content: "Dioxus | Fullstack crossplatform app framework for Rust",
content: "{meta.title}",
}
Meta { property: "og:type", content: "website" }
Meta { property: "og:type", content: og_type }
Meta {
property: "og:description",
content: "A fullstack crossplatform app framework for Rust. Supports Web, Desktop, SSR, Liveview, and Mobile.",
}
Meta { property: "og:url", content: "https://dioxuslabs.com" }
Meta {
property: "og:image",
content: "https://dioxuslabs.com/assets/static/opengraph.png",
content: "{meta.description}",
}
Meta { property: "og:url", content: "{meta.url}" }
Meta { property: "og:image", content: "{og_image}" }
Meta { property: "og:image:width", content: "1200" }
Meta { property: "og:image:height", content: "630" }
Meta { property: "og:image:alt", content: "{meta.title}" }
Meta { property: "og:site_name", content: "Dioxus" }
Meta {
name: "twitter:title",
content: "Dioxus - Fullstack crossplatform app framework for Rust",
content: "{meta.title}",
}
Meta {
name: "twitter:description",
content: "Dioxus | A fullstack crossplatform app framework for Rust. Supports Web, Desktop, SSR, Liveview, and Mobile.",
content: "{meta.description}",
}
Meta {
name: "twitter:image",
content: "https://dioxuslabs.com/assets/static/opengraph.png",
content: "{og_image}",
}
Meta { name: "twitter:card", content: "summary_large_image" }
Meta { name: "twitter:site", content: "@dioxuslabs" }
if let seo::PageKind::Article { published, author } = meta.kind {
if let Some(published) = published {
Meta {
property: "article:published_time",
content: "{published}",
}
}
Meta {
property: "article:author",
content: author,
}
}
Script {
r#async: true,
src: "https://www.googletagmanager.com/gtag/js?id=G-EBE72MVZ1B",
Expand All @@ -167,7 +201,7 @@ fn Head() -> Element {
src: asset!("/assets/gtag.js"),
r#type: "text/javascript",
}
if don_t_index {
if meta.noindex {
Meta { name: "robots", content: "noindex" }
}
}
Expand Down
Loading
Loading