Skip to content

Commit

Permalink
fix(build): orphaned and conflicting
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Sep 16, 2024
1 parent 675a738 commit a353b88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion crates/rari-doc/src/pages/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ pub fn build_doc(doc: &Doc) -> Result<BuiltDocy, DocError> {

let no_indexing =
doc.meta.slug == "MDN/Kitchensink" || doc.is_orphaned() || doc.is_conflicting();
let parents = if !doc.is_conflicting() && !doc.is_orphaned() {
parents(doc)
} else {
Default::default()
};

Ok(BuiltDocy::Doc(Box::new(JsonDoADoc {
doc: JsonDoc {
Expand All @@ -272,7 +277,7 @@ pub fn build_doc(doc: &Doc) -> Result<BuiltDocy, DocError> {
is_translated: doc.meta.locale != Locale::default(),
short_title,
is_active: true,
parents: parents(doc),
parents,
page_title: page_title(doc, true)?,
body,
sidebar_html,
Expand Down
18 changes: 14 additions & 4 deletions crates/rari-doc/src/pages/types/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Doc {
}

pub fn is_conflicting(&self) -> bool {
self.meta.slug.starts_with("orphaned/")
self.meta.slug.starts_with("conflicting/")
}
}

Expand All @@ -131,9 +131,19 @@ impl PageReader for Doc {
let mut doc = read_doc(&path)?;

if doc.meta.locale != Default::default() && !doc.is_conflicting() && !doc.is_orphaned() {
let super_doc = Doc::page_from_slug(&doc.meta.slug, Default::default())?;
if let Page::Doc(super_doc) = super_doc {
doc.copy_meta_from_super(&super_doc);
match Doc::page_from_slug(&doc.meta.slug, Default::default()) {
Ok(Page::Doc(super_doc)) => {
doc.copy_meta_from_super(&super_doc);
}
Err(DocError::PageNotFound(path, _)) => {
tracing::error!(
"Super doc not found for {}:{} (looked for {})",
doc.meta.locale.as_url_str(),
doc.meta.slug,
path
);
}
_ => {}
}
}

Expand Down

0 comments on commit a353b88

Please sign in to comment.