Skip to content

Commit

Permalink
Re-organise content and remove slotmap indirection level (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keats authored Apr 26, 2022
1 parent 92e80b5 commit 9ab1bf2
Show file tree
Hide file tree
Showing 133 changed files with 1,835 additions and 2,615 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Switch to pulldown-cmark anchor rather than ours, some (very niche) edge cases are not supported anymore, you can
also specify classes on headers now
- Now outputs empty taxonomies instead of ignoring them

### Other
- Fix markup for fenced code with linenos
Expand Down
107 changes: 48 additions & 59 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mime_guess = "2.0"

site = { path = "components/site" }
errors = { path = "components/errors" }
front_matter = { path = "components/front_matter" }
content = { path = "components/content" }
utils = { path = "components/utils" }
search = { path = "components/search" }
libs = { path = "components/libs" }
Expand Down
2 changes: 1 addition & 1 deletion components/config/src/config/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct LanguageOptions {
/// The filename to use for feeds. Used to find the template, too.
/// Defaults to "atom.xml", with "rss.xml" also having a template provided out of the box.
pub feed_filename: String,
pub taxonomies: Vec<taxonomies::Taxonomy>,
pub taxonomies: Vec<taxonomies::TaxonomyConfig>,
/// Whether to generate search index for that language, defaults to `false`
pub build_search_index: bool,
/// The search config, telling what to include in the search index for that language
Expand Down
8 changes: 6 additions & 2 deletions components/config/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct Config {
/// If set, files from static/ will be hardlinked instead of copied to the output dir.
pub hard_link_static: bool,

pub taxonomies: Vec<taxonomies::Taxonomy>,
pub taxonomies: Vec<taxonomies::TaxonomyConfig>,

/// Whether to compile the `sass` directory and output the css files into the static folder
pub compile_sass: bool,
Expand Down Expand Up @@ -99,7 +99,7 @@ pub struct SerializedConfig<'a> {
default_language: &'a str,
generate_feed: bool,
feed_filename: &'a str,
taxonomies: &'a [taxonomies::Taxonomy],
taxonomies: &'a [taxonomies::TaxonomyConfig],
build_search_index: bool,
extra: &'a HashMap<String, Toml>,
}
Expand Down Expand Up @@ -246,6 +246,10 @@ impl Config {
others
}

pub fn other_languages_codes(&self) -> Vec<&str> {
self.languages.keys().filter(|k| *k != &self.default_language).map(|k| k.as_str()).collect()
}

/// Is this site using i18n?
pub fn is_multilingual(&self) -> bool {
!self.other_languages().is_empty()
Expand Down
4 changes: 2 additions & 2 deletions components/config/src/config/taxonomies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct Taxonomy {
pub struct TaxonomyConfig {
/// The name used in the URL, usually the plural
pub name: String,
/// If this is set, the list of individual taxonomy term page will be paginated
Expand All @@ -13,7 +13,7 @@ pub struct Taxonomy {
pub feed: bool,
}

impl Taxonomy {
impl TaxonomyConfig {
pub fn is_paginated(&self) -> bool {
if let Some(paginate_by) = self.paginate_by {
paginate_by > 0
Expand Down
2 changes: 1 addition & 1 deletion components/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;

pub use crate::config::{
languages::LanguageOptions, link_checker::LinkChecker, search::Search, slugify::Slugify,
taxonomies::Taxonomy, Config,
taxonomies::TaxonomyConfig, Config,
};
use errors::Result;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[package]
name = "front_matter"
name = "content"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = {version = "1.0", features = ["derive"] }
time = { version = "0.3", features = ["macros"] }

errors = { path = "../errors" }
utils = { path = "../utils" }
libs = { path = "../libs" }
config = { path = "../config" }

# TODO: remove it?
markdown = { path = "../markdown" }

[dev-dependencies]
test-case = "2" # TODO: can we solve that usecase in src/page.rs in a simpler way? A custom macro_rules! maybe
tempfile = "3.3.0"
Loading

0 comments on commit 9ab1bf2

Please sign in to comment.